Is it possible to crop image parallel with angle?
7 views (last 30 days)
Show older comments
Hello
If I set a point in the picture with the angle of its orientation, is there a possible way to crop around this point, where the center of the cropped image centers the position of this point and parallels the orientation of this point?
point(x,y,o)

0 Comments
Accepted Answer
Image Analyst
on 22 Sep 2018
Yes, as long as you also specify the width of the box perpendicular to the orientation line. Otherwise you just get the entire image like you have now. Simply create a mask with poly2mask() with the polygon you've created to outline the region you want.
[rows, columns, numberOfcolorChannels] = size(grayImage);
mask = poly2mask(x, y, rows, columns);
then mask it
grayImage(~mask) = 0; % Blacken outside mask.
If you also want to crop in addition to blackening, then find the limits of the mask then use indexing.
[r,c] = find(mask);
topRow = min(r);
bottomRow = max(r);
leftCol = min(c);
rightCol = max(c);
croppedImage = grayImage(topRow:bottomRow, leftCol:rightcol);
3 Comments
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!