Delete points containing pixels smaller than (N)

I tried almost all the filters in PIL, but could not. Is there a function in numpy scipy to remove noise? How to Bwareaopen () in Matlab ()?

eg:

enter image description here

PS: If there is a way to fill the letters with black, I will be grateful

+5
source share
3 answers

I don't think this is what you want, but it works (uses Opencv (which uses Numpy)):

import cv2

# load image
fname = 'Myimage.jpg'
im = cv2.imread(fname,cv2.COLOR_RGB2GRAY)
# blur image
im = cv2.blur(im,(4,4))
# apply a threshold
im = cv2.threshold(im, 175 , 250, cv2.THRESH_BINARY)
im = im[1]
# show image
cv2.imshow('',im)
cv2.waitKey(0)

Output (image in the window):
Output image

You can save the image using cv2.imwrite

+8
source

Numpy / Scipy can perform morphological operations as well as Matlab.

See scipy.ndimage.morphology for , among other things, the binary_opening()Matlab equivalent bwareaopen().

+15

Numpy/Scipy: scipy.ndimage.morphology.binary_opening. : scikits-image.

from skimage import morphology
cleaned = morphology.remove_small_objects(YOUR_IMAGE, min_size=64, connectivity=2)

. http://scikit-image.org/docs/0.9.x/api/skimage.morphology.html#remove-small-objects

+6

All Articles