Down Sample Image by Deleting Alternating Rows & Columns

I am trying to down sample an image to 1/4 and 1/16 its original size, and the instructions are to "use simple decimation to remove every other row and column to do so".
I have been reading through the MATLAB documentation for imresize, downsample, and decimate, as well as various threads here and on other sites, and I cannot seem to figure out how to implement this task?
I = imread('filename');
J = downsample(I,4);
which gives me the correct resize vertically but doesn't change the horizontal dimension. How do I apply this downsample to both rows AND columns?

 Accepted Answer

J=I(1:4:end,1:4:end);

2 Comments

Thanks Matt! I actually figured that out after posting, by looking through the provided code later on in the task, but now I am wondering what the
(1:2:end, 1:2:end,:)
part of the command is representing? That is the portion that was provded (but not explained), so I just want to understand what "1","2", and "end" represent, as well as the ":" as the last term in parenthesis. Even if you (or anyone) could point me to where in the MATLAB documentation I would find this command/info to learn more about its use and syntax?
You're welcome. Please Accept-click the answer if it solves your problem.
To read about the 'end' operator and matrix indexing in general, see for example,

Sign in to comment.

More Answers (0)

Products

Release

R2021b

Asked:

on 27 Feb 2022

Edited:

on 27 Feb 2022

Community Treasure Hunt

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

Start Hunting!