Wednesday, September 12, 2007

Filter numpy images with FFT, Python

Generic linear filter support is not currently built into the Python Imaging Library. This module lets you filter a numpy array against an arbitrary kernel:
    >>> I = numpy.asarray(Image.open('test.jpg'))
    >>> I = filter(I, [[-1,0,1],[-2,0,2],[-1,0,1]])/8+128
    >>> Image.fromarray(numpy.uint8(I)).show()
The Fast Fourier Transform (FFT) is used. The FFT routine included with numpy isn't particularly fast (c.f. FFTW [1]), and in any case using the transform isn't as efficient as applying the filter naively for small filter sizes. Also, for separable kernels (e.g. the Gaussian kernel), it is often faster to perform two 1D convolutions in sequence. However, for large images and filters, using an FFT for convolution is often faster than other approaches. (If an image and filter contain a total of N pixels, then this algorithm takes O(NlogN) time, which is the fastest known time complexity algorithm for the general problem.) Public domain.

Update: A number of image filtering operations are provided in numarray (in the module numpy.numarray.nd_image), such as filtering, image morphology, distance transforms, and segmentation; see [2].

(Source)

8 comments:

Anonymous said...

honestly I do not understand so much about Python, actually I thought it was the name of a company on the Internet when you can buy Viagra Online , I know I am a big ignorant!

Generic Viagra Viagra

Anonymous said...

j2j3
I do not understand neither, but I think you can add even more information about it, specially if we are sharing the same objective: Generic Viagra development. All is about information and "seo" skills. You know what I mean.

Chris said...

TypeError: 'numpy.ndarray' object is not callable

Entertaining Game Channel said...

This is Very very nice article. Everyone should read. Thanks for sharing. Don't miss WORLD'S BEST MonsterTrucksRacingGamesForKids

Callie Edorra said...

Hi,
This is a nice post shared here.. Thanks for sharing..
Men leather Vest

ZedRS said...

Get the lowest prices for Max main rental for oldschool prices from ZedRS.

Jay Keygreer said...

Glass Crack Repair
Liberal KS Exterminator
Investor Friendly Contracting KCMO
Contracting Near Me
Buy My Home Fast
Online High School Fundraising

Nino Nurmadi , S.Kom said...

Ok
Kontrakan Natar