![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174683/image.png)
How detect, crop and straighten a particular shape
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
riccardo isi
el 12 de Jul. de 2016
Comentada: riccardo isi
el 15 de Jul. de 2016
Hi all, I have to detect, crop and straighten this particular rectangular shape with rounded corner from the image, in order to classify this "film" used in dosimetry application.
These are different films belonging to different class:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154808/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154809/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154810/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154811/image.jpeg)
I have already tried with common methods like is shown in these posts without any useful result:
Any suggestion?
0 comentarios
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 12 de Jul. de 2016
Look at the outer band of the image, like a rectangular "ring" within 40 pixels (or whatever) of the image. Take the mode of those pixels in each color band to get the most common color. Create masks for each color channel and then combine them to form an overall mask. Then invert that to find blobs that are not the background color. Then fill holes with imfill() and get the convex hull. That will get you the rounded rectangle. Then call bwboundaries to get the coordinates and identify the flat parts to get the angle, then call imrotate() to rotate/fix it.
1 comentario
riccardo isi
el 14 de Jul. de 2016
Editada: riccardo isi
el 14 de Jul. de 2016
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!