# How do I compare two resultant images from different binarization algorithms?

I have a binarized image to which i add noise and then try to filter out the noise using various thresholding algorithms such as otsu and niblack.How can i compare the resultant image with the original image so as to find the percentage error that exists between the two??

the original image is as such:

and the resultant image is:

I need a way to find the percentage error that is present.

• Why not just subtract the two images and then count the number of non-zero elements in the difference ? – Paul R Apr 3 '12 at 13:13

Well i think you need to compare the effectiveness of various methods of noise removal that you would be using to get back the original image :

I would suggest to take the following parameters for measure

1. Mean Square Error (MSE)

2. Peak Signal to Noise Ratio (PSNR in dB)

3. Structural Content (SC)

and many others

You can find the MATLAB codes out here

Thresholding can be treated as one of the basic methods segmentation.

In general, to evaluate the segmentation method, one needs to compare it with a ground truth image and identify number of pixels that are correctly classified as foreground as foreground and vice-versa. In general, number of background pixels even if classified correctly shouldn't really matter.

One of the possible metric to evaluate is "Tanimoto Coefficient" - which is explained here:

Here is another reference

Mehmet Sezgin, Bulent Sankur Survey over image thresholding techniques and quantitative performance evaluation Journal of Electronic Imaging 13(1), 146 – 165 (January 2004).

which provides a much broader framework specifically for the thresholding. This method provides a mechanism which is not dependent on ground truth and hence it is quite useful for document image processing as dicussed in the paper.

Count the number of black pixels in the original image (P). Count the number of pixels that are black in the original image, but white in the new image (FN). Your percentage of false negatives is FN / P * 100.

Count the number of white pixels in the original image (N). Count the number of pixels that are white in the original image, but black in the new image (FP). Your percentage of false positives is FP / N * 100.

Since there are more white pixels than black pixels, you may want to weigh the false negative error and the false positive error differently.

By the way, if your image is already binary, why are using thresholding? I would think morphological operations might be a better option for this problem.

• I will be adding the noise to the image and converting it to greyscale.Its the only way i could think of to measure the success rate of different algorithms.Do you have any suggestions of another way I could do this? Thanks for your reply by the way, really helpful. – mark Apr 3 '12 at 15:20
• For this type of noise median filtering might work. There is a function in the Image Processing toolbox for that called medfilt2. – Dima Apr 3 '12 at 17:06