I have some particles that I have identified in a large image, and you need to parse smaller images for each particle. I used the function "BoundingBox" regionprops, but so far have not been successful. How can I now make a rectangular subimage of image I using the BoundingBox? I can use the BoundingBox to draw a rectangle on the original image, but the parameters returned by the BoundingBox do not seem to have pixel dimensions (x, y, width, height), (x1, y1, x2, y2), etc., Which I would expect the border to be returned. I wrote some code examples using coins.png to facilitate understanding. can you help me with this? Thanks!
figure(1); I = imread('coins.png'); bw = im2bw(I, graythresh(I)); bw2 = imfill(bw,'holes'); imshow(bw2); figure(2); L = bwlabel(bw2); imshow(label2rgb(L, @jet, [.7 .7 .7])) figure(3); imshow(I); s = regionprops(L, 'BoundingBox'); rectangle('Position', s(1).BoundingBox);
source share