Remove points which contains pixels fewer than (N)

filter, image-processing, numpy, python, scipy

Solution

I don't think this is what you want, but this 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 a window ):

You can save the image using `cv2.imwrite`

Problem

I tried almost all filters in `PIL`, but failed. Is there any function in numpy of scipy to remove the noise? Like Bwareaopen() in Matlab()? e.g: PS: If there is a way to fill the letters into black, I will be grateful

Original source