Save image as grayscale with specified resolution

19 ビュー (過去 30 日間)
Soda
Soda 2019 年 11 月 15 日
編集済み: Image Analyst 2019 年 11 月 15 日
Hello!
I want to save image (preferably jpg or tif) as grayscale with specified resolution(500 px * 500 px).
I converted image to gray scale and then blurred and added some noise. Following is what I tried
I = imread('sth.tif');
greyI = rgb2gray(I)
Iblur = imgaussfilt(greyI,1);
Inoise = imnoise(Iblur,'speckle',0.02);
inshow(Inoise)
saveas(Inoise,'image.tif')
However, when I try to save image using either imwrite, or saveas, it converts the image back to a color image and original resolution.
Thank you for your help in advance!

採用された回答

Image Analyst
Image Analyst 2019 年 11 月 15 日
編集済み: Image Analyst 2019 年 11 月 15 日
saveas() saves a screenshot, which can be any resolution - you can drag the window to any size you want, right?
You should use imresize(Inoise, [500,500]) then imwrite() which saves the image itself with the actual pixel dimensions (rows and columns).
Inoise = imresize(Inoise, [500,500]) ;
imwrite(Inoise, 'image.tif');

その他の回答 (0 件)

カテゴリ

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