using prior data for regionprops in new image

1 view (last 30 days)
I encountered a problem in using previous data for regionprops in my image that contains 20 shapes. I want to use prior data of the centroids and bounding boxes in a couple of other images, which are a little different from previous ones. I have gotten prior information from regionprops and I will use the area inside bounding box for the shapes in new images. This means that I want to use same locations of one of the images (bounding box and centroid) to calculate area of shape in other images using regionprops. Is this possible? How to define my code to use prior information?
W = bwlabel(CM);
p = regionprops(W, 'BoundingBox', 'Extrema', ...
'Centroid','Area', 'EquivDiameter');
%figure, imshow(W);
% count shapes with centroids
extrema1 = cat(1, p.Extrema);
left_most_bottom1 = extrema1(6:8:end, :);
left1 = left_most_bottom1(:, 1);
bottom1 = left_most_bottom1(:, 2);
% quantize the bottom coordinate
bottom1 = 6 * round(bottom1 / 6);
[sorted, sort_order] = sortrows([bottom1 left1]);
p2 = p(sort_order);
% counting shapes
hold on
for n1 = 1:numel(p2)
centroid1 = p2(n1).Centroid;
text(centroid1(1), centroid1(2), sprintf('%d', n1));
end
hold off

Answers (1)

Image Analyst
Image Analyst on 22 May 2015
I've read this several times and I can't figure out what you want. From what I can tell, you want to use a prior binary image or the bounding boxes of objects in it as a mask against your current image. Is that what you want to do?
Or maybe you want to use imreconstruct() or xor().
Please clarify, with sample images if possible.
  2 Comments
Carlos Zuniga
Carlos Zuniga on 22 May 2015
Thanks for read and reply my question. My problem is that I have a binary image with several objects and another image with same objects but a bit moved from the previous place. Is it possible to use some regionprops (boundingbox and centroid) from the previous image in the new one? These objects in new picture are located in a way that, they have different area, and I need their new area, while keeping boundingbox and centroid of previous image.
Image Analyst
Image Analyst on 22 May 2015
That's "tracking". You can do it yourself if you keep track of the centroids and assume that each blob didn't move very far. So even though they may have different label numbers, you can figure out which is which by computing the distance between each centroid and the centroids in the prior photo.
The Computer Vision System Toolbox also has tracking capability, so look into that.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!