How to make a set of RGB color combinations
4 ビュー (過去 30 日間)
古いコメントを表示
I want to build a finite set of RGB colors, say 100, which maximices the overall differences (Euclidean distance) between each of them. Any suggestions?
0 件のコメント
採用された回答
Thorsten
2013 年 2 月 5 日
This is what you get if you tile the RGB cube uniformly
N = 100;
n = ceil(N^(1/3)); % 3D color volume
x = linspace(1, 255, n)';
Nr = n^3;
x3 = repmat(x, [Nr/n 1]);
x2 = repmat(x', [5 1]);
x2 = repmat(x2(:), [Nr/numel(x2) 1]);
x1 = repmat(x', [5^2 1]);
x1 = repmat(x1(:), [Nr/numel(x1) 1]);
rgb = [x1 x2 x3];
rgb = rgb(1:N, :); % select first N
% rearrange colors as image to show
n2 = sqrt(N);
if round(n2) == n2
I = reshape(cat(3, cat(3, rgb(:, 1), rgb(:, 2), rgb(:, 3))), [n2 n2 3]);
end
imshow(I/255)
2 件のコメント
Jan
2013 年 2 月 6 日
Cubes are not the structure with the maximum distance. Actually you need a close packing of spheres. But the fix number of elements makes the problem really hard. I've voted for this question, because it is one of the hardest problems in the forum at all.
その他の回答 (2 件)
Image Analyst
2013 年 2 月 5 日
I think that is not such an easy thing to do. Think of a 3D space, in the shape of a Munsell solid if you want to Google that. Would the set of points that has the max average distance between all the points be all on the outer surface? Or uniformly distributed throughout the volume? Or some other distribution? I have no idea, though I bet Roger Stafford does if we're lucky enough to get him to respond here.
I think it might be better to ask what you need this for and find something that works for you. For example, is the "lines" colormap good to use for your situation?
0 件のコメント
Mario Trevino
2013 年 2 月 5 日
2 件のコメント
Jan
2013 年 2 月 6 日
The more different does not mean that the distance in the 3D space of RGB values is maximal. "Different" involves the perception by a human and our eyes do not work in RGB space. See FEX: maximal perceptual distinct colors for a solution.
Image Analyst
2013 年 2 月 7 日
Mario, that doesn't make any sense. If you make multiple masks, then you have multiple masks - they are binary (true/false) and the color is of no consequence at all. It doesn't matter if the masks are all on one image or one blob per image and multiple images. Anyway, if you wanted to have multiple colors on a binary image with multiple blobs in the image, you'd just label the image with bwlabel() and then call label2rgb() to turn separate blobs into different colors. You wouldn't do what you asked to do. So I say that your question was wrong, and it you use Thorsten's answer you'll be on a wild goose chase, even though his question may have answered your question. If you want to explain further, go ahead, and we can get this figured out. I've dealt with image processing every day for over 30 years so I have a pretty good understanding of this stuff.
参考
カテゴリ
Help Center および File Exchange で Colormaps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!