Digital Image Processing
Digital Image Processing
Group members:
Shahzaib hanif :(B-22271)
Submitted to:
Mam.Ramsha Imran
Introduction
We make an object detection system based on colors (we can take cook and Pepsi can images). It
can shows how we can use basic image processing to do complex tasks. It’s a nice introductory
application that can enhance our computer vision skills. It’s a simple python application that
reading the images for us and display the results. Basically it detects the Pepsi and coke cans
easily through their techniques.
Problem statement
In the program OpenCV used. opencv is used highly for the object detection purposes it’s the
python library. There is a lot where OpenCV is used but here in our project we use OpenCV to
detect the difference between the Pepsi and Coca-Cola cans. As we know about these brands
companies highly recommended around the world due to their taste. So the problem statement
or the problem faced during the procedure is that there is about use three types of color
categories here in which detection of the object could be easy. Here RGB(Ref Green Blue) color
is converted in to HSB( Hue Saturation Brightness). Here hue portion cover all the colors
saturation portion cover the intensity of the color and brightness is to cover brightness. The
problem facing is that algorithms just read bottles related colors which is red and blue and some
others combination of colors. So the programme are desighn in such a way that he will just read
about the pepsi and coco-cola branding bottels and in the return show which one is the pepsi and
which one is the coco-cola name written on them.
Algorithm: Open-CV
The algorithm or the library that is used highly in the field of computer related to the computer
vision problems. It also the machine learning capabilities init to read about the images that is
provided with the help of data-set
This libarary has more than 25000 of algorithms in it that is used to detect and regognizing of the
faces and the moving objects as well classify human object init,track camera movements, extract
3D models also find simmilar images from the given data sets .
Code:
import cv2
def colorProfiles(n):
if n == 0 :
name = "Pepsi"||here is the name defiend to the specfic object
hsv_lower = ( 95,100,100)\\
hsv_upper = (115,255,255)
(in color the blue color is start from 95 to 115\other part is saturation and
brightness of the color)
return (name,hsv_lower,hsv_upper)
if n == 1 :
name = "Coke"
hsv_lower = ( 0,100,100)
hsv_upper = (10,255,255)
return (name,hsv_lower,hsv_upper)
(the same color range are used here from 0 to 10)
frame = cv2.imread("cola_wars_promo.jpg")
for i in range(2):
name, hsv_lower, hsv_upper = colorProfiles(i)
mask = cv2.inRange(hsv,hsv_lower,hsv_upper)
conts, herirarchy =
cv2.findContours(mask.copy(),cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_NONE)
biggest = sorted(conts,key = cv2.contourArea,reverse=True)[0]
rect = cv2.boundingRect(biggest)
x,y,w,h = rect
cv2.rectangle(frame,(x,y),(x+w,y+h),(0,255,255),2)
cv2.putText(frame, name, (x,y),cv2.FONT_HERSHEY_SIMPLEX,1,
(0,0,255),2)
cv2.imshow("cola_wars_promo",frame)
cv2.waitKey(0)
cv2.destroyAllWindows()
RESULT IMAGES
Here is the result images that defiend the working of algorithm properly.lower is the simple
images of different types and the upper side is the result images