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?

 Risposta accettata

Matt J
Matt J il 27 Feb 2022
Modificato: Matt J il 27 Feb 2022
J=I(1:4:end,1:4:end);

2 Commenti

Jason Almeida
Jason Almeida il 27 Feb 2022
Modificato: Jason Almeida il 27 Feb 2022
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,

Accedi per commentare.

Più risposte (0)

Prodotti

Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by