How can I convert Binary image to 2D binary matrix

조회 수: 7 (최근 30일)
Shahed
Shahed 2013년 3월 25일
I convert an image to binary image, but can't convert binary image to binary matrix.
I have the code so far,
[X,map]= imread('E:/8SEM/PROJECT_ALOK_SIR/picture/t1000.jpg');
BW = im2bw(X,map,0.3);
imshow(X,map), figure, %if we don't use figure we can't see the two images
imshow(BW)
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 3월 25일
jpeg file format cannot store indexed (pseudocolor) images, so the map will always be empty for a jpg file.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2013년 3월 25일
What is the problem, if any? Get rid of map in both statements. Then, does it not display or something? Or does it display all black or all white? If so, you might have chosen the wrong threshold. Try something other than 0.3, or try the graythresh() function.
fullFileName = 'E:/8SEM/PROJECT_ALOK_SIR/picture/t1000.jpg';
if exist(fullFileName, 'file')
rgbImage = imread(fullFileName);
binaryImage = im2bw(rgbImage, 0.3);
subplot(1, 2, 1);
imshow(rgbImage)
subplot(1, 2, 2);
imshow(binaryImage);
else
errorMessage = sprintf('Image file does not exist:\n%s', fullFileName);
uiwait(warndlg(errorMessage));
end

추가 답변 (2개)

Walter Roberson
Walter Roberson 2013년 3월 25일
A binary image stored in memory is a binary matrix.

Shahed
Shahed 2013년 3월 27일
Thank you very much all of you .............

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by