Calculate R,G,B components from given a,b values of CIE L*a*b* color space
7 次查看(过去 30 天)
显示 更早的评论
I need to calculate a map, which I call RGB spectrum of some image. It is number of image pixels that appears for each of unique colors combinations.
It takes several hours to calculate such values for image of ~2k x 2k pixels, if I directly loop through unique RGB combinations, but if I convert RGB picture into L*a*b* format, such calculation takes a few minutes. Calculated result is a function of a* and b* vectors. I'm attaching result for peppers.png
How to calculate corresponding R, G, B components from these vectors? What value of L should I use? Is it important, do I need L or can exchange it by some constant?
Thanks a lot for help
3 个评论
DGM
2021-6-30
编辑:Image Analyst
2021-7-2
You're trying to basically map the frequency of color points in an image. If it's a color image, this will be a 3D map, regardless of the color space you use. If you're representing it as a 2D map, then you're somehow reducing the information being represented. In this case, you're converting to a different space and then discarding one of the components. That's why you can plot it in 2D. You only have two things to plot. You can do the same in RGB by ignoring one of the three.
If you want what amounts to a 3D histogram/heatmap, you'll first need to figure out how you want to visualize a volumetric image. Whenever I've ever wanted to view color point distributions, I just plot them as a cloud of points in 3D. It works for a quick visualization, but it's hard to spatially correlate some things. The IPT Color Thresholder app does similar point cloud previews when you import an image. You could also plot a volume by 2D slices. That makes it easier to see stray points, but it's hard to see larger patterns.
Valeriy
2021-7-1
编辑:Image Analyst
2021-7-2
DGM, thank you for your reply.
>You're trying to basically map the frequency of color points in an image.
In my understanding, frequency is number of something (pixels, waves' periods, colors), related to some unit of time, length, space, etc. For this case it seems to me that final result is more close to the spectrum. But this is question of definition.
>If you want what amounts to a 3D histogram/heatmap, you'll first need to figure out how you want to visualize a volumetric image.
You are right, but at first I need to obtain result. It could be RGB axes with volumetric data of amount of pixels, similar for Color Inspector 3D of ImageJ, BUT with colors, which related not to RGB color combination, but coded by amount of corresponding pixels into image.It could be set of 3D slices, stereoimage of final distribution, etc. Or any other kind of such data presentation.
Valeriy
2021-7-1
In the above ab Spectrum of peppers, I have found surprising results, which I didn't understand immediately.
The main color of the image is the color of the background, violet. It corresponds to the strong peak ab = (118,148). I have to squeeze the presented range of intensities to show weaker peppers' peaks. On the left side of it, there is peak ab = (98,159); I suppose that it corresponds to green peppers. Surprising is the bridge between these peaks. Here is a digital photo, and this bridge proves the discovery of Eugene Delacroix, French painter of the XIX century, impressionist predecessor, who saw so-called in painting "color reflexes". This is an effect when the color of one object is mixed with the colors of other neighbors' objects. He saw it and we can see them in his masterpieces. This bridge is clear evidence of the physical, optical background of his observation.
A similar bridge we can see between the same, main violet background peak and wide peak (170,190). I suppose (my question is still not answered) that it corresponds to red, orange peppers. It is not solid, it broke somewhere in the center. Its reason is unclear for the moment, perhaps it is related to weak camera dynamical range.
采纳的回答
Image Analyst
2021-7-1
编辑:Image Analyst
2021-7-1
In your comment above, you forgot to attach the bridge picture/painting.
Perhaps you want colorcloud() to build a 3-D color gamut of your image. Unfortunately it's just a visualization of the 3-D gamut/histogram and doesn't return the histogram.
Or you can easily compute the 3-D histogram of your image in a few seconds, even for a 2k by 2k image, with a simple nested for loop.
rgbImage = imread('peppers.png'); % Read in demo image.
rgbImage = imresize(rgbImage, [2048, 2048]); % Make 2k by 2k
hist3d = zeros(256, 256, 256); % Initialize counts
[rows, columns, numberOfColorChannels] = size(rgbImage)
startTime = tic;
% Create histogram.
for col = 1 : columns
for row = 1 : rows
r = rgbImage(row, col, 1) + 1; % Convert range from 0-255 to 1-256 because indexes can't be 0.
g = rgbImage(row, col, 2) + 1;
b = rgbImage(row, col, 3) + 1;
hist3D(r, g, b) = hist3d(r, g, b) + 1;
end
end
elapsedSeconds = toc(startTime);
fprintf('Done. Elapsed seconds = %.1f.\n', elapsedSeconds);
rows =
2048
columns =
2048
numberOfColorChannels =
3
Done. Elapsed seconds = 2.0.
Converting from RGB to CIELAB should take only a few seconds and you can then build a histogram of LAB values if you want. If it takes several hours, you're doing something wrong.
If you then sum the hist3d across the third dimension you will get the a vs b image you got in the image you attached. It's basically kind of like looking straight down the L axis.
My final suggestion is to build the color frequency IMAGE, which sounds perhaps like what you're describing. It is not a histogram but essentially makes a gray scale image where the brightness of the pixel is related to how much that pixel's color appears in the image. Here is a program that does that: https://www.mathworks.com/matlabcentral/fileexchange/28164-color-frequency-image?s_tid=srchtitle
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/670568/image.png)
In the image above, see how there are a lot of pixels with the sky color? So those pixels are bright. And the ocean also has a lot so it's almost as bright. The green and white have a lower area fraction of the image so those pixels are darker.
20 个评论
Valeriy
2021-7-1
Image Analyst, thank you very much for your creative contribution.
>In your comment above, you forgot to attach the bridge picture/painting.
I added to my initial question image in file <peppers + AB spectrum.png> with the results of my calculations. Is it visible? I repeat it in this comment. I used paperclips from menu to point image file. Did I something wrong?
>Perhaps you want colorcloud() to build a 3-D color gamut of your image.
Unfortunately, my Matlab version doesn't have it. I developed my way of visualization of such dependences, I'll adapt it for such a task.
>Or you can easily compute the 3-D histogram of your image in a few seconds, even for a 2k by 2k image, >with a simple nested for loop.
The excellent proposal, thank you. I went by another way: I found unique colors and scan along with them. Scan along with uniques RGB triades takes a very long time, but when I converted the image into Lab format, 2D scan along with a,b components takes a few minutes. Your proposal is definitely more efficient and quick.
>Converting from RGB to CIELAB should take only a few seconds and you can then build a histogram of LAB >values if you want.
As you can see from <peppers + AB spectrum.png> possibility of 3D (not 4D) representation of such results is very convenient.
This is the reason, why I continue to ask my question, and like to know expressions for the way of (a,b) -> (R,G,B) conversion.
>My final suggestion is to build the color frequency IMAGE, which sounds perhaps like what you're >describing.
Thank you, I know this function. Unfortunately, it don't solve my problem.
My question is related to the analysis of a luminescence image. The original task was the following: how many chemical, luminescent active different components it has? Only visual image analysis didn't answer this question. Are they two, three? I supposed that components of different chemical origins will produce localization of corresponding colors into separated groups in RGB or AB space. The Application of such calculation well fit this idea, now I see in my luminescent image definitely only two different components, I can prove this by corresponding spectrum, histogram.
Image Analyst, thanks a lot for your efficient solution.
Image Analyst
2021-7-1
When I asked about the bridge picture you mentioned, I was talking about the picture you mentioned here: "Here is a digital photo, and this bridge proves the discovery of Eugene Delacroix, French painter of the XIX century, impressionist predecessor, who saw so-called in painting "color reflexes". This is an effect when the color of one object is mixed with the colors of other neighbors' objects. He saw it and we can see them in his masterpieces. This bridge is clear evidence of the physical, optical background of his observation."
Where is "here"? Not so clear since we don't see the bridge photo, just a photo of peppers.
I suggest you look at pricipal components analysis. I attach a demo for getting the PCA of an RGB image. Each fluorescent material will probably belong to only one of the PCs.
You might also look at Eigenvector Research's PLS Toolbox, or MCR (multivariate curve resolution)
Do you know the theoretical curves of the glowing stuff, or is that an unknown too?
Valeriy
2021-7-2
>Where is "here"? Not so clear since we don't see the bridge photo, just a photo of peppers.
Good question. Do you see immediately before the body text of my initial question, near paper clip sign <peppers + AB spectrum.png>? Is it present? If I click on it I see two images, on top - Matlab's peppers, below - its calculated ab spectrum, which I have described.
Later I repeat it in the same way in my comment to your answer, below two images deal with Color Frequency Image, again near paper clip and <peppers + AB spectrum.png>.
I didn't find a way how to insert an image directly into the body text. I try to drag and drop the corresponding file, but the result is exactly the same, if I press the paper clip and point to an image file.
>Not so clear since we don't see the bridge photo, just a photo of peppers.
A bridge is not a photo, but it is part of ab spectrum, with some intensity link between the powerful blue-violet peak of background and peaks of green, red, yellow papers. I'm sorry about this interface issue, which doesn't show you what I mean.
How to insert an image directly into question or comments text? I didn't found how to do this.
>I suggest you look at pricipal components analysis. I attach a demo for getting the PCA of an RGB image. >Each fluorescent material will probably belong to only one of the PCs.
Very interesting idea, thank you very much. I'll definitely try to realize, to check your proposal.
>You might also look at Eigenvector Research's PLS Toolbox, or MCR (multivariate curve resolution)
Interesting, I will try to explore this direction.
>Do you know the theoretical curves of the glowing stuff, or is that an unknown too?
The challenge of this situation is that I know them, but they are very significantly overlapped, so spectral separation is very difficult and questionable. I plan to try to decompose spectra into a sum of Gaussians, using your function Fit Multiple Gaussians. There are small hopes that such kind of analysis can give some useful information.
Thanks a lot for your creative and kind help
Image Analyst
2021-7-2
You can insert a picture into the body of the post with the green and blue frame icon in the "Insert" section of the tool ribbon. Like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/671888/image.jpeg)
"The Old Bridge at Nantes" Drawing by Eugene Delacroix
With MCR you can decompose a signal into a combination of other component signals and you do not need to know the exact shape of the component signals - it figures it out. It figures out both the component spectra (curves) and the amount of each to use when combining (adding) them to form an arbitrary test signal.
Valeriy
2021-7-2
Eureka! I see it, thank you! In fact, I hate such kind interface issues, but sometimes they appear...
>"The Old Bridge at Nantes" Drawing by Eugene Delacroix
Excellent aquarelle, thank you. Do you like Delacroix?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/672363/image.jpeg)
Ok, about the ab spectrum, I intuitively add marks of colors, I hope my guess is correct. So, I'd like to know relationships for (a,b) to (r,g,b) conversion, if this question is correct. The source of my doubts is the following: how from two independent variables, a and b, calculate tree ones, r,g,b? Have it to be used one additional relationship? What? With L value?
"Bridge", color reflects are lines, linked mainly the main violet background peak with a green spot, in this case, it is very bright.
About yellow - background reflects, I understand why it is partly broken, this is not dynamical range effect as I was supposing in previous comment. Its intensity depends on the geometrical proximity of participating object on the picture space: one yellow pepper is directly contacted with background, so reflects are pronounced. Another one is placed in relatively big distance from the background, reflects are weak or absent.
>With MCR you can decompose a signal into a combination of other component signals and you do not need >to know the exact shape of the component signals - it figures it out. It figures out both the component >spectra (curves) and the amount of each to use when combining (adding) them to form an arbitrary test >signal.
Do you talk about the analysis of spectra?
Image Analyst
2021-7-2
I don't recall hearing of the painter before.
I'm not sure what you want to know about the peppers. There are many spectra in that picture, whereas in a fluorscopy image there are only one or two - the spectra of the fluorescent material.
Not sure how you computed LAB. Was it with the rgb2lab() function? Be aware that uses "book formulas" and will not be accurate but may be fine for relative comparisons. See attached tutorial if you want to do calibrated color analysis. This should answer your comment "So, I'd like to know relationships for (a,b) to (r,g,b) conversion, if this question is correct."
I think what you call "bridges" are just colors of pixels that are not the dominant colors and may be pixels on the boundary between two colors so they're kind of a blend of those colors.
Regarding "The source of my doubts is the following: how from two independent variables, a and b, calculate three ones, r,g,b? Have it to be used one additional relationship? What? With L value? " You cannot. A given (a,b) pair could give rise to an infinite number of (r,g,b) triplets. Unless you specify the L component, you can't get the RGB value. It could be anywhere from (0,0,0) to (255,255,255). Why do you (think) you want/need to do this anyway?
Valeriy
2021-7-2
>I don't recall hearing of the painter before.
He is very bright and colorful, see for example:
https://en.wikipedia.org/wiki/The_Lion_Hunt_(Delacroix)#/media/File:The_Lion_Hunt_(Eug%C3%A8ne_Delacroix)_-_Nationalmuseum_-_23399.tif
>I'm not sure what you want to know about the peppers. There are many spectra in that picture,
Peppers' image was the only colorful illustration for such an application.
>whereas in a fluorscopy image there are only one or two - the spectra of the fluorescent material.
Surprisingly I have found in fluorescence image the same bridge effect, where two peaks were linked like we see this in peppers' ab spectrum.
>Not sure how you computed LAB. Was it with the rgb2lab() function?
No, it was according example from Matlab help:
fRGB2Lab = makecform('srgb2lab');
imgLab = applycform(imgRGB,fRGB2Lab);
>I think what you call "bridges" are just colors of pixels that are not the dominant colors and may be pixels on the boundary between two colors so they're kind of a blend of those colors.
Exactly, this is a purely optical effect, when a colorful source of light, violet background in peppers' case illuminate neighbors, also colorful objects, so these colors are mixing.
>A given (a,b) pair could give rise to an infinite number of (r,g,b) triplets. Unless you specify the L component, you can't get the RGB value. It could be anywhere from (0,0,0) to (255,255,255).
Yes, this is what I was afraid of.
>Why do you (think) you want/need to do this anyway?
You see, even for simple pepper's ab spectrum, I need to guess who has what color?. For more complicated real analysis it would be more difficult and non-obvious.
On the other hand, I like ab spectrum due to its 3D nature and simple visualization. But I'd like to have complete color information for the case if I need RGB components.
I don't know, probably during LAB scan of the picture I should keep corresponding L values and recalculate RGB, using them.
Thanks a lot for the informative discussion
Image Analyst
2021-7-2
You didn't really describe the need and why the need exists. You just said that you need to. "I need to guess who has what color". Well the image itself tells you that. Every pixel has information about its color. In addition the 3-D color gamut histogram, whether in RGB color space or LAB color space also tells you about frequency of colors in the image - from zero (color does not appear) to fairly dominant. So, as I see it you have all the information you need for the next step - whatever that is. But again, I'm still not clear on what you want/need to do, why you want to do it, and why you think something is still lacking.
Valeriy
2021-7-3
>You didn't really describe the need and why the need exists.
OK, do you like the whole story, it is the following.
As Covid 19 result I lost my job and during 1.5 years continue to be in the same state. My former PhD student contacted one big pharmaceutical company, which needs to find a way how to measure small concentrations of API, Active Pharmaceutical Ingredient. He didn't find such a method and recommended me as a researcher who potentially can solve such a task. The company told me that if I'll find such a method, they will provide financial support and I will have at least a temporary job. I found that this is possible by the analysis of a luminescent image. The goal of such work is to determine unknown API concentration.
As you already know, this is possible to find a, b zones responsible for corresponding luminescence image. I prefer to make API separation into 3D ab space, not into 4D rgb one. It is difficult to imagine how to realize it correctly and conveniently inside it? Next step, I need to create a mask, corresponded to API location on a real image. This is the reason why I'm searching ab to rgb transfer. And the ratio of the mask size to total image size will give me concentration.
But this sad story is not finished, the company employee who initiates this project is laid off from the pharmaceutical company and pass it to somebody else, who seems not too interested in its further development.
Sorry for all of these details, but this is "why the need exists"
Image Analyst
2021-7-3
So how many APIs are present? Just one? Can't you just get a measure of how much of it is there in the image by summing it all up? Essentially taking the mean of the image. If you just look at the hue and saturation (chroma) by looking at a and b, and ignoring L then you're ignoring how much of the API there is in that pixel. Wouldn't a brighter pixel have more API at that location than a darker one, even if they are the same (a,b) value? So I don't think you can get a true measure of the quantity of API unless you consider all 3 color factors. Though you can certainly get a map of what pixels have a and b in a certain range just by using the Color Thresholder app in LAB color space. Just adjust the a and b thresholds and leave the L one alone (so it considers any and all L values). Then export the code, which will produce a binary image ("map") of what pixels had those a and b values, if that's what you want.
But there are probably dozens of ways of analyzing fluorscopy images and I don't know all, or even most, of them. I suggest you look over these articles on fluorescence analysis and see if any of them look applicable:
Valeriy
2021-7-5
>So how many APIs are present? Just one?
Yes, API is only one, but there are 5 other components with well overlapped spectra and unknown concentrations...
>But there are probably dozens of ways of analyzing fluoroscopy images and I don't know all, or even most, >of them. I suggest you look over these articles on fluorescence analysis and see if any of them look >applicable: >http://www.visionbib.com/bibliography/medical851f1.html#Fluorescence%20Analysis,%20Microscopic%20Analysis,%20Cells
Very interesting, thank you. I need to look it through
I have some additional idea, I'd like to check it. My idea is simple:
- into AB spectrum map (peppersLab) mark rectangular zone (aMin,bMin)...(aMax,bMax) that contains peak of interest.
- Using these values find ranges of indices in A, B maps and filter corresponding peppers zones
[yMax,xMax,~] = size(peppers);
imgFiltered = zeros(yMax,xMax);
[iY,iX] = find(((peppersLab(:,:,2)>=aMin) &(peppersLab(:,:,2)<=aMax)) &
... ((peppersLab(:,:,3)>=bMin) &(peppersLab(:,:,3)<=bMax)));
imgFiltered(iY,iX) = peppers(iY,iX);
It should work but seems I have an error(s) somewhere, filtered zone is set of rectangulars and don't correspond to the desired color.
Image Analyst
2021-7-5
Try
[rows, columns, numberOfColorChannels] = size(peppers);
imgFiltered = zeros(rows, columns);
peppersLab = rgb2lab(peppers);
[lImage, aImage, bImage] = imsplit(peppersLab);
mask = (aImage >= aMin) & (aImage <= aMax) & ...
(bImage >= bMin) & (bImage <= bMax);
imshow(mask);
% Not sure what you want to do after this.
% If you want to just mask the lab images and go back to RGB color space...
aImage(~mask) = 0;
bImage(~mask) = 0;
labImage = cat(3, lImage, aImage, bImage);
imgFiltered = lab2rgb(labImage);
Valeriy
2021-7-5
>If you just look at the hue and saturation (chroma) by looking at a and b, and ignoring L then you're ignoring >how much of the API there is in that pixel. Wouldn't a brighter pixel have more API at that location than a >darker one, even if they are the same (a,b) value?
If I understand you, you mean that API can be present into a single or less than one pixel, is it correct? Happily, I observe relatively big image zones, containing many pixels with different relative background colors; right now my task is to filter, separate them.
>So I don't think you can get a true measure of the quantity of API unless you consider all 3 color factors. >Though you can certainly get a map of what pixels have a and b in a certain range just by using the Color >Thresholder app in LAB color space.
I did some experiments with Color Thresholder. But I don't find direct correspondence between a*, b* spectra of Color Thresholder and ab spectrum from my post from July 2, 14:46, Their a, b ranges are very different. From the way, how I F*a*b* calculated above, I see the ranges: a = 105:201; b = 92:214; while from Color Thresholder they are: a ~= -40:50; b ~= -40:30. It is difficult to establish such correspondence.
>Just adjust the a and b thresholds and leave the L one alone (so it considers any and all L values). Then >export the code, which will produce a binary image ("map") of what pixels had those a and b values,
>if that's what you want.
This is an idea that I try to realize in my previous post, but something went wrong. Probably, L value has to be also filtered in some way.
Thank you very much for your help.
Image Analyst
2021-7-5
Have you tried to carve out a 3-D chunk of the gamut using discriminant analysis. See attached demo.
Valeriy
2021-7-6
Excellent, it works! Your
mask
with logic indexing became more efficient and correct than my
find
...
Thanks a lot, I appreciate your knowledge, experience, and willingness to help for users!
_________________________________________________________
>Have you tried to carve out a 3-D chunk of the gamut using discriminant analysis. See attached demo.
Now I try to assemble the final version of a color selecting function. This demo I will try as one of the next steps.
I'd like to ask your opinion, due to my situation, which I have described above, is it possible for me to find a Matlab post for answering users' questions or other kinds of Matlab-related activity? I love Matlab during many years, my first forum's questions about it are dated by 2009, but I worked with it even earlier. I have extended experience in Matlab application for optoelectronic setups, I have realized with it digital lock-in amplifier, based on computer sound card, computer-controlled PMT sensitivity switch. It gives a possibility to measure signals in the range of 7 orders of magnitude. As well I applied Matlab for simulation of different optical properties of nanostructured objects.
I can provide more detailed information, if necessary.
Image Analyst
2021-7-7
I'm not sure what you mean by "a Matlab post for answering users' questions", but this Answers forum you're in now is a place where users can post MATLAB related questions and you can add a post of your own to answer them. In fact we welcome you to. Sounds like you have hardware experience with MATLAB and that could be helpful to users who post questions on those kinds of topics. So please join us in helping others.
Valeriy
2021-7-11
Thank you for your answer.
>I'm not sure what you mean by "a Matlab post for answering users'
Observing the forum's life I see that very often different kinds of questions have been answered very quickly and mainly by some limited amount of forum's users. It looks like professional activity, so I supposed that they are Matlab's employees. It is difficult to imagine that such persons do nothing except answering forum questions. Their knowledge is high and extended, they are professionals in Matlab applications. These are the reasons why I was thinking that they are Matlab employee. So I was asking you if is this true? If such a team exists, is it possible to join it? How does it work?
Of course, I was answering different questions, which I can answer and I will continue to do this.
But returning to colors' game. I wrote a function that gives a possibility to calculate image mask, basing on 2D user-defined filtered zone on AB spectrum map. Borders of such zones are marked by white lines on the left spectrum images. Masked image zones became white.
You see attempts to select all red zones,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/681398/image.png)
all violet, background zones,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/681403/image.png)
and finally all zones, that are present in AB spectrum map.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/681408/image.png)
As you see it is not possible to select in such a way all, for example, red zones. AB spectrum didn't contain all red (or other colors).
It means that the idea about F part of F*a*b* format contains only the intensity component of the image is wrong. Unfortunately, verification of this statement shows that it is correct. The number of unique colors in the initial RGB peppers image is 99059, while the same parameter for AB image is only 6626 colors, practically 15 times less than RGB image.
So, the conclusion from this attempt is that the F component contains the main part of color information. To perform color filtering of RGB image either it has to be analyzed directly by R, G, B components, either its TREE F, A, and B components.
Image Analyst
2021-7-11
Color science is a confusing topic, more so than traditional gray scale image processing. I know, because I've done both for literally decades. I can see that you're confusing/conflating different topics. First of all, the 3-D color gamut, like you can get from colorcloud(), is a scatter plot of all colors in the image. "Red" is not really a single color, but more of a range of colors, and the limits of that range are not carved in stone. For example, you could say that anything with a positive CIE a value is redder than anything with a negative a value. However there are colors with a positive a that you probably wouldn't call "red". See attached demo. What areas would you call "red"?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/681443/image.png)
Maybe the upper right where both a and b are high?
However your plot of b vs. a doesn't have to do with that. As I understood it, you're taking the gamut cluster and looking down the L (not F) axis and either taking the first L value you see or the max L value you see, or the mean L value, or maybe the pixel count. (Not sure without reviewing everything we've discussed so far). But no matter which, that is a gray scale image since it's a 2-D image with single values at each location.
Then it looks like you applied a colormap to that 2-D image which turns a value into a color. This color has absolutely nothing to do with the CIE a and b colors and is only a mapping of your processed L value(s) via an arbitrary colormap. So your "red" values in your b vs a image have nothing whatsoever to do with where pixels with those a and b values are actually red. It only has to do with the L values of pixels with those a and b values. In other words, the "red" in your display has to do with the (mean/first/count) of L values, not the actual intrinsic color of anything in the image. If you were to somehow lassoo "red" pixels in that image you'd get pixels with a and b in the range (which might be blue or green or yellow or anything in the original scene) that had high (mean/first/max/count) L values. I know it's confusing do you may have to read this paragraph several times. If that's confusing, try applying a gray scale colormap to the image and that might help you understand.
Now as far as understanding why the number of pixels is different, in a 3-D scatterplot you'll have 256x256x256 colors. Now when you map that into CIELAB colorspace, you could have any number of "voxels" depending on how you discretized the space. So if you had 100 L values, and 70 a values and 70 b values, you'd have 100x70x70 possible digitized CIELAB colors that you could display. Now if you were to somehow do a projection down the L axis and take the min, max, mean, first L value, or count of the non-zero L values, then you'd have an image of 70x70 dimensions, with a value that depends on however you processed the L values in the column above the plane.
So the statement "that the idea about F part of F*a*b* format contains only the intensity component of the image is wrong." and the reasoning behind it based on number of pixels is not correct. Likewise, the two ssentences in this paragraph are not right: "So, the conclusion from this attempt is that the F component contains the main part of color information. To perform color filtering of RGB image either it has to be analyzed directly by R, G, B components, either its TREE F, A, and B components."
If you still don't understand then attach your code where you start with the peppers image, convert it to CIELAB color space, and end up with your b vs a image and I'll try to explain what each step is really doing, hopefully in a way that someone with 40+ years of color science behind him doesn't confuse beginners.
Valeriy
2021-8-6
Hello @Image Analyst, sorry for the delay in replying to you. Jobless activity is hard and timeconsuming job.
>See attached demo. What areas would you call "red"?
Thank you for the interesting demo.
>Color science is a confusing topic,
Yes, sure, I see, but let's see if I need it for such a task?
After some thinking, what I have, when I analyze camera recorded luminescence image. Original luminescence light from each pixels' location has some complicated spectrum S(λ), where λ is light's wavelength. The camera has three kinds of sensors with its own spectral sensitivity: R(λ), G(λ), B(λ). For each pixel we have (Ro, Go, Bo), the sum of products:
Ro = sum(S.*R); Go = sum(S.*G); Bo = sum(S.*B);
They are pure physical, optical values, only for user convenience, they are translated by a monitor to color presentation. They are not colors, they are only colorized optical quantities. It definitely means that the observed camera image is 4D, so any attempt to squeeze, reduce its dimensionality to the 3D structure is wrong. It means as well that I must to work with img = (Ro(:,:),Go(:,:),Bo(:,:)) matrice.
Next, what I need is to calculate 4D rgb histogram of img, H(r,g,b) and to find a way how to observe and separate its clusters.
I'm not sure that it will be convenient to apply stereo H presentation and introduce user-defined segment(s) into it. So I'm thinking about 3 projections of H on the RG, GB, BR planes, like I illustrate in the attached image.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/704837/image.png)
By the way, how is possible to plot such an image, if I have corresponding RG, GB, BR projections? This image I did in graphics editor.
Another question, Image Segmentation Using the Color Thesholder App is very convenient tool, does exist something similar for RGB image format?
Thank you a lot for your help
Image Analyst
2021-8-6
编辑:Image Analyst
2021-8-6
It is true that the emitted spectrum from your scene is continuous (a function of lambda, the wavelength). And it's true that the camera has filters over the pixels that have a continous spectral transmissivity. And you do integrate the product of spectral emittance of these scene times spectral tramnsmissitivy of the camera to get the single color value, like your Ro, Go, or Bo. And you do end up with a 3-channel image. But it's a 3-dimensional image. Even if you had not summed over wavelength and stayed with, say 32 different images (one image for each 10 nm band), you'd still ahve a 3-D image. It would be hyper spectral with 32 color channels instead of only 3 but both cases are 3-D. The hyper spectral image is not 4-D or 32-D. It's 3-D -- rows-by-columns-by-32 wavelength bands. The histogram is a 3-D histogram (not 4-D) for an RGB image, and for a 32 channel hyperspectral image, it would be a 32-D histogram.
If you have the known theoretical spectral emittance of the fluorescent material, and you know the spectral transmissitivities of the RGB filters on the camera, and you have the RGB values, you can get the "loadings" of the signal for each wavelength using multivariate curve resolution. This gives you the emittance of your signal at each wavelength.
The Color Thresholder can be used with any 3-D color space, like CIELAB, HSV, or RGB, so I don't understand that question.
更多回答(1 个)
Dmitry Kaplan
2021-7-1
编辑:Dmitry Kaplan
2021-7-1
... This is probably not an answer, but a suggestion -- I simply don't have enough info. If your rgb valus are limited to 1-byte values (i.e. each of the components color components is between 0 and 255), then I would consider creating a 256^3 x 1 sparse matrix and use accumarray to sum up histogram counts. Something like this:
rgb = double(imread('peppers.png'));
rgb_index = rgb(:,:,1)*256*256+rgb(:,:,2)*256+rgb(:,:,3); %create index of color histogram red*256*256+green*256*blue
res = accumarray(rgb_index(:)+1,1,[256^3,1],[],[],true); %don't forget to subtract 1 when converting indeces back to rbg if needed
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)