What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

color elements


Ninanoki

Well-Known Member
Messages
89
Likes
0
is photoshop able to measure color separate parameters like value, chroma and hue? like on the image below:
c.png
 
is photoshop able to measure color separate parameters like value, chroma and hue? like on the image below:

Photoshop can directly display the values of Lab color space or officially known as CIELAB. Conversion to CIELCH or CIELUV is just a mathematically conversion from CIELAB so certainly could be done yet might take a script to do so.

However, simple answers to relatively straightforward questions does not solve what looks like a pretty major software development program if you are trying to duplicate the capabilities of an already existing product. Photoshop is a very powerful program yet that does not equate to Photoshop being a good software base from which to build a product. Just my opinion of course.
 
let's say i will pick a color at the tooth neck with some tolerance ex:51x51 and paste values (RGB or L,a,b) into excel. i could put there rgb or Lab values for all tooth shades. how to check which color is closest? should i compare sum of R+G+B? i'd like to tell how many % should i take of color A1 and how many % of color A2 for example to have this picked color.
 
Personally I would stick with Lab since the color numbers represent a color whereas RGB numbers have to be paired to a specific RGB color space to know the color.
Also, this is only a good as the image colors representing the actual colors since getting a good calibration/match is an issue.

You also have to decide if you are looking just for a color/chroma etc match or if you want to include luminosity as well.

If you want to compare all three L,A,B components then here is the formula I would used to get the RMS distance of an image sample compared to a single palette sample

Li = L of the image sample
Ai = A component of the image sample
B = B component of the image sample

Lp = L component of palette
Ap = A component of palette
Bp = B component of palette

Distance = Square Root of ((Li-Lp)^2 + (Ai-Ap)^2 + (Bi-Bp)^2)

Do the above calculation for all palette values against the single image sample value and take the minimum of all calculations to have your closest match.

The calculation should be the same as ∆E by the way.

If you want to leave out the L part of the matching test, just leave out the L portion of the equation.

Hope that helps.
 
...However, simple answers to relatively straightforward questions does not solve what looks like a pretty major software development program if you are trying to duplicate the capabilities of an already existing product. Photoshop is a very powerful program yet that does not equate to Photoshop being a good software base from which to build a product. Just my opinion of course.
John is *EXACTLY* right, and this is why, a month or so ago, I questioned your overall goal as well as the approach you have chosen. If you were still in school, I could understand why you might be doing such a project (eg, for a class or a thesis), but you replied that you have been in practice for 8 years. You should have more than enough revenue from your practice to purchase any of the clinically validated and widely accepted commercial software and write it off as a business expense instead of attempting to do it yourself.

If, for some reason unknown to us (eg, you don't like any of the commercial packages and think you can do better than the commercial software), then, because this is obviously a significant software development effort and you are clearly not an expert in the area of software development, you should hire some people who do have expertise in this, eg, a SW architect / manager, as well as people with expertise in mathematical algorithms, lighting and image capture, programmers/coders, etc., instead of pressing people for hours and hours of free consulting from on-line forums such as this. Some of these positions could be filled by part-timers and consultants at very reasonable rates.

Finally, let me be more direct than John: Photoshop IS clearly the wrong way to develop such software. At best, even using all the actions you have already developed and possibly some new scripts, the native programming capabilities of PS are much too limited and the end result will be too fragile, not capable of displaying the desired info without a huge amount of intricate (and easily broken) code, etc. At the very minimum, you should be looking into platforms such as ImageJ, or even more preferably, development platforms such as the Image Processing Toolbox for Matlab from Mathworks. This latter (or similar add-on "packages" for Mathematica) could then serve as a prototype for real software which would likely be written in an even lower level programming language such as Java, C++, etc.

Sincerely,

Tom M

PS - In some of our earliest communications, I described to you the benefits of a color space other than RGB, and suggested Lab, HSL/HSV, or any of several other possibilities that would allow one to substantially ease the lighting requirements, particularly with respect to shadowing, glints, and other unwanted variations in brightness.
 
thanks guys, this software is quite expensive but the most important thing is that not every technician has such equipment and i want to work with some who doesn't and i need to tell him the colors i need.

Tom - i know that i can switch RGB info panel to Lab values, but is that better in anyway?

please take a look a this excel where i want to put rgb or lab values.do You think that i should sum the values of R,G and B and find the difference between all the shades? tooth rgb-A1 rgb, tooth rgb-A2 rgb etc? and find which absolute value is the closest?
https://docs.google.com/spreadsheets/d/16wojqGM-A71PAVmZU6rd7RSlyhkJbR1VRp12GgvevSQ/edit?usp=sharing
 
thebestcpu - ;) could you help with the excel question? is my way to sum rgb or lab values and compare them correct? i asked Tom because he mentioned LAB colors. and i can see how to display lab colors, what about Value, Chroma and Hue?
 
Last edited:
Hi Ninanoki

I also suggested Lab color so will respond on that as well.

Lab allows you to separate out Luminosity from the "a" and "b" color components RGB does not.
Doing math with just RGB gives way too much weight to the blue component as for the same color number, blue actually has about 1/6 the luminosity impact as green and about 1/3 as much as red. So not weighted correctly on how our eyes perceive color
Also, with RGB you run the risk of having a palette in one color space and an image data in another color space if you are not careful. That can't happen in Lab.
The Lab color space numbers are based on a scale that more or less evenly represents how our eyes perceive differences in a color. RGB is not.

I think you will have fewer problems and better matches using Lab and not RGB. There are possible workarounds yet why mess with that.

As far as Excel. to know the difference in colors you want to know the distance between two points in 3D space. That is using the approach from my prior post where you take the RMS value of the differences between the two color numbers in each channel. Best to do in Lab yet could be done in RGB (blue in the RGB channel can throw off the accuracy of visual differences so still suggest Lab)

Adding the numers in Excel does not make sense. You could actually have two totally different colors add up to the same number and that is not the result you want.

Hope the info helps.

ADDED EDIT: Here is a link to convert from Lab to Lch
http://www.brucelindbloom.com/index.html?Equations.html
 
Last edited:
1)i understand the need to use the Lab colors, thanks. so i need to find the shortest distance on the chart between my tooth sample and shades (a1,a2,a3,etc...).but should i use 3-D (include Luminosity) or 2-D with only a,b coordinates?

2)here is my current excel after recent update with 3-d coordinates that finds the closest color (delta E). am i doing it right now? this is the formula i'm using to measure the distance: https://www.easycalculation.com/analytical/learn-distance3.php

http://www.dentopolis.org/temp/ShadeMatch.xlsx

3)does it matter if photoshop can't divide colors into Value, Hue and Chroma as numbers?

4)this is my real life case.i made a selection for tooth parts, filter-average, color picker and pasted Lab values into excel. but it tells me that all those parts are A4 shade! it should display some dark color at the tooth neck and light color at the edge. strange. Lab values are very close to each other (very small range).
que.jpg
 
Last edited:
1)i understand the need to use the Lab colors, thanks. so i need to find the shortest distance on the chart between my tooth sample and shades (a1,a2,a3,etc...).but should i use 3-D (include Luminosity) or 2-D with only a,b coordinates?

2)here is my current excel after recent update with 3-d coordinates that finds the closest color (delta E). am i doing it right now? this is the formula i'm using to measure the distance: https://www.easycalculation.com/analytical/learn-distance3.php

http://www.dentopolis.org/temp/ShadeMatch.xlsx

3)does it matter if photoshop can't divide colors into Value, Hue and Chroma as numbers?

4)this is my real life case.i made a selection for tooth parts, filter-average, color picker and pasted Lab values into excel. but it tells me that all those parts are A4 shade! it should display some dark color at the tooth neck and light color at the edge. strange. Lab values are very close to each other (very small range).

First, the numbers in your spreadsheet do not match the numbers of the color sampler points in the image you provided. So that was a little confusing.

Responses:
1) I personally would measure both the 3D Lab and the 2D ab and the 1D L distances so you can see the information separated. You have embarked on a project where the differences in the luminosity and hues are closer to suble differences rather than clearly distinct. In such a case, the results will be very sensitive to the lighting and color accuracy of the original image relative to an absolute standard. That is not easy to do. You have already seen the issue of the specular highlights in you imges and I suspect matching up luminosities to a common standard is not easy as well.

Since the sample teeth are somewhat separated by Luminosity and Color, using the 2D and 1D distances might help.

In some respects, if when the shot of the tooth is taken, you had a reference tooth side by side with it, you might have some good info on how to adjust the image for the right color balance and luminosity. Just a thought.

2) The spreadsheet looks right to me other than the numbers don't match you picture example. The link to the formula is correct. To go to 2D you just eliminate one of the dimensions in the equation and for 1D just use one subtraction (no need to square and square root at that point)

3) Value, Hue and Chroma numbers can be calculated outside of Photoshop in Excel so not a must to have in Photoshop in my opinion

4) Since the spreadsheet you linked do not have the correct numbers from the image it is hard to comment. This gets back to having known and uniform lighting and color balance with relatively dry teeth I suspect so it would not be hard to off just due to those factors. Again, taking a picture with a reference tooth may be an idea.

If the number differences seem small, you can always sample with 16 bit values instead of 8 bit values and use the 16 bits numbers in the spreadsheet. I don't think it will change you answer in the spreadsheet you supplied to me though. It might make a difference differentiate between two close values in the table though. Having more digits in the number you use in Excel only helps if the color accuracy is spot on (key issue).

Note that you mention dark color. It is best to think of light and dark as Luminosity and brightness e.g. L channel and the color as the ab channels. In the image you provide, all three samples look very similar. That is not an issue of your sampling or calculations, that is just is what is in your picture. So if there is an issue, I suspect it is in how the image was shot/processed.

I suggest you try a number of samples before you conclude you have a problem.

----------------------

Hope the above information is helpful.
 
Hi Tom
Since Ninanoki asked you specifically on this question, I will leave this one to you.
John Wheeler
Thanks for the courtesy, John, but, I'm going to bow out of this discussion.

The reason is that several weeks ago, the detail level of the questions and the amount of my time required to generally guide him and answer his questions in the level of detail that he wants told me that I crossed the line from teaching (which is what we do enthusiastically on this forum) to doing free consulting for someone whose practice will likely profit from that consulting. In addition, I don't believe his basic approach (ie, PS vs a real programming language) is correct, nor, as you just pointed out, the lack of emphasis given to the image lighting and capture issues, not just the image analysis aspects (which I pointed out to him quite some time ago).

Best regards,

Tom M
 
Tom, many times i said i am grateful for your help and ps action i did with your cooperation works. here is an example:
part.jpg

but after i put my hands on the SpectroShade tool for profesionall color analysis in dentistry i can:
1)compare results from both methods
2)see that the resolution of my analysis is better and more detail in pixels (not big squares like SpectroShade does)
3)see that many times tooth color doesn't match any of the VITA shades i use for analysis but it is based on color range tolerance. that's why i'm working on more detailed and mathematical analysis by using excel to check delta E.

in a few days i'm going to resample my shades with maximum quality.

here is a correct jpg and xlsx.
1part.jpg
3part.jpg
http://dentopolis.org/temp/3part.xlsx

i don't know if i'm doing it right in excel with L,a,b and a,b ...i can see a little difference between Lab and ab in the middle and bite section of the tooth. but i think that even right now excel confirms the right way i made photoshop analysis. any ideas how to make it better?

what's not good is that in ps colors overlay each other when the tolerance is too high in color range selection.
do you think that some proportion in excel could mix color to say that for example i should take 70% B2 and 30& C2 to achieve minimum delta E?
 

Attachments

  • ShadesAnalysis.jpg
    ShadesAnalysis.jpg
    2.2 MB · Views: 1
  • 3part.jpg
    3part.jpg
    522.9 KB · Views: 2
Last edited:
i don't know if i'm doing it right in excel with L,a,b and a,b ...i can see a little difference between Lab and ab in the middle and bite section of the tooth. but i think that even right now excel confirms the right way i made photoshop analysis. any ideas how to make it better?

what's not good is that in ps colors overlay each other when the tolerance is too high in color range selection.
do you think that some proportion in excel could mix color to say that for example i should take 70% B2 and 30& C2 to achieve minimum delta E?

Hi ninaoki
I believe using the Lab approach with appropriate lighting is the correct and I believe you are on the right path with the correct math.
Better matches involve the correct numbers for the sample teeth and correct lighting/preparation for the actual patient.
Other then that, for product, you need to test your product against a large variety of patients and see if the visual match with the samples is the same as you workflow. When not, it means you need to tune up your product.

In making selections for analysis, avoiding specular areas is important. Also, if you use a PS tool that uses the tolerance option, it has inherent limitations as such a tool selects on an RGB math equation that do not exactly reflect what you see with you eyes (e.g. it is color data based not luminosity based. That means the blue component of RGB in selecting an area gets too much weight. Those are the fine tuning nuances that come with product development that are beyond the basic pointers from forum posting in my opinion.

If you need more help than just the basic pointers for you product in PS or Excel, it is probably an indicator you need to hire an expert to aid in achieving a quality product result as well as advice/course correction when you hit the inevitable bumps in the road during product development, testing, deployment, maintenance, and support.

Hoped that advice in the thread helped get you on your way and best wishes.

John Wheeler
 
if you use a PS tool that uses the tolerance option, it has inherent limitations as such a tool selects on an RGB math equation that do not exactly reflect what you see with you eyes (e.g. it is color data based not luminosity based. That means the blue component of RGB in selecting an area gets too much weight.

thanks for everything. am i allowed to open a new thread to discuss the most accurate color selection method in photoshop for L,a,b?
 
thanks for everything. am i allowed to open a new thread to discuss the most accurate color selection method in photoshop for L,a,b?

I don't see why not. The moderators will keep you on track if there is a concern with a post. The only redirection that I have seen is when someone is asking for a job to be done vs just someone wanting some advice or pointers. Questions that are really asking for a job or consulting to be done, is typically shipped over to another Forum where members can bid to do the work you desire.
 
I have a few minutes to spare so wrote a script to compare colours using the denary value of the hex colour, it shows that it does not work and proves what John and Tom have allready said. But it was fun doing it.
(The colours used were taken using the colour sampler on the low res picture supplied so they are not acurate.)
The script requires only one colour sampler to be selected.
TC.jpg
 

Attachments

thanks Paul for that, i will look at it late night. i have created an excel to do that. does anyone know how should I think of finding the perfect mix of shades to match tooth shade? not close but precise. here is what i mean:

my shades got color picked values like:
A1
L=73
a=4
b=21

A2
L=78
a=9
b=24

if i color pick a tooth and Lab values are L=74 a=8 b=22 how should I look for the mixture like 70%A1 + 30%A2? are those values equal during calculation or should i only think about a and b?
 
Hi Ninanoki

This will be my last post to your thread. I will provide my answer to a higher accuracy ∆E number and then some mathematical information on why your approach is highly unlikely to get a proper tooth color match. The best I think you will be able to reiably count on is 1 or 2 shades off (not great news yet it may save you some time on your project)

1) To have a higher accuracy ∆E number.mathematically:
The basic difference is to extract out of PS 16 bit values instead of 8 bit values and use them properly in Excel.
Workflow > Image capture in Raw (not JPEG) - Raw process in TIFF 16 bit mode in your desired color space to send to PS. Do not got into 8 bit mode. This reduces accuracy and as well when changing color modes in 8bit, PS by default adds some noise into the image which will also add error (this dither can be turned off in Edit > Color Settings yet only applies to 8 bit mode.

Convert to LAB with Edit > Convert to Profile and use the Absolute Colorimetric rendering intent (not sure this is needed for LAB yet the idea is not to change the white point in the conversion). Again, leave the image in 16 bit mode.
Change the info panel to read Lab values in 16 bit mode (its actually 15 bit mode yet that is a detail). Copy those numbers into Excel.
The scale down the 15 bit Lab numbers by
L=L(15 bit)/327.68 (16 bit numbers for L are scaled different than the "a" and "b" numbers
a=a(15 bit)/128
b=b(15 bit)/128

This scale the numbers in PS to floating point numbers that will be very close to the 8 bit numbers yet in floating point with higher accuracy. This will improve the accuracy of up to ∆E of .8.
NOTE - You would want to have 16 bit values for the tooth references as well.

2) By moving away from actual visual comparisons with the tooth, and moving to a photograph, the level of accuracy to exact correct color I believe is not possible. Here is the math of why.

Almost all tooth samples have a ∆E to another tooth sample of right around 3 or 4. That means if you have an error in your image Lab values and/or the tooth references of only 1.5 ∆E, then you would not be able to get a best match to a reference tooth. It would give you a wrong answer.

That means after going through all the specialized lighting, white balance, tone correction etc, you would need to have an maximum error in each of L,a,b of only 1%

I dare say with the cumulative errors that you could have down your proposed workflow that it would be virtually impossible to achieve.

What you could get is a starting point or accepting that the identified tooth match could be off by one color/shade or maybe two.

That is probably why when getting a color match outside of tooth samples place right next to the teeth, most solutions that I have read about are using photospectrometers and even then.

So this is all in my opinion yet felt obligated along with the "academic" answers on measuring ∆E and accuracy of calculations, that I included a dose of practical advice to consider about why I consider an insurmountable challenge (assuming your are trying to get the exact match in selecting a tooth without reference teeth being used by the dentist.

Hope you find this useful.

John Wheeler (signing out of the thread)
 

Back
Top