how to set the background color of this image to 0 and remaining foreground color to 1 to make this image binary?
조회 수: 2 (최근 30일)
이전 댓글 표시
![Colored Watershed Label Matrix.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/211171/Colored%20Watershed%20Label%20Matrix.png)
댓글 수: 0
채택된 답변
Image Analyst
2019년 3월 30일
Make a mask:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Now make the mask
mask = ~(recChannel ~= 0 & greenChannel == 0 & blueChannel == 0);
댓글 수: 2
Image Analyst
2019년 3월 30일
Your colors are not pure.
When I tried to save the image it looks like this is a labeled image returned from the watershed function, so you should already have the binary image to begin with, so that is what you want. You can also get it from the labeled matrix like
binaryImage = labeledMatrix ~= 0;
but that should not be necessary. Not sure how the white boundary lines got there though.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!