colormap for a matrix with 4 columns

조회 수: 8 (최근 30일)
Kiran Vaddi
Kiran Vaddi 2018년 10월 26일
댓글: Walter Roberson 2018년 10월 27일
Hi, I have a 3D plot with around 200 points and each has an associated vector (C1,C2,C3,C4) so matrix C = 200x4. I am looking to get a colormap to assign a unique color to each point in a plot based on their four Ci values (i.e. to get a color as mix of 4 colors such as CMYK). Any help would be appreciated
Thanks in advance

답변 (2개)

Walter Roberson
Walter Roberson 2018년 10월 27일
The *.icc file can be obtained at the link above.
I_cmyk = reshape(mat2gray(C),size(C,1), 1, 4);
inprof = iccread('USSheetfedCoated.icc');
outprof = iccread('sRGB.icm');
C = makecform('icc',inprof,outprof);
I_rgb = applycform(I_cmyk,C);
rgbmap = reshape(I_rgb, [], 3);
pointsize = 20; %adjust as desired
scatter3( X(:), Y(:), Z(:), pointsize, rgbmap );
  댓글 수: 5
Image Analyst
Image Analyst 2018년 10월 27일
I think the way I gave in my answer should work. Basically you have to normalize your C measurements, then take the mean of them all.
Walter Roberson
Walter Roberson 2018년 10월 27일
According to references I find, "dark cyan" is CMYK 100, 0, 0, 45. This is distinctly different than CMYK 100, 0, 0, 0, so if you want C1 to correspond to dark cyan then it is not possible to calculate it based upon relative portions 1.0, 0.0, 0.0, 0.0 in any permutation.
Using data cursor to read off the colors at the vertices of your diagram as best I can, and using the conversion at https://www.rapidtables.com/convert/color/rgb-to-cmyk.html (and note that max for RGB is 255 but max for CMYK is 100)
C1 - RGB [41 38 39] CMYK - [0 7 5 84]
C2 - RGB [246 233 74] CMYK - [0 5 70 4]
C3 - RGB [0 180 236] CMYK - [100 24 0 7]
C4 - RGB [234 15 137] CMYK - [0 94 41 8]
The only one of those that maps at all well to CMYK is C3, potentially pure cyan, but C3 has 1/4 magenta in the mix.
The CMYK that I get out of the conversion from the Mathworks Support link appear to be rather different than the values from the online calculator. It is possible that the conversion profile is quite different, but the differences are fairly large, so I am not convinced the conversion is accurate for the one provided by Mathworks Support.
Anyhow, your tetrahedron does not match CMYK.
I do not think that humans could be expected to mentally interpolate between four different values (C1, C2, C3, C4) based upon three pieces of information (R, G, B). Humans are not all that good at identifying mid colors, especially not in small swathes.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2018년 10월 27일
Can you attach C in a .mat file, and include a screenshow of your 3-D plot?
What are the 3 axes in the 3-D plot? C1, C2, and C3? What to the 4 C's represent? X, Y, Z, and something? What exactly is a "point"? A plot in 4-D space, or a point in 3D space where C4 is some kind of intensity value at the x,y,z coordinate? If you have 200 points and want a colormap with 200 unique colors, why can't you just do
cmap = hsv(200); % Make 200 unique colors.
  댓글 수: 4
Walter Roberson
Walter Roberson 2018년 10월 27일
? plot3 does not take a 4th numeric input, and does not permit an array of color inputs ?
Image Analyst
Image Analyst 2018년 10월 27일
I guess you'd have to use scatter3() then, which can take a color for every point.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Orange에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by