Creating a circle with segments of colour

11 views (last 30 days)
I am trying to create an image of a circle, with segments of colour. The way I think to do it to either create two circles, one smaller than the other, and fill the gap in between with colour (seems unnecessary, since if I create a circle of colour anyway). Easier might be to create a circle made up of different colours, and fill the rest in with black.
It seems to be easiest using RGB colours, and creating segments each with a specific colour in them, then just specify the colour and width of the segments to create coarser/finer rainbow structure, for example.
Any ideas to create a circle made up of segments, which are adjustable both in number, and colour, in an easy way?
EDIT: http://i.imgur.com/12K40ha.png an example of what I mean.

Accepted Answer

David Young
David Young on 30 Sep 2014
Edited: Image Analyst on 1 Oct 2014
Not sure what you mean by "adjustable in colour". The code below does the full colour wheel - it should give you a starting point anyway.
% Set parameters (these could be arguments to a function)
rInner = 80; % inner radius of the colour ring
rOuter = 200; % outer radius of the colour ring
ncols = 12; % number of colour segments
% Get polar coordinates of each point in the domain
[x, y] = meshgrid(-rOuter:rOuter);
[theta, rho] = cart2pol(x, y);
% Set up colour wheel in hsv space
hue = (theta + pi) / (2 * pi); % hue into range (0, 1]
hue = ceil(hue * ncols) / ncols; % quantise hue
saturation = ones(size(hue)); % full saturation
brightness = double(rho >= rInner & rho <= rOuter); % black outside ring
% Convert to rgb space for display
rgb = hsv2rgb(cat(3, hue, saturation, brightness));
% Check result
imshow(rgb);
  1 Comment
Jens
Jens on 1 Oct 2014
Oh, yes, this is what I was looking for. I should be able to work from this. Thank you very much.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!