在我用特定尺寸256x256裁剪后,我的图像在mat文件中,在写入png文件之前大小正确。我用png格式保存了它们。现在,我想处理它们并意识到尺寸不一样,原因是什么?我该如何解决?感谢
这段代码:
[m1,m2] = size(II);
i1_start = floor((m1)/2)-floor(n/2); % or round instead of floor; using neither gives warning
i1_stop = i1_start + n;
i2_start = floor((m2)/2)-floor(n/2);
i2_stop = i2_start + n;
B = II(i1_start+1:i1_stop, i2_start+1:i2_stop);
figure ,imshow(B,[]);
这是png转换的代码:
outfile = sprintf(png_filename)
data=uint8(data);
imwrite(data,outfile,'png','BitDepth' ,8);
答案 0 :(得分:0)
使用imwrite功能
A = rand(50);
imwrite(A,'myGray.png')