how to set the dpi while using 'imwrite' to save a matrix into an image of 'jpg' format?

9 ビュー (過去 30 日間)
A is a matrix of 1000*1000*3
I want to export A as a 'jpg' image with dpi=240
imwrite(A,'filename.jpg');
the default dpi value is 96, how to change it into 240?

採用された回答

Image Analyst
Image Analyst 2012 年 5 月 13 日
That is not one of the parameters that you can set with MATLAB's imwrite() function.
  4 件のコメント
Li Shenguang
Li Shenguang 2012 年 5 月 14 日
good idea, thank you~
David Young
David Young 2023 年 7 月 11 日
It seems silly that you can't set the resolution parameter for jpegs when you can for tiffs. It surely would be the work of moments to put it into the imwrite code - it's just a number to go into the file header.

サインインしてコメントする。

その他の回答 (1 件)

DGM
DGM 2023 年 7 月 11 日
You use external tools. If you have exiftool, use that.
% take a clean image
inpict = imread('peppers.png');
% write it to a degraded 4:2:0 JPG at 75% quality
fname = 'crustBelongsOnPies.jpg';
imwrite(inpict,fname)
% set x and y resolution tags and units using external tools
resolution = 240;
comstr = sprintf(['exiftool %s '...
'-xresolution=%d '...
'-yresolution=%d '...
'-resolutionunit=inches -v2'],...
fname,resolution,resolution)
system(comstr,'-echo')
% inspect to see that the tags have been set
imfinfo(fname)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by