Hi, I have written this code to crop out just a connected component on an image:
rp = regionprops(cc, 'BoundingBox');minr = rp(stainid).BoundingBox(2);minc = rp(stainid).BoundingBox(1);maxr = rp(stainid).BoundingBox(2) + rp(stainid).BoundingBox(4);maxc = rp(stainid).BoundingBox(1) + rp(stainid).BoundingBox(3);imstainzoom = im(minr:maxr, minc:maxc);
It works, but isn't the best code possible. Also, the bounding box returns non-integers (why is that?). Is there a much more efficient way to do this?
Best Answer