Save image as grayscale with specified resolution

3 vues (au cours des 30 derniers jours)
Soda
Soda le 15 Nov 2019
Modifié(e) : Image Analyst le 15 Nov 2019
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!

Réponse acceptée

Image Analyst
Image Analyst le 15 Nov 2019
Modifié(e) : Image Analyst le 15 Nov 2019
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');

Plus de réponses (0)

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by