Change color of numbers that show in ploT?
1 view (last 30 days)
Show older comments
So i have this code here that finds the centroids of blobs within my image and then shows the image with the borders outlined and with the blobs numbered. I was wondering if it is possible to change the color of those numbers from its default black to say white.
I think it has to do with something in this line:
text(matchCentroid(1) + labelShiftX, matchCentroid(2), num2str(k), 'FontSize', fontSize, 'FontWeight','Bold');
But here is the segment of the code I am working with.
matchMeasurements= regionprops(PI,'all');
M=length(matchMeasurements);
for k=1:M
matchCentroid = matchMeasurements(k).Centroid; % Get centroid.
matchOrientation = matchMeasurements(k).Orientation;
fprintf(1,'\n#%2d %8.1f %8.1f %8.1f %8.1f\n', k, matchCentroid, matchOrientation); %Displays the coordinates and bacteria number.
matchCentroid = matchMeasurements(k).Centroid; % Get centroid.
end
figure(7)
imshow(PI)
title('Bacteria Locations')
labelShiftX=-8;
fontSize=12;
for k = 1 : M % Loop through all blobs.
matchCentroid = matchMeasurements(k).Centroid; %Get centroid.
text(matchCentroid(1) + labelShiftX, matchCentroid(2), num2str(k), 'FontSize', fontSize, 'FontWeight','Bold');
end
hold on;
boundaries1 = bwboundaries(PI);
numberOfBoundaries1 = size(boundaries1);
for k = 1 : numberOfBoundaries1
thisBoundary1 = boundaries1{k};
plot(thisBoundary1(:,2), thisBoundary1(:,1), 'red', 'LineWidth', 2);
end
hold off;
0 Comments
Accepted Answer
per isakson
on 11 Jun 2012
The text object in axes has a property: Color
text( ....., 'FontSize', fontSize, 'FontWeight','Bold', 'Color', [1,0,0] );
More Answers (0)
See Also
Categories
Find more on Language Support 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!