0
我的圖像是在我用特定尺寸256x256裁剪後的mat文件中,在寫入png文件之前大小是正確的。我以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);
你怎麼裁剪圖像並保存pngs?請分享您的代碼 – drorco