Crop out a section of the image in imshow, how?

4 ビュー (過去 30 日間)
Happy PhD
Happy PhD 2020 年 8 月 6 日
コメント済み: KSSV 2020 年 8 月 6 日
I have an image I, I want to crop out a section of the image so i dont use the whole image in the analysis.
I have two coordinates at the upper and lower corner, like
pts = [ 234 355; 1678 764];
that is p1 = [ 234; 355] and p2 = [1678; 764]. I want to create a rectangle within the area of these coordinates. The total image size is [1936, 1216].
My issue is that I get a little confused with the image coordinates, since the upper left corner has coordinate [1,1], lower left is [0,1216], upper right is [1936,1] and lower right is [1936,1216],.. (not like with a figure). I am not getting the coordinates correctly.
so how do I have to write to get the second rectangular cropped image in the right area?
I2 = I ( some coordinates) .. for example I2 = I(p1(1):p2(1), p1(2):p1(2)). this is the wrong area though
I been at this for an hour and I cant see how to make it work... :( please help!!

採用された回答

KSSV
KSSV 2020 年 8 月 6 日
Read about imcrop. Let I be your image.
rect = [234 355 (1678-234) (764-355)]
iwant = imcrop(I,rect)
imshow(iwant)
  2 件のコメント
Happy PhD
Happy PhD 2020 年 8 月 6 日
Thanks, I think i solved it.
I2=I(p1(2):p2(2), p1(1):p2(1));
I will look into your version.
KSSV
KSSV 2020 年 8 月 6 日
Yes, you can do this too.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by