I'm having a problem with binarization of image (perhaps blurry in general) I have this image:
and after I've done binarization I get
How can I do better binarization? My goal is to have just black background and white letters and nothing else. I used adaptive threshold binarization
cv2.adaptiveThreshold(image_gs,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY ,41,3)
and I also have
kernel=np.ones(1,1)
Does anyone have idea how to do that?
Image Binarization is the conversion of document image into bi-level document image. Image pixels are separated into dual collection of pixels, i.e. black and white. The main goal of image binarization is the segmentation of document into foreground text and background.
Thresholding is a type of image segmentation, where we change the pixels of an image to make the image easier to analyze. In thresholding, we convert an image from colour or grayscale into a binary image, i.e., one that is simply black and white.
For every pixel, the same threshold value is applied. If the pixel value is smaller than the threshold, it is set to 0, otherwise it is set to a maximum value. The function cv. threshold is used to apply the thresholding. The first argument is the source image, which should be a grayscale image.
Python - OpenCV & PyQT5 together From an image processing perspective, a binary image contains pixels with two possible values- zero and one.
You should try deblurring methods, see these:
Deblurring image by deconvolution using opencv
Experiments with deblurring using OpenCV
Try out the following:
1.De-noise your image,first, by using either a Median,Bilateral,Gaussian or Adaptive Smooth Filter (Gaussian filter works pretty well when it comes to images with textual content).
2.De-blur the image by referring to http://www.pyimagesearch.com/2015/09/07/blur-detection-with-opencv/ or https://github.com/tvganesh/deconv
3.Check out Adaptive Gaussian thresholding,instead.In case its a scene text image,you can use Otsu's algorithm after shadow removal. The 'Image Processing in OpenCV' tutorials have a detailed documentation on Image Thresholding.
The Image Filtering — OpenCV 3.0.0-dev documentation explains the implementation of the Median Blur, applied to an image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With