How do I change the colors of circles that I draw using the viscircles function?
Show older comments
I'm trying to draw circles in an image whereby if the circles' radii are outside a particular threshold, they get colored in with a different color. However, I keep getting an error when I write in the following line of code.
viscircles(centers, radii, 'Color', 'g')
The error is as follows:
Error using viscircles>parseInputs (line 175)
Unknown input string: Color.
How would one get around this issue?
Thank you for your help.
P.S. I'm currently using Matlab R2015a.
Answers (1)
Walter Roberson
on 29 Jun 2017
0 votes
In R2015a it was EdgeColor rather than Color; http://www.mathworks.com/help/releases/R2015a/images/ref/viscircles.html?searchHighlight=viscircles#namevaluepairarguments
Note for readers: viscircles only permits one color to be set for all of the circles it draws in one call. At the underlying level, it use a line object for all of the circles themselves, and a second thicker line object for the edges of the circles, counting on the thinner object to only overlay part of the thicker object to create edging on both sides. The point here being that line objects are restricted to a single color each, so it is not possible to use different colors for different circles created in a single viscircles() call.
4 Comments
Neda
on 8 Nov 2017
How about if we draw a circle by using rectangle 'Curvature',[1 1], and we need to shade all the rectangle with different colour based on their value, for example min value should be blue, and max value should be red, and those values between min and max how can colour?
Walter Roberson
on 9 Nov 2017
You should probably reconsider using rectangle() for that. It would make more sense to use a patch(), probably providing vertex color data and asking for face color interpolation.
Becky CNS
on 28 Feb 2018
Then how DO you change the colour following the viscircles function?
Walter Roberson
on 1 Mar 2018
h = viscircles([0 0;1 1; 2 2],[5 8 10]);
h.Children(1).Color = 'w'; %change the color of the thinner inside line
h.Children(2).Color = 'k'; %change the color of the edging
Categories
Find more on Images 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!