How can I write a function that reduces image's size? I need help with how to pass in the image and then work with it.
1 view (last 30 days)
Show older comments
For instance if this is the format, how can I load the image in 'image' ? Do we do it it command window.
function sampledimage = subsample(image,factor)
0 Comments
Answers (2)
Image Analyst
on 7 Feb 2016
You don't need your own special custom function. There is already a function for that. It's called imresize(). Check it out.
0 Comments
Walter Roberson
on 7 Feb 2016
Do not name a variable "image", as that conflicts with the MATLAB graphics function "image".
MyImage = imread('Camerman.tif');
reduced_image = subsample(MyImage, 0.345);
2 Comments
Walter Roberson
on 8 Feb 2016
We do not have a context for that statement.
If you were asked to reduce an image by a factor of 2 in each direction then you could do that by extracting, for each row, pixels at index 1,3,5,7,9,... Clearly the end result would be half the number of pixels as the original (provided it was an even number of pixels). The size of an image for this purpose is the number of pixels it is in each direction.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!