Ask Your Question

How to filter an RGB image and transform into an BW one

asked 2013-03-01 15:14:50 -0500

simba1382 gravatar image

I have been trying to do that: -> (You can ignore the red lines, I just added them to illustrate the final objective)

So, what I've done in the first case was: Using MatLab, I transformed rgb -> hsv and picked up the s channel (a.k.a saturation). Then I used Otsu (called graythresh in matlab) to binarize and transform into a black and white picture. Everything worked perfectly.

Now, in the second case this doesn't work so well:

Base img( -> S Channel( ->Otsu(

As you can see, the Otsu filter becomes useless in this case. Is there any workaround or other way I should be taking? Thanks in advance!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-03-02 16:56:26 -0500

Guanta gravatar image

Instead of Otsu's method you could use an adaptive binarization approach via cv::adaptiveThreshold . However note that your image has undergone three processes: first different brightness, probably not that challenging if you use adaptive-binarization. Second the image has undergone salt and pepper noise --> median-filter. And third it has been blurred, probably by a gaussian --> you need to deblur it ( use unsharp-technique, a code snippet can be found in the openCV-Doku: . These processes you need to adress in reversed order. Good luck!

edit flag offensive delete link more


Thanks a lot, I actually was able to apply your very explained answer quickly and learn a lot from it. Thanks for everything!

simba1382 gravatar imagesimba1382 ( 2013-03-06 20:22:05 -0500 )edit

Question Tools


Asked: 2013-03-01 15:14:50 -0500

Seen: 253 times

Last updated: Mar 02 '13