Image analysis - Bounding Box converted to Circular Mask
Ältere Kommentare anzeigen
Hello, I have a greyscale image that I have located the centroids, binarised, area filtered and then drawn bounding boxes around

I create the bounding boxes by:
s = regionprops(img1,'Centroid','Circularity','BoundingBox');
cen = cat(1,s.Centroid); circ=cat(1,s.Circularity);
x1=cen(:,1); y1=cen(:,2);
BB=cat(1,s.BoundingBox);
so BB has all the info in.
As I want to project this mask onto my raw image to extract the integrated intensity at each spot, I would rather circularise the boxes. This has been done for a single spot using:
% For e.g the 25th spot
i=25;
R=max(BB(i,3),BB(i,4)); % take the max dimension of the rectangle
V=nsidedpoly(1000,'Center',[x1(i) y1(i)],'Radius',R*1).Vertices;
mask=poly2mask(V(:,1),V(:,2),sy,sx);
ax4=nexttile;
myImagesc(app,ax4,mask); title(ax4,'Keep');
This works beautifully for a single spot

So my question is how I get all of the spots on the binary mask , I tried the following but with no luck:
n=numel(x1); % This is the number of spots
mask=[];
for i=1:n
R=max(BB(i,3),BB(i,4));
V=nsidedpoly(1000,'Center',[x1(i) y1(i)],'Radius',R*1).Vertices; %Was 10
mask=mask+poly2mask(V(:,1),V(:,2),sy,sx);
end
I dont know how to correctly perform the "addition or combining" of all the individual circular masks
mask=mask+poly2mask(V(:,1),V(:,2),sy,sx);
Akzeptierte Antwort
Weitere Antworten (1)
Kategorien
Mehr zu Region and Image Properties finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
