def gaborwavelet(self, img): ''' Gabor wavelet (GW) filter (Is this working?) ''' imArray = utils.im2array(img) row_size, col_size = imArray.shape x = np.array(range(1, row_size + 1), dtype='float') x = x.reshape((row_size, 1)) y = np.array(range(1, col_size + 1), dtype='float') y = y.reshape((1, col_size)) orientations = [] for i in range(8): orientations.append(i * pi / 8) w = signal.freqz()# spatial frequency G = np.exp(-(x ** 2 + y ** 2) / (2 * imArray.std()**2)) GList = [] # image edge container for different directions for theta in orientations: wave_vector = x * np.cos(theta) + y * np.sin(theta) G *= np.cos(w * wave_vector) + 1j * np.sin(w * wave_vector) # Apply Gabor filter to image sigma = convolve.convolve2d(imArray, G) GList.append(sigma) # Get the imaginary part of GW # format the output image sigma, output_image = utils.formatimage(sigma) return output_image
def response(self, frequency, rotation, gamma=1, etha=1): gb = self.gabor2DFunction(frequency, rotation, gamma, etha) gb = gb.reshape(self.image.shape) # Get magnitude of Gabor function? # gb_magnitude = np.abs(gb) response = convolve.convolve2d(self.image, gb.real) return response
def gaborwavelet(self, img): ''' Gabor wavelet (GW) filter (Is this working?) ''' imArray = utils.im2array(img) row_size, col_size = imArray.shape x = np.array(range(1, row_size + 1), dtype='float') x = x.reshape((row_size, 1)) y = np.array(range(1, col_size + 1), dtype='float') y = y.reshape((1, col_size)) orientations = [] for i in range(8): orientations.append(i * pi / 8) w = signal.freqz() # spatial frequency G = np.exp(-(x**2 + y**2) / (2 * imArray.std()**2)) GList = [] # image edge container for different directions for theta in orientations: wave_vector = x * np.cos(theta) + y * np.sin(theta) G *= np.cos(w * wave_vector) + 1j * np.sin(w * wave_vector) # Apply Gabor filter to image sigma = convolve.convolve2d(imArray, G) GList.append(sigma) # Get the imaginary part of GW # format the output image sigma, output_image = utils.formatimage(sigma) return output_image
def response(self, frequency, rotation, gamma=1, etha=1): gb = self.gabor2DFunction(frequency, rotation, gamma, etha) gb = gb.reshape(self.image.shape) # Get magnitude of Gabor function? # gb_magnitude = np.abs(gb) response = convolve.convolve2d(self.image, gb.real) return response
def lapacian(grayarr): try: from scipy.stsci.convolve import convolve2d except ImportError: print "You probabably didn't install python scipy 0.7.0 correctly." kernel = -1*numpy.ones((3,3)) kernel[1,1] = 8.0 return convolve2d(grayarr, kernel, fft=True)
def filterResponse(self, params): ''' compute the response given x,y,f,angle ''' return convolve.convolve2d(params, self.imageArray)
def filterResponse(self, params): ''' compute the response given x,y,f,angle ''' return convolve.convolve2d(params, self.imageArray)