Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binarization of image in opencv

Tags:

python

opencv

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?

like image 479
slomil Avatar asked Dec 15 '15 12:12

slomil


People also ask

What is binarization in image processing?

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.

What is threshold of image in Python?

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.

What is image thresholding in OpenCV?

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.

What is binary image in OpenCV?

Python - OpenCV & PyQT5 together From an image processing perspective, a binary image contains pixels with two possible values- zero and one.


2 Answers

You should try deblurring methods, see these:

Deblurring image by deconvolution using opencv

Experiments with deblurring using OpenCV

like image 179
Nima Avatar answered Oct 05 '22 08:10

Nima


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.

like image 39
Sukriti Avatar answered Oct 05 '22 09:10

Sukriti