How do I create a sub image of a larger image?

3 ビュー (過去 30 日間)
Charles
Charles 2013 年 4 月 12 日
移動済み: DGM 2023 年 2 月 14 日
I have two vectors which define the x and y coordinates of the vertices of a convex polygon. For example:
L = linspace(0,2.*pi,6); xv = cos(L)';yv = sin(L)';
xv = [xv ; xv(1)]; yv = [yv ; yv(1)];
Given an image, I want to display only the part of the image that is inside this polygon. What is the way to do it?

採用された回答

Image Analyst
Image Analyst 2013 年 4 月 12 日
I have a masking demo if you want to see it. It blackens outside the ROI. Do you want that, or you want the bounding box cropped out?
  10 件のコメント
Image Analyst
Image Analyst 2021 年 8 月 8 日
移動済み: DGM 2023 年 2 月 14 日
@Aravind Prabhu Gopala Krishnan, what do you want to do with the image once you have it? You can use conv2() or nlfilter() to move over by one pixel. Sounds like you were using blockproc(). blockproc can also move over by one pixel as I show in the attached demo. All these functions get the subimage and do something with it and return a value or subimage. In the custom function, or the main function, you can save the subimage to disk if you want. Be aware that for a 256x256 image moving over by one pixel each time you'd have 255x255 = 65025 images to save. And for what purpose? Why not just process them as you get them and discard them? Why save them?
Aravind Prabhu Gopala Krishnan
Aravind Prabhu Gopala Krishnan 2021 年 8 月 9 日
移動済み: DGM 2023 年 2 月 14 日
I have 10,000 images i cant process that much images in neural network using matlab i dont have gpu, so i have to use google colab to train the images in neural network using python.

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

その他の回答 (1 件)

Alex Taylor
Alex Taylor 2013 年 5 月 23 日
編集済み: DGM 2023 年 2 月 14 日
In addition to this demo, you might also take a look at roipoly. You can use the logical image returned by roipoly as a mask.

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by