MATLAB: Confusion matrix to validate image segmentation

confusion_matriximage_processingradiographradiologyx ray

I have a segmented image of an xray image. I need to make a confusion matrix to validate that segmentation. Can anyone tell me please how can I apply a confusion matrix to validate image segmentation?
The origial image and te segmented image are shown below.
The first one is the original image and the second one is the segmented image.

Best Answer

If you have the Statistics and Machine Learning Toolbox, you can use confusionmat() and confusionchart(). Of course you still have to do a bunch of experiments to determine true positive, true negatives, false positives, and false negatives. I assume you know how to do that. It's basically a list of whether you got the diagnosis right or wrong. You have to decide how to determine if the segmentation is right or wrong, like use the Sorensen-Dice metric to see how much of your segmentation overlaps a hand drawn segmentation by the radiologist.
Related Question