Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem in removing certain colors from the given image

Hi Guys I have the following image image description

I want to draw contour around orange , green, light blue and pink box. I don't want to draw contour around black as well as dark blue box.

Things I Tried ... 1.) I converted the image to gray and applied thresholding but the resulting image was having only black and white colors. So that didnt work

ray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(gray,100,255,cv2.THRESH_BINARY_INV)

2.) I tried masking the required image out . Even that didnt work ..

lower = np.array(param1)
upper = np.array(param2)
mask  = cv2.inRange(img, lower, upper)
res   = cv2.bitwise_and(img, img, mask= mask)

I dont understand what to do Of course there is one method of filtering out one color at a time and applying contour , but i want to avoid this approach.

I want to know if there is any method which basically removes black and blue box from the image and the final image contains only orange , green pink and light blue box.

I am using python 2.7 with cv2

Problem in removing certain particular colors from the given image

Hi Guys I have the following image image description

I want to draw contour around orange , green, light blue and pink box. I don't want to draw contour around black as well as dark blue box.

Things I Tried ... ...

1.) I converted the image to gray and applied thresholding but the resulting image was having only black and white colors. So that didnt work

ray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(gray,100,255,cv2.THRESH_BINARY_INV)

2.) I tried masking the required image out . Even that didnt work ..

lower = np.array(param1)
upper = np.array(param2)
mask  = cv2.inRange(img, lower, upper)
res   = cv2.bitwise_and(img, img, mask= mask)

I dont understand what to do Of course there is one method of filtering out one color at a time and applying contour , but i want to avoid this approach.

I want to know if there is any method which basically removes black and blue box from the image and the final image contains only orange , green pink and light blue box.

I am using python 2.7 with cv2

Problem in removing particular colors from the given image

Hi Guys I have the following image image description

I want to draw contour around orange , green, light blue and pink box. I don't want to draw contour around black as well as dark blue box.

Things I Tried ...

1.) I converted the image to gray and applied thresholding but the resulting image was having only black and white colors. So that didnt work

ray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(gray,100,255,cv2.THRESH_BINARY_INV)

2.) I tried masking the required image out . Even that didnt work ..

lower = np.array(param1)
upper = np.array(param2)
mask  = cv2.inRange(img, lower, upper)
res   = cv2.bitwise_and(img, img, mask= mask)

I dont understand what to do Of course there is one method of filtering out one color at a time and applying contour , but i want to avoid this approach.

I want to know if there is any method which basically removes black and blue box from the image and the final image contains only orange , green pink and light blue box.

The output image should be in the form of

image description I am using python 2.7 with cv2

Problem in removing particular colors from the given image

Hi Guys I have the following image image description

I want to draw contour around orange , green, light blue and pink box. I don't want to draw contour around black as well as dark blue box.

Things I Tried ...

1.) I converted the image to gray and applied thresholding but the resulting image was having only black and white colors. So that didnt work

ray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(gray,100,255,cv2.THRESH_BINARY_INV)

2.) I tried masking the required image out . Even that didnt work ..

lower = np.array(param1)
upper = np.array(param2)
mask  = cv2.inRange(img, lower, upper)
res   = cv2.bitwise_and(img, img, mask= mask)

I dont understand what to do Of course there is one method of filtering out one color at a time and applying contour , but i want to avoid this approach.Input Image

I want to know if there is any method which basically removes black and blue box from the image and the final image contains only orange , green pink and light blue box.box i.e. I want my output image to be displayed as

The output image should be in the form of Output Image

image description I am using python 2.7 with cv2

Update

Following the suggestion give by @StevenPuttemans

I converted my given image to HSV using following code

img = cv2.imread('Image.jpg')
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
cv2.imshow('hsv',hsv)

I got output as

Intermediate Output

What procedure should i follow next to get my output as shown in 2nd image.

Problem in removing particular colors from the given image

Hi Guys I have the following image

Input Image

Input Image

I want to know if there is any method which basically removes black and blue box from the image and the final image contains only orange , green pink and light blue box i.e. I want my output image to be displayed as

Output Image

I am using python 2.7 with cv2

Update

Following the suggestion give by @StevenPuttemans

I converted my given image to HSV using following code

img = cv2.imread('Image.jpg')
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
cv2.imshow('hsv',hsv)

I got output as

Intermediate Output

What procedure should i follow next to get my output as shown in 2nd image.