Save image as grayscale with specified resolution
12 views (last 30 days)
Show older comments
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!
0 Comments
Accepted Answer
Image Analyst
on 15 Nov 2019
Edited: Image Analyst
on 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');
0 Comments
More Answers (0)
See Also
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!