Is it possible to crop image parallel with angle?

5 views (last 30 days)
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)

Accepted Answer

Image Analyst
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
Image Analyst
Image Analyst on 24 Sep 2018
Let's try to get the terminology straight.
Cropping is always, always parallel to the x and y axes because images must MUST be rectangular, not diamond shaped. This is because matrices are always rectangular and images are matrices.
Masking can be any shape at all from rectangular to diamond shaped to any arbitrary irregular shape. But the masked region must be in a rectangular image/matrix. The part outside the mask can be black, or white, or whatever you want the background to be.
I'm not sure what you mean when you say cropping is parallel to the edges, as if that's a bad thing. Again, cropping will always be parallel with the edges.
When you talk about angle, what angle is that? The angles along the edges of the diamond (tilted rectangular masking region)? What is the perpendicular angle? Do those angles have to do with the angles of the mask edges, or the angle of the predominant direction of the fingerprint edges? Note that some fingerprint patterns (e.g. circular whorls) don't have a predominant angle.
With those definitions in mind, try to explain what you want again, because I have no idea.
Why do you want to crop the images anyway? What can you do with the cropped /masked image that you can't do with the original image?
wisam kh
wisam kh on 25 Sep 2018
Edited: wisam kh on 25 Sep 2018
OK
Sorry if I could not explain the idea. Each pixel in the image has a orientation angle measured in certain ways, depending on the orientation of the ridges in the fingerprint. If I can find the orthogonal points with this angle I will get a new image that is almost similar to all the pictures when I apply the mask method, because I took into account the angle of point.
thank you again

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!