How to combine thresholded images

3 views (last 30 days)
Hi,
I was following one of the tutorials on thresholding colour images and I am having trouble with one step. It is a colour jpg image and I am trying to remove background noise, large & small outlying spots and then count the number of spots.
Basically I separate the image into R , G and B components and then generate a threshold value and use the im2bw function. This step works fine, but when I try to combine them together to analyse the final binary image I am not getting the right thing.
The function I am using to combine the three is rgb=(r&g&b) . When I combine just r and g everything works fine and I see the red spots and the green spots come together. But when I include b in the function, it subtracts spots from the final image.
Is there something I am doing wrong, does this function not serve my purpose or is there something better I can do?
Thank you.

Accepted Answer

Image Analyst
Image Analyst on 18 Aug 2014
Please post your image and code. rgb is a very bad name for an image that is not RGB - it's deceptive. Your rgb image is actually a binary (logical) image, NOT an RGB image. What you did was to create a binary image that is true/white/1 ONLY where it's true/white/1 in the r binary image AND the g binary image AND the b binary image. Perhaps you want OR, I don't know. I can't really say more until you post your image(s) and code.

More Answers (1)

Meshooo
Meshooo on 18 Aug 2014
Use cat
RGB = cat(3, R, G, B)
  3 Comments
Adam
Adam on 18 Aug 2014
Use 'image' with the result of cat
Image Analyst
Image Analyst on 18 Aug 2014
Edited: Image Analyst on 18 Aug 2014
He has that image - that's just his original! If you did the same thing with lower case r,g,b you'd get an image with values around 0 and 1 and it would be so dark you could not see anything. So it's not a problem of whether he used imshow() or image(). And of course using bwlabel in that is just nonsense. So it's just a matter of doing the wrong thing(s) instead of the right thing(s). And you don't want to use cat() on the lower case r, g, b binary images.

Sign in to comment.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!