Ask Your Question
0

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

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

simba1382 gravatar image

I have been trying to do that:

http://prntscr.com/umv66 -> http://goo.gl/Bgmv2 (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(http://goo.gl/OtK4G) -> S Channel(http://goo.gl/oo8h6) ->Otsu(http://goo.gl/cnfxU)

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
2

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

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: http://docs.opencv.org/modules/core/doc/basic_structures.html?highlight=unsharp#matrix-expressions . These processes you need to adress in reversed order. Good luck!

edit flag offensive delete link more

Comments

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 -0600 )edit

Question Tools

Stats

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

Seen: 432 times

Last updated: Mar 02 '13