MATLAB: How detect, crop and straighten a particular shape

cropdetectImage Processing Toolboxshapestraighten

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:
I have already tried with common methods like is shown in these posts without any useful result:
Any suggestion?

Best Answer

See attached m-file that produces the figure below: