How to cut an image by pixels without imcrop?
6 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Image Analyst
on 14 Jun 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.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!