How to detect objects in an image based on colour?

337 views Asked by At

I am using a handwriting database for writer recognition. I'm using the QUWI database, it has a sample of an original image and a sample of the image segmented into lines by giving each line a different colour.

For example here is the original image: (stackovrflow was not uploading this image because of its size)

http://pasteboard.co/131PthXa.jpg

And here is the image where the lines are detected and separated via colour:

enter image description here

Is there anyway I can use the method they used to extract the lines from the original image based on colour. Such as using the colours of this image as a mask?

1

There are 1 answers

1
Ander Biguri On BEST ANSWER

Yes there is, I guess.

First, I am assuming that the second image is EXACTLY the same as the first image, but with colors.

The first thing I would do is match the images, as you want the mask to be exactly on top of the other image. To do that I would recommend you use SURF/SIFT feature extraction and feature matching. Have a look here if you don't know how to do it:

http://uk.mathworks.com/help/vision/ref/matchfeatures.html

With that you should b able to match exactly both images.

Then I'll segment by colors the mask image, using HSV color space. In that color space, the values of H are the color itself. For example, values around 120 are green colors. Knowing which colors you want to segment, you can manually pick the H value.

Once there you are done, you have the mask with the values you want to keep. Multiply your mask with the original image and you have the result.

PD: I dont really understand why you'd want to do it this way, as your mask is your original image, so instead of matching, using the colored image as mask,... you could just do the color segmentation in the mask and you'd have the result.