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)
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)

Answers (2)

Image Analyst
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.

Walter Roberson
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
tehreem fatima
tehreem fatima on 8 Feb 2016
thank you for your response. also need help with this statement 'In particular, it reduces the size of an image by taking only pixels every ‘factor’ pixels apart.'
What does it mean? i created a function that reduces the image size by the given factor. But what to do with the pixels ? does it mean we only need to work with some pixels rather than the whole image? If so, how this can be done.
thanks
Walter Roberson
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.

Sign in to comment.

Categories

Find more on Images 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!