imread -> colorcloud() : points are too small?

I'm new to Matlab and struggling with imread() and scatter3() which offers options for 'marker size'.
But there are 'complications'... My goal is to load an RGB image (using imread) and then plot the image colors in 3D using the original RGB pixels values.
So far, I got this code working which produces a 'monochromatic' (blue) 3D plot :
RGB = imread("Bonnet.jpg")
[R,G,B] = imsplit(RGB);
scatter3(R(:), G(:), B(:))
I tried experimenting with 'scatter3(X,Y,Z,S,C) draws each circle with the color specified by C' where C is a three column matrix with the number of rows in C equal to the length of X, Y, and Z, then each row of C specifies an RGB color value for the corresponding circle...
Trouble is I can't find how to convert the RGB 'array' into a 3x3 matrix to supply as c argument?
That is why I was interested in colorcloud() since it automatically colors each points BUT there are no options to increase the points size... So back to square one...
----
Once I get past this 'hurdle', my next goal is to allow 'picking' points (filled circles or squares) with the mouse so that I can tell what the RGB coordinate of a mouseover or mouse click is.
Then, for the cherry on the icing, I'd like to create a wireframe from a separate 3D dataset (extracted from Output ICC profile) to allow viewing which colors are out-of-gamut.
Tall order!
Any help is appreciated / Roger

Réponses (2)

Walter Roberson
Walter Roberson le 14 Déc 2021
Modifié(e) : Walter Roberson le 14 Déc 2021
filename = "yellowlily.jpg";
RGB = imread(filename);
[R,G,B] = imsplit(RGB);
pointsize = 25;
scatter3(R(:), G(:), B(:), pointsize, rescale([R(:), G(:), B(:)])); axis equal

7 commentaires

Roger Breton
Roger Breton le 14 Déc 2021
Modifié(e) : Roger Breton le 14 Déc 2021
I get it. Any idea how I'd need to approach this if I want to use CIE Lab coordinates? I tried converting an RGB image in Photoshop to CIE Lab for which imread had no problem opening. But the image still displays with "RGB" (0 to 255) axis? I remember reading something about support for CIE Lab somewhere... I could always convert the RGB coordinates to Lab in Matlab (never done it) but it would give me a Lab matrix and I'd still have, I guess to ultimately convert to RGB? Because scatter3 can only graph RGB values? I'll have to research this....
Roger Breton
Roger Breton le 14 Déc 2021
I found this link. Got the script file and it works.
This is pretty close to what I want to do.
I will study the code? As I don't see a way to load up an image... Which is not the end of the world, since I have a small utility (BabelColor PatchTool) which can extract the RGB or Lab coordinates out of a TIFF file and save them as a Text file, a file I guess I could then import into 'plot Lab'. BTW, it is interesting that the people who developped this script are associated with UGRA, I guess I did not know they had an office in Spain -- color is a small world)...
Image Analyst
Image Analyst le 14 Déc 2021
Roger, just be aware that those (I believe) are just "book formula" conversions. They are not calibrated CIELAB values like you'd get from a spectrophotometer (the gold standard for color measurement). They're relative. I can't give my whole course on color science here, but, yes, you do have a lot of reading and studying to do. If you want calibrated values you need to put in a calibration standard and image that then develope a transform from the RGB values to the CIELAB values. Then it will be true and accurate, not arbitrary/relative book formulas.
Roger Breton
Roger Breton le 14 Déc 2021
Dear Image Analyst, if the "book formula" give the same result as in, say, a proper ICC application, like Photoshop, then that's just good enough for my needs. All I want to achieve with this "demonstration" is for my students to better understand the physical of out-of-gamut colors. BTW, I have plenty of "nice" instruments in my "lab", PR705, i1Pros, ChromaMeter CS-200, X-Rite 508, Techkon Spectrodens and more... (I used to work as color manager for Transcontinental Printing in Canada for many years, and I also consuted 'professionally' -- the world of color measurements and reproduction is my daily "bread"). Having said that, I should take the time to compare the equations behind these "book formula" and those I see in a number of colorimetry text books. Thank you so much for your invaluable help! I'm not out of the woods yet.
BTW, I still maintain an old color management site at www.graxx.ca.
Roger Breton
Roger Breton le 14 Déc 2021
I started experimenting with plot lab. (Maybe I should continue in the author's Home page for help?)
In case you're interested... This is the graph I get, so far :
This is the script I used to call the function:
Lab = [80 -4 90; 56 -37 -50; 48 72 -6]
RGBtriplet = [227,227,227]
plot_Lab(4, Lab, 1, RGBtriplet, 60,'fill')
The result is "encouraging" but I know there is an error somewhere, since the XYZ value do not correspond with my original Lab values. I'm not sure whether I need to create a 3x3 array or a 3x3 matrix (as I did)... I'll investigate further...
Roger Breton
Roger Breton le 14 Déc 2021
One thing that strikes me now is that some of the XYZ displayed triplets are negative? CIE XYZ are never negative. ...
Roger Breton
Roger Breton le 15 Déc 2021
I found (with the help of the script author) my mistake.
The Lab coordinates need to be entered in "Columns" triplets, like so :
Lab =
50 80 20 15 40
12 -6 -4 -20 48
38 78 -40 38 -60
This is the resultant plot :

Connectez-vous pour commenter.

Image Analyst
Image Analyst le 14 Déc 2021
"my next goal is to allow 'picking' points (filled circles or squares) with the mouse so that I can tell what the RGB coordinate of a mouseover or mouse click is."
So after you call imshow(), just call impixelinfo to do that. It will show you the (x,y) and RGB of the pixel your mouse is over
imshow(rgbImage);
impixelinfo;
It works for a displayed color or gray scale image, not for the colorcloud or scatter3 plots.

1 commentaire

Roger Breton
Roger Breton le 14 Déc 2021
Modifié(e) : Roger Breton le 14 Déc 2021
Using Walter script, above, I got the "mouseover" behavior I was thinking about. Maybe the displayed number can be enlarged? But what I'm really after is CIE Lab numbers (have to do a conversion somewhere or find a way to import a CIE Lab number file version)? The displayed coordinates (X,Y,Z) are still in RGB form... Boy! I'm going to be busy 'reading up' ....

Connectez-vous pour commenter.

Catégories

En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange

Produits

Version

R2021b

Commenté :

le 15 Déc 2021

Community Treasure Hunt

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

Start Hunting!

Translated by