How to extract a Roipoly area in an image with poly2mask function under my own defined coordinates

11 ビュー (過去 30 日間)
I am working on an application to convert a 2D image into 3D space, I need to divide the image into different areas and extract the pixel values and pixel koordinates of each area, I have defined my own coordinate system for the subsequent conversion. The starting point of the x and y axes are at the center of the picture Now I know the coordinates of the four vertices of the quadrilateral
When I use poly2mask function I get the area at the default coordinates, which not consistent with my own defined coordinates. So I would ask, how can I get the enclosed area with poly2mask function? Thanks in advance.

採用された回答

Image Analyst
Image Analyst 2022 年 6 月 25 日
poly2mask expects x and y to be in pixels. drawpolygon will give you the coordinates in pixels and thus should be fine for use immediately and directly in poly2mask.
If you have some other mapping and you want to use that in poly2mask then you'll have to map back to pixels to get the polygon on the image. For example if you used drawpolygon and got x and y, then you converted those into your special coordinate system, you'll have to unconvert them back to pixels, or else just use the original pixel coordinates that you got from drawpolygon.

その他の回答 (0 件)

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by