I have this binary image with white spots: I want to represent each white spot by a rectangle with the same size of spot and if possible with same orientation. There are any function that do that? I can detect each spot using RP:
I would compute the smallest Feret diameter (shortest projection) with corresponding angle, and the perpendicular projection. That usually corresponds to the smallest bounding box.
See here for MATLAB code on computing Feret diameters: http://www.crisluengo.net/archives/408