Where do these methods come from?

Philipp Bender <[email protected]>
Newsgroups gmane.comp.python.image
Message-ID <[email protected]>
Hi there,

I am confused of the PIL code, I tried to write a custom non-linear filter 
that's the reason why I took a look.

Can someone give me a hint how this works:

ImageFilter.py, class RankFilter:

In the method "filter" which takes an image (which is obviously an Image()?) a 
method "image.rankfilter" is called. I cannot call this method on an image I 
e.g. loaded from a file and can't find it elsewhere in the code.

$ fgrep rankfilter *

returned only this file and on a *.so. Is that the key? Does "rankfilter" call 
a C-function which cannot be found in Python-code?

The other thing I originally planned was to write an own filter. I started 
with:

####

import Image
from ImageFilter import *

class BinomialFilter(Filter):

    name = "BinomialFilter"
    
    def __init__(self, scale=1):
        self.scale = 16
        self.offset = 1
        self.filtermatrix = [[1, 2, 1],[2, 4, 2],[1, 2, 1]]
        
    def filter(self, image):
        # convert to grayscale
        im = image.convert("L")
        return im

im = Image.open("/tmp/pic.jpg")
im.filter(BinomialFilter()).show()

###

which I thought should return me a grayscale image. But it returns a coloured 
image. What's wrong here?

Thank you for any advice,
Regards,
Philipp Bender
_______________________________________________
Image-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/image-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.