How can I count the number of markers in a ROI after using impoly?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am working on a project where I need to count the number of markers within a drawn ROI on a .fig image using the impoly function. This .fig image is a MATLAB drawn representation of the original image and has already been generated from another code. In this image, there are plotted markers of different types (green squares and red circles) that represent different aspects of the original image.
Is there a simple way of doing this that I am just not getting? I am getting the error "Attempt to reference field of non-structure array" in regard to the "count_pa = BF_pa.NumObjects;" line. So far I have:
ROI_BF = 'MDA103L_tracingfig.fig';
openfig(ROI_BF); %Display image to determine number of masks needed
n = input('How many masks are needed?'); %Ask user for number of masks needed
for i=1:n
BF = impoly(gca); setColor(BF,'b'); %Draw polygon around Barrel Field (BF)
BF_pa = findobj(gca,'Color','r'); %find penetrating arteriole markers
count_pa = BF_pa.NumObjects;
BF_anast = findobj(gca,'Color','g'); %find anastomoses markers
count_anast = BF_anast.NumObjects;
end
end
Ultimately I would like to draw multiple ROIs and be able to count the numbers of green square and red circle markers in each ROI. I have attached the image that I use in the code. Also, I am using the R2013a version.
0 commentaires
Réponses (1)
Image Analyst
le 3 Juil 2015
Change your other software so that BF_pa includes the x,y coordinates of all the colored spots. Then simply use inpolygon() to do the counting. If you don't get the x,y coordinates, it's much harder and maybe not 100% accurate because many of the spots overlap almost completely.
2 commentaires
Image Analyst
le 7 Juil 2015
You drew the red spots on there so you must already know their coordinates.
You can use impoly() or roipoly() or roipolyold() to have the user indicate a polygon and get the vertex coordinates for them.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!