# Appropriate Level of Uncertainty in Pixel Classifixation?

Hi everyone,
I am new to using this software but have been unable to find an answer to this question. I am wondering what an appropriate level of uncertainty is when performing pixel classification. Essentially, is the goal to completely get rid of the blue color seen in the uncertainty layer of the image, or is some uncertainty inherent in the way the program works? I have spent a lot of time annotating my training images to the best of my ability, but have not seen a major improvement in uncertainty levels past a certain point, particularly at cell boundaries. Is there any other way to reduce uncertainty? An explanation as to how the system is determining uncertainty would also be much appreciated!

Thank you very much for your help!

Dear @emwelter,

welcome to the image.sc forum!

Uncertainty computation in ilastik:
Suppose you have a Pixel Classification Project with N classes (where N is at least 2), then for each pixel you get N probabilities, that the pixel belongs to the respective class. For the uncertainty, those probabilities are sorted for each pixel and the top 2 probabilities are are substracted from each other. This gives you a small number if probabilities are very close together (or a large number if probabilities are far apart). Then you substract this number from one, to invert this relationship -> large number (high uncertainty) for probabilities that are close together.

An example.
Say we have pixel classification with 4 classes and we look at one pixel. There you get the following probabilities:
[0.09, 0.4, 0.45, 0.06].
Those probabilities are sorted, so you get
[0.45, 0.4, 0.09, 0.06].
You substract the highest two probabilities from each other: 0.45 - 0.4 = 0.05. You substract this number from 1: 1 - 0.05 = 0.95 to get your uncertainty measure (which is high in this case).

For the second part of your question, whether it is possible to get rid of uncertainty completely: Not really. Especially at the boundaries youâ€™ll have this continuum of pixel characteristics where probabilities might be close.

Cheers
Dominik