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?

 Respuesta aceptada

Matt J
Matt J el 27 de Feb. de 2022
Editada: Matt J el 27 de Feb. de 2022
J=I(1:4:end,1:4:end);

2 comentarios

Jason Almeida
Jason Almeida el 27 de Feb. de 2022
Editada: Jason Almeida el 27 de Feb. de 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?
Matt J
Matt J el 27 de Feb. de 2022
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,

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2021b

Preguntada:

el 27 de Feb. de 2022

Editada:

el 27 de Feb. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by