First time here? Check out the FAQ!

Ask Your Question
0

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

asked Mar 1 '13

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!

Preview: (hide)

1 answer

Sort by » oldest newest most voted
2

answered Mar 2 '13

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!

Preview: (hide)

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 (Mar 7 '13)edit

Question Tools

Stats

Asked: Mar 1 '13

Seen: 457 times

Last updated: Mar 02 '13