Ask Your Question
0

Problem in removing particular colors from the given image

asked 2016-02-04 08:46:44 -0500

Dr Dre gravatar image

updated 2016-02-04 10:12:24 -0500

Hi Guys I have the following 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.

edit retag flag offensive close merge delete

Comments

Convert your images to a color space where those black and blue colors are seperable from the others. As a first guess, HSV could already do the trick!

StevenPuttemans gravatar imageStevenPuttemans ( 2016-02-04 09:05:37 -0500 )edit

What procedure should i follow next sir @StevenPuttemans

Dr Dre gravatar imageDr Dre ( 2016-02-04 10:13:13 -0500 )edit
3

Well, you need to find a function (or two) that results in a true value where the colors you are removing are, and false in the rest. Take a look at the pixel values for the colors you wish to remove. How are they different from the other colors? Is one value (of the 3) always lower or always higher? Then that's a good way to tell the difference. The threshold or bitwise functions can help turn that into a mask.

Tetragramm gravatar imageTetragramm ( 2016-02-04 16:33:04 -0500 )edit

Start by splitting up into channels, then take a look at the HSV channel properties and like @Tetragramm said, try to define ranges which apply for your seperation boundary.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-02-05 04:16:36 -0500 )edit

Thank U Guys

Dr Dre gravatar imageDr Dre ( 2016-02-05 11:27:35 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-02-06 08:49:07 -0500

Dr Dre gravatar image

updated 2016-02-06 08:57:06 -0500

I Filtered out only sky blue color, Pink Color, Orange and Green Color using masking function separetely and added the images to get an image containing only the 4 colors

then by converting bgr to gray and thresholding i could draw the contours

Thank U Every one for ur help and support

image description

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-02-04 08:46:44 -0500

Seen: 2,764 times

Last updated: Feb 06 '16