- imread - https://www.mathworks.com/help/matlab/ref/imread.html
- imbinarize - https://www.mathworks.com/help/images/ref/imbinarize.html
- imwrite - https://www.mathworks.com/help/matlab/ref/imwrite.html
Coverted a grayscale image to binary, but....
조회 수: 9 (최근 30일)
이전 댓글 표시
I have a `grayscale` image which I have converted to `binary`. But, when I `imwrite` it, I don't get a `binary` image. That is, an image with two values (i.e; 0,1), why is that?
Thanks.
댓글 수: 0
답변 (1개)
ag
2024년 11월 13일 18:59
Hi Med,
I understand that you are facing issues while trying to save a binarized image.
Unfortunately, I am not able to reproduce the issue on my end. Please try the below code snippet to see if it resolves the issue:
I = imread('image.png');
BW = imbinarize(I); % imbinarize generates a matrix with values 0 and 1 as per the Otsu threshold for your image
imwrite(BW, "BinaryImage.png"); % saves the binary image in the cwd
For more details, please refer to the following MathWorks documentation:
Hope this helps!
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!