Creating a circle with segments of colour

10 次查看(过去 30 天)
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.

采纳的回答

David Young
David Young 2014-9-30
编辑:Image Analyst 2014-10-1
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 个评论
Jens
Jens 2014-10-1
Oh, yes, this is what I was looking for. I should be able to work from this. Thank you very much.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by