Cropping an image with coordinate values
古いコメントを表示
I have an image with 848*1102 pixels after edge detection, and I want to crop out a part of the image accurately, so I need to use the coordinate values of the top left and bottom right points. How do I get the coordinates of these two points and crop the image?
採用された回答
その他の回答 (1 件)
KALYAN ACHARJYA
2023 年 1 月 2 日
[rows,colm]=find(image==1);
Get the indices as rows & colm
3 件のコメント
Image Analyst
2023 年 1 月 2 日
編集済み: Image Analyst
2023 年 1 月 2 日
Then, to crop
row1 = min(rows)
row2 = max(rows)
col1 = min(colm)
col2 = max(colm)
yourImage = yourImage(row1:row2, col1:col2, :);
imshow(yourImage);
axis('on', 'image');
By the way, it may not be necessary for you to crop it unless you just want to see it bigger when you display it. Also you might want to call imclearborder to get rid of that thick white frame around it.
If you want to get rid of the thin white rectangular outline also, then let me know.
Sterne_17
2023 年 1 月 2 日
カテゴリ
ヘルプ センター および File Exchange で Region and Image Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


