Is it possible to crop image parallel with angle?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
wisam kh
el 22 de Sept. de 2018
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 comentarios
Respuesta aceptada
Image Analyst
el 22 de Sept. de 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 comentarios
Image Analyst
el 24 de Sept. de 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?
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!