How to cut an image by pixels without imcrop?

5 次查看(过去 30 天)
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.

采纳的回答

Image Analyst
Image Analyst 2017-6-14
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by