0

私の画像は、特定のサイズ(256x256)で切り取った後のマットファイルです。サイズは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); 
+0

PNGに?あなたのコードを共有してください – drorco

答えて

0

使用関数imwrite機能あなたは、画像をトリミングして保存ましたか

A = rand(50); 
imwrite(A,'myGray.png') 
関連する問題