Hi Nate,

I am also working in an academic application for image processing (remote sensing data) based in Python, which is intended to accompany a book over this topic (written in Spanish).

I have been working around the same tools you mention (PIL, Numpy, wxPython), as you can see in the attached file, although a problem I have found with PIL is that the georeference is lost after the processing (I have had also some problems linking this to an interface developed with wxPython, a question that I am going to send to the wxPython list soon). Now, I am looking toward GDAL.

Maybe you have seen this doc: http://www.esri.com/news/arcuser/0405/files/python.pdf, where there is an interesting example using GDAL (page 2, listing 1). I tried it with my own data, but I got an unexpected result. Anyway, you can also take a look at hobutools (http://hobu.biz/software/hobutools/index_html), which include several tools (GDAL/OGR, MapScript, …) for Python 2.4.

I have written some functions for image preprocessing (contrast adjustment, PCA, filtering) in the R language, which is also a very useful language for teaching purposes, although it is not well-fitted for very large datasets, like a raster image (that is one of the reasons why I am going to make the translation to Python).

I think it is also worthy to look at PCL (Python Cartographic Library) and the GRASS/Python interface, but as you know, they require a more advanced knowledge.

Regards,

Ali Santacruz
M.Sc. Geomatics, Student
National University of Colombia
Bogotá D.C.



From: "Nate Jennings" <[EMAIL PROTECTED]>
To: image-sig@python.org
Subject: [Image-SIG] working with multi-spectral imagery, PIL, and NumPy
Date: Fri, 4 May 2007 14:47:39 -0700

Hello...

I am working on building an image processing application for a class I am
teaching in remote sensing.
I have multi-spectral (multi-band...greater than 3 bands of imagery) that I
would like to load into a NumPy array so I can process it.  PIL seems to be
limited to 3 bands for PIL. Is there any other methods using PIL, NumPy, or
other to work with more than 3 bands?

The file format I am working with is TIF. The data is often from satellites
(Landsat, SPOT, RADAR) or hyperspectral.

I would like to do pixel processing such as custom filters that are not
found in PIL, band ratios, image enhancements such as Principle Components,
and image classification (such as maximum likelihood, or ISOData
(unsupervised classification).  Many of these functions require linear
algebra, trigonometry functions, and statistics (the use of means, st
deviations, histograms, etc) as well as 3x3, 5x5, or greater kernels (i.e.
moving windows).

From my research there seems to be some work out there regarding 3 band
images, performance testing for PIL and C routines, some basic filtering
functions and kernel use.

My work is related to remote sensing and GIS.  Yes, I know about GRASS, but
this is too complicated for my students who know very little about remote
sensing and GIS. It looks like QGIS and GRASS have some integration, but it
is still too cumbersome for novice users.  I have been through a remote
sensing algorithms class in grad school and I have fundamental knowledge of
the math and programming logic.  I am just trying to get it to work with
Python, wxPython interface building, PIL, NumPy, and anything else I may
need.  Trying to communicate Python to C++ is beyond my capability without
any serious documentation or samples to work from.  I know C++, but it has
been over 10 year since I programmed in this and it was done in OS2.

Please provide me with links, sample code, and/or contacts to follow up
with.

Thank you in advance with any information.

Nate

--
http://www.jenningsplanet.com


_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
def filterf(input, output):
    """apply a directional filter on an image"""
    im = Image.open(input)
    out = ImageOps.expand(im, 1, 1)
    a = list(im.getdata())
    a1 = n.array(a).reshape(im.size[1],im.size[0])
    kernel = n.array([[-1,1,1],[-1,-2,1],[-1,1,1]]).astype(float)
    dotc = n.median(n.arange(1,kernel.shape[1]+1))
    dotr = n.median(n.arange(1,kernel.shape[0]+1))

    for i in n.arange(1,dotc):
        a1 = n.column_stack((a1[:,0],a1,a1[:,a1.shape[1]-1]))

    for i in n.arange(1,dotr):
        a1 = n.vstack((a1[0],a1,a1[a1.shape[0]-1]))

    a2 = a1.copy().astype(float)

    for i in n.arange(dotr-1,a1.shape[0]-(dotr-1)):
        for j in n.arange(dotc-1,a1.shape[1]-(dotc-1)):
            if kernel.sum()==0: skernel = 1
            elif kernel.sum()!=0: skernel = kernel.sum()
            a2[i,j] = (((kernel*a1[(i-1):(i+dotr),(j-1):(j+dotr)]).sum())/skernel).round()

    a3 = a2.copy()

    for i in n.arange(1,dotc):
        a3 = n.delete(a3, [0], axis=1)
        a3 = n.delete(a3, [a3.shape[1]-1], axis=1)

    for i in n.arange(1,dotr):
        a3 = n.delete(a3, [0], axis=0)
        a3 = n.delete(a3, [a3.shape[0]-1], axis=0)

    a4 = (((a3-a3.min())/n.diff([a3.min(),a3.max()]))*255).round().astype(int)

    im.putdata(list(n.ravel(a4)))
    im.save(output, "TIFF")

_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to