How to combine thresholded images
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Image Analyst
2014-8-18
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.
0 个评论
更多回答(1 个)
Meshooo
2014-8-18
Use cat
RGB = cat(3, R, G, B)
3 个评论
Image Analyst
2014-8-18
编辑:Image Analyst
2014-8-18
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!