Adaptive Threshold Binarization: Post-processing to remove ghost objects

Does anyone know of post-processing algorithms for removing ghost objects from a binarized image? Problem: When I binarize an image using, for example, the niblack or bernsen method, it produces a lot of noise. I’m a red book or an online article about binarization, and they all say that the post-processing step is necessary in Niblack and another binarization method, but they don’t say what it is, a post-processing operation. So please, if someone knows, call me. EDIT: Original image:

alt text http://i.piccy.info/i4/20/63/b970ab2ca66e997f421e969a1657.bmp

Burnson threshold wins 31, contrast 15:

alt text http://i.piccy.info/i4/32/55/2f1e0293311119986bd49529e579.bmp

Burnson threshold wins 31, contrast difference 31:

alt text http://i.piccy.info/i4/2a/13/774508890030b93201458986bbd2.bmp

Niblack method window of size -15, k_value 0.2:

alt text http://i.piccy.info/i4/12/4f/fa6fc09bcba7a7e3245d670cbfa5.bmp

Niblack-31 method window size, k_value 0.2:

alt text http://i.piccy.info/i4/c0/fd/1f190077abba2aeea89398358fc0.bmp

EDIT2: As you can see, the Niblack threshold is causing a lot of noise. And if I reduce the size of the window, the black squares will become a little white inside. Burnsen is better - less noise, but even if I make a contrast difference more, but there is one problem, I just can’t produce the image right now, in words, the problem is: if the image contains some objects with a color close to white, and the background is white, therefore, if there is a region (for the line with the sample) with black color, then this method ignores the objects, and the result is incorrect. This is because the Burnsen method uses this formula: on each pixel, the contrast difference diff = maximum_grayscale_value - minimum_grayscale_value is calculated and then diff is used to calculate the threshold value, but in the case I wrote above, we have a maximum value of 255 and a minimum value of 0. So Thus, the threshold will be 128, but the actual color of the object is higher than 128 (almost white).

Therefore, I need to use some post-processing operations for proper binarization. Any thoughts?

+4
source share
3 answers

End the Python program using the K-tool, a tool designed to find optimal quantization intervals:

from scipy.misc import imread, imsave def kmeans(file_in, file_out, maxiter): X = imread(file_in) thresh = X.mean() for iter in range(maxiter): thresh = (X[X<thresh].mean() + X[X>=thresh].mean())/2.0 X[X<thresh] = 0 X[X>=thresh] = 255 imsave(file_out, X) return X, thresh 

During each iteration, the K-value calculates the center of each “cluster”, and then reassigns the elements to the clusters based on the reconfigured centers. In the simple case, when each element (i.e., the Pixel) is one-dimensional and only two clusters are required, the threshold is simply the average of the two cluster centers.

I should add that this method works for an example image that you posted but might not for others (like the one you posted in another question). But without additional information, I think this solution works.

Conclusion:

binary.bmp http://up.stevetjoa.com/binary.bmp

+2
source

In my opinion, your problem is related to the problem of segmentation ... what types of images do you upload?

Btw, how can I comment on a question and not answer it?

0
source

The question may be outdated, but for those who have still not been able to find the answer, the method that should be used in these situations, namely with rapidly changing background images, is not the "Local gray level", but the local value "Threshold" , which analyzes images not according to the local gray level, but according to the stroke width method. U can search it online.

0
source

Source: https://habr.com/ru/post/1302864/


All Articles