I have an image which I'm equalizing and then using clahe histogram on, like so:
self.equ = cv2.equalizeHist(self.result_array) clahe = cv2.createCLAHE(clipLimit=100.0, tileGridSize=(8,8)) self.cl1 = clahe.apply(self.equ)
This is the result I get:
I want to get rid of all the black dots which is noise. Ultimately, I'm trying to extract out the blood vessels, which are black in the image shown above, in trying to do so, the noise makes the extraction inaccurate.
1 Answers
Answers 1
A large part of my thesis was on reducing the noise in images, and there was a technique I used which reduced noise in images while preserving the sharp edges of information in the image. I quote myself here:
An effective technique for removing noise from fringe patterns is to filter the image using sine-cosine filtering [reference]. A low-pass filter is convolved with the two images that result from taking the sine and cosine of the fringe pattern image, which are then divided to obtain the tangent, restoring the phase pattern but with reduced noise. The advantage of this technique is that the process can be repeated multiple times to reduce noise while maintaining the sharp details of the phase transitions.
And here is the code I used:
import numpy as np from scipy import ndimage def scfilter(image, iterations, kernel): """ Sine‐cosine filter. kernel can be tuple or single value. Returns filtered image. """ for n in range(iterations): image = np.arctan2( ndimage.filters.uniform_filter(np.sin(image), size=kernel), ndimage.filters.uniform_filter(np.cos(image), size=kernel)) return image
There, image
was a numpy array representing the image, linearly rescaled to put black at 0
and white at 2 * pi
, and kernal
is the size in image pixels of the uniform filter applied to the data. It shouldn't take too many iterations to see a positive result, maybe in the region of 5 to 20.
Hope that helps :)
0 comments:
Post a Comment