Save file.bmp from a matrix.
이전 댓글 표시
Dear all,
I am quite new in Matlab and I am eperiencing some issue by saving a matrix as an image.
I have a matrix (202 x 134 double) composed of 0 and 1. I want to generate a black and white image from that.
If used: imshow(mymat), and I save the file from that it is perfect; but I have to save images within a loop.
I tried to use:
imwrite(mymat,sprintf('FIG%d.bmp',z1))%,'Quality',100)
But the quality of the image is very very low as you can see from the attached pictured.

I tried also to use:
image = mat2gray(mymat,[0 1]);
imwrite(image,sprintf('FIG%d.bmp',z1))
But I get the same result.
Thanks in advance.
댓글 수: 4
Rik
2021년 4월 19일
202x134 is a fairly low resolution already, but the file you uploaded is 67x101.
Can you confirm that size(mymat) returns [202 134]?
I would suggest avoiding image as a variable name, as that is already a base Matlab function/class.
Michele Vanini
2021년 4월 19일
Rik
2021년 4월 19일
How did you get the idea you have a 202x134 matrix? Nothing so far indicates that. Using a different function will not fix anything if your input data is not what you expect.
Michele Vanini
2021년 4월 19일
편집: Michele Vanini
2021년 4월 19일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!