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

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

Réponse acceptée

Kazuya
Kazuya le 7 Juin 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 commentaire
Kenta
Kenta le 8 Juin 2019
ありがとうございます!
imwriteに変更して解決できました。

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!