How to cut an image by pixels without imcrop?

6 ビュー (過去 30 日間)
Megan Wang
Megan Wang 2017 年 6 月 14 日
コメント済み: Megan Wang 2017 年 6 月 14 日
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.
  1 件のコメント
Megan Wang
Megan Wang 2017 年 6 月 14 日
Thanks so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by