create mask (line) based on conditional (mask)
Show older comments
would like to create a mask that hightlights image pixels above or below a threshold
from each element in the mask, would like to draw a circle around it (anotehr mask) so as to make it stand out in the image
not sure how to implement the circular mask, seems to need XY coordinate (wont take maska)
function Findnoise(app, event)
highedit = str2num(app.highEditField.Value);
lowedit = str2num(app.lowEditField.Value);
maska= app.a >=highedit & app.a <=lowedit;
hcirc = drawcircle(app.UIAxes, 'Center',maska,'Radius',10,'StripeColor','red'); <- problematic line
% mask1 = hcirc.createMask;
% imagesc(app.a,'Parent',app.UIAxes);
end
Accepted Answer
More Answers (1)
Image Analyst
on 21 Aug 2024
Based on your question and the answer, I don't understand. I don't know why you're messing with circles when regions in a threshold range will, in general, not be perfectly circular.
If you simply want to outline pixels above, or in the range of, a threshold, simply threshold and use bwboundaries followed by visboundaries.
If you want to tint different/separate regions with different colors and opacities, then use labeloverlay.
If you want a circle at the centroid of the blob just to "note" where the blob is in a visual sense, then you can use
hold on;
plot(x, y, 'r.', 'MarkerSize', 30);
to place a red dot at the centroid. To find the centroids you can use regionprops
props = regionprops(mask, 'Centroid');
xy = vertcat(props.Centroid);
x = xy(:, 1);
y = xy(:, 2);
You could also use the centroids to place a number at each centroid using the text function. This essentially counts/labels each blob with a unique number, rather than just doing a dot. Of course you could combine the things, like have the outline around each blob with a dot at the center and a number next to the dot.
If you want to place an ellipse over each blob (that has the same area as the blob and same orientation), see Steve's blog:
Categories
Find more on Image Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



