Please, refer to this journal article.
The last paragraph of the section 4.1 (Preprocessing) says that,
Using [threshold = (mean + std dev)
] along with Otsu Thresholding gives the following result,
.
And, without them I obtain the following result,
.
Therefore, I have three questions,
(1) What is the main issue with my implementation of Binary Thresholding?
(2) If Otsu Threshold really gives good result, why did the authors of the article suggest to use [threshold = (mean + std dev)
]?
(3) How can I apply a double
value as threshold of the Otsu?
Source Code
Here is the GitHub repository.
The most relevant part of the source code is as follows,
private void thresholdButton_Click(object sender, EventArgs e)
{
Bitmap color = (Bitmap)this.inputImagePictureBox.Image;
Bitmap temp = Grayscale.ToGrayscale((Bitmap)color.Clone());
ImageStatistics imgStat = new ImageStatistics(temp);
Histogram histogram = imgStat.Gray;
double meanPlusStdDev = histogram.Mean + histogram.StdDev;
OtsuThreshold otsu = new OtsuThreshold();
int thres = otsu.getOtsuThreshold(temp);//////
//otsu.Apply(temp, (int)meanPlusStdDev);
otsu.Apply(temp, thres);
thresholdedImagePictureBox.Image = temp;
}