Best tooth color match

i have a photo of a tooth in RAW/NEF format. photo is taken with a correct white balance and with a correct color profile.

how can i find best matching colors of the tooth from those shades below assuming I know their Lab values. I could use segmentation editor but some color will overlay so choosing which color covers more area can sometimes be difficult. any other method/plugin is better for this?

One method could be to use template matching (the template would be the tooth), see:

ImageJ plugins:

Older Forum Thread:

Another way would be to use the Trainable segmentation Plugin where the different classes are the different shades.

Problems will certainly occur because of the light reflections on the tooth.
I think it should be possible to filter them out with a decent filter kernel.

can i add more than two classes in Trainable Weka Segmentation? in need 16 color shades.

Sure, you can add additional classes. As far as I know there is no upper limit here, although I’m not sure if TWS is the most efficient route for so many shades, any thoughts @iarganda?

You can add up to 100 classes right now. I’m not sure about the efficiency either.

1 Like

great tool, works fine with 16 shades but how can i make it not to color anything except those shades? like lips, skin, etc.


You can add one more class that represents ‘background’ - i.e. lips, skin, etc. So just add traces over those regions and train again. Actually - i’m not sure it’s going to be so straightforward. You can try to add an additional class - but now that I’m testing it myself - it’s not working so well with that additional ‘background’ class.

This is before including skin and gums in the background class:

This is AFTER including skin and gums in the background class:

In this latter case - then almost everything is classified as ‘background’ - there is obviously too much overlap of colors of the teeth and skin/gums. For sure @iarganda will have better insight in how to address this.

eta :slight_smile:

thanks anyway, i’ll wait for @iarganda hints but maybe you know how to edit the color tolerance in this plugin?

Someone might have a clever way to do this in the image processing step, but I think some small adjustments to your image acquisition could go a long way. As you are photographing people here, I imagine you will get a few different colors of background…

Maybe you can drape something with a distinct, matte color over the skin? Or pull it back so that you only have the gums to get rid off? I’m not a dentist, maybe you can think of something suitable. Anything that gives you less variation in background is an improvement.


sure i can crop the image to leave black (open mouth) and gums. how about tolerance? can i lower/increase it somehow?

Yes, cropping is probably easiest… Do you need all the teeth? I’d say cropping the two front teeth in good focus will give you the most reliable results.

I don’t know about any tolerance setting in Weka, I suppose increasing the training data would improve the ability to segment the different classes here, if that’s what you are after?

Do you intend to repeat this process for each patient or to train a classifier that can be applied generally?

If in each instance you want to match the patients teeth with the color table below the image, some kind of template matching as suggested by @Bio7 might be the best approach… although I’m not entirely sure how you would go about it. EDIT: That being said, I can’t imagine it being very complicated (color template-matching).

1 Like

everytime i set the correct white balance and create color profile with x-rite color passport so I assume color I achieve have always natural shades. i take a photo with one shade like on the picture above just to check if recognized color is correct for that shade.
so classes and data should always be the same. i only need to open an image and apply classifier.

I will test results I get in ImageJ (Fiji) with Photoshop photoshop my action selects color range of shade A1 with fuzziness (tolerance) of 5,10,15 or 20 and fills selection with some color easy to recognize.the same for all other shades. problem is that usually colors overlay each other and it is difficult to choose best matching color. anyway I’m curious which method will be more precise.
I will compare those results with dental spectrophotometer SpectroShade.

Woo this looks like a fun hot topic.

While we are enjoying machine learning, how about a “simpler” approach.

Here is an example using k-means clustering that worked pretty well for me…

  1. Create ROIs for each tooth to get the mean Red Green and Blue Values
  2. Use these to create a table with the centroid values

    3, With that (reusable) table, we can then apply the clustering on the image to get the cluster number

With this approach, it seems that the fake tooth is closer to C3 and the real tooth seems closer to D2

I used the excellent k-means implementation from the IJ-Plugins Toolkit

You can find attached the table that I built by hand.

To test it yourself. (409 Bytes - It is just a CSV but the forum won’t let me post it directly)

  1. Make sure that the IJ-Plugins toolkit is installed - Unfortunately they are old-school and do not have an update site yet (or am I wrong?)
  2. Open the attached table
  3. Open your image
  4. Run the Plugins > Segmentation > k-means Clustering Reapply…
  5. Select the name of the table and select the image.
  6. On the resulting ‘Clusters’ image use the Glasbey Inverted Lookup Table, which helps you see the clusters a little bit better using Image > Lookup Tables

I join all my colleagues in that you can maybe improve the acquisition but if you happen to have the x-rite passport, then that’s already awesome!

Hope this helps.



Hello everybody,

Just to add to the conversation, I would like to mention that you can also perform clustering with TWS by using the ClassificationViaClustering classifier and selecting the clusterer you prefer. Here you are the instructions to install a new classifier such as ClassificationViaClustering.