Inspect zone of interest in images?

Hi,

Trying to inspect few little section of 10x10 pixels in a zone of interest determined from a binarized photo, the zone of interest is highlighted as shown below.

How can I capture (randomly) let say 10 images of 10x10 pixels located in the zone of interest from the original image? Getting the captured image coordinates would be good to check the location on the original. Any example would be great. :wink:

Thank you

Hugh

Hi again,

Let’s take it another way. :slight_smile:
How to get random coordinates within a zone of interest of complex shape with a contour. In my case, the zone of interest can be long and skinny, U-Shape like, etc… so a Centroid function would not work.
Hope this clarifies my question :wink:

Regards

Hugues

Hughes,

This sketch uses Erosion with a kernel that has the size of your small images:

pills = Binarize[i];
res = Erosion[pills, BoxMatrix[radii], Padding -> 0];
pos = PixelValuePositions[res, 1];

These positions pos are the coordinates of the center of the small images. Once you have the positions, you need to iterate picking one randomly and removing all the leftover positions that correspond to overlapping small images.

After you have done that, you can extract the small images using ImageTrim:

ImageTrim[image, {#}, radii] & /@ pos