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:

enter image description here

and the resultant image is:

enter image description here

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

  • 2
    $\begingroup$ Why not just subtract the two images and then count the number of non-zero elements in the difference ? $\endgroup$
    – Paul R
    Apr 3, 2012 at 13:13

3 Answers 3


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

enter image description here

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:

How do I evaluate the performance of a segmentation algorithm?

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.

  • $\begingroup$ 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. $\endgroup$
    – mark
    Apr 3, 2012 at 15:20
  • $\begingroup$ For this type of noise median filtering might work. There is a function in the Image Processing toolbox for that called medfilt2. $\endgroup$
    – Dima
    Apr 3, 2012 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.