How to combine thresholded images
조회 수: 4 (최근 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!