jpg形式からpng形式への変更について

11 views (last 30 days)
Kenta
Kenta on 7 Jun 2019
Commented: Kenta on 8 Jun 2019
IMG = imread('1.jpg'); %画像読み込み
imshow(IMG,'Border','tight');
saveas(gcf,'test_1.png') %画像の保存
上記のコードで
.jpg形式の画像ファイルを読み込み、
.png形式のファイルとして出力する
プログラムを作成中です。
この際に、入力の画像ファイルの大きさと
出力画像ファイルの大きさが異なるのはなぜでしょうか?
640×480を入力ファイルとしても
667×500の画像が出力されます。

Accepted Answer

Kazuya
Kazuya on 7 Jun 2019
imwrite 関数を使うのがよいかと。
A = rand(50);
imwrite(A,'myGray.png') % サンプル画像
B = imread('myGray.png');
whos B
imwrite(B,'myGray.jpg'); % jpg で保存
C = imread('myGray.jpg');
whos C
% 同じサイズが確認できます。
  1 Comment
Kenta
Kenta on 8 Jun 2019
ありがとうございます!
imwriteに変更して解決できました。

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!