How to cut an image by pixels without imcrop?

6 visualizaciones (últimos 30 días)
Megan Wang
Megan Wang el 14 de Jun. de 2017
Comentada: Megan Wang el 14 de Jun. de 2017
I would like to crop the image from (1,1) to (340,562) using a "while" function. This is the code I have so far
c = I2(:,1);
d = I2(1,:);
while c <= 562
c = c+1
I3 =
while d <= 340
d = d+1
I3 =
end
end
I don't know what to put in the I3= parts to crop the image if the pixel coordinates satisfy those conditions. Also I can't use imcrop since this is an assignment and it was specified to be completed this way.

Respuesta aceptada

Image Analyst
Image Analyst el 14 de Jun. de 2017
Initialize c and d to 1, then
c = 1;
I3 = zeros(340, 562); % Preallocate for speed.
while c <= 562
d = 1;
while d <= 340
I3(d, c) = I2(d, c);
....
....
c = c+1
....
and so on. See if you can fill in the missing lines for your homework. It's pretty close - just 3 more lines of code.

Más respuestas (0)

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by