Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python How do I remove the dots / noise without damaging the text?

import cv2
import numpy as np

img = cv2.imread('path_to_your_image', 0)
_, blackAndWhite = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY_INV)

nlabels, labels, stats, centroids = cv2.connectedComponentsWithStats(blackAndWhite, None, None, None, 8, cv2.CV_32S)
sizes = stats[1:, -1] #get CC_STAT_AREA component
img2 = np.zeros((labels.shape), np.uint8)

for i in range(0, nlabels - 1):
    if sizes[i] >= 50:   #filter small dotted regions
        img2[labels == i + 1] = 255

res = cv2.bitwise_not(img2)

cv2.imwrite('res.png', res)
Comment

PREVIOUS NEXT
Code Example
Python :: Python - Cara Mengurutkan String Secara alfabet 
Python :: 201903100110041 
Python :: turtule code for digital clock 
Python :: get key of min value 
Python :: Convert this bash command into Python echo have a nice day Quizlet 
Python :: softmax for nparray 
Python :: how to add 2 integers in python 
Python :: How to get a mock image in django? 
Python :: send command civil3D 
Python :: def identity_block(X, f, filters, training=True, initializer=random_uniform): 
Python :: Issue TypeError: ‘numpy.float64’ object cannot be interpreted as an integer 
Python :: what does it mean when i get a permission error in python 
Python :: permcheck codility python 
Python :: import curses module in python 
Python :: how to convert array value to integer in python 
Python :: Bar Plot Seaborn with No Error Bars 
Python :: import nifti to numpy 
Python :: main.py : invalid syntax 
Python :: leetcode 206 python 
Python :: xmlrpc get all posts 
Python :: python identify array 
Python :: color to black and white opencv 
Python :: open tkinter and cli 
Python :: reorder columns in python 
Python :: paystack python 
Python :: pytorch pad to square 
Python :: fix misspelled in Wikipedia library on python 
Python :: request.query_dict hubspot 
Python :: how to add a list to a list python 
Python :: python remove warnings 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =