analitics

Pages

Friday, November 8, 2013

Using python with Image, ImageFilter, ImageChops and custom image filter.

Today I will sow you some filters using python Image, ImageFilter and ImageChops.

I make this default python script to open one image and after will be delete from memory.See the default image:


I make also one python class named TEST_FILTER.

This class will have all data from filter, see filterargs.

The filterargs args it's one matrix and this will be the filter.

The default script ...

import Image
import ImageFilter
import ImageChops

class TEST_FILTER(ImageFilter.BuiltinFilter):
    name="TestFilter"
    filterargs = (3,3),10,0,(1,0,1,0,0,0,1,0,1)

def main ():
    filename = "test-gentoo.jpg"
    image = Image.open(filename);
    del image;
if (__name__ =="__main__"):
   main();

Let's try first filter : TEST_FILTER

import Image
import ImageFilter
import ImageChops

class TEST_FILTER(ImageFilter.BuiltinFilter):
    name="TestFilter"
    filterargs = (3,3),10,0,(1,0,1,0,0,0,1,0,1)

def main ():
    filename = "test-gentoo.jpg"
    image = Image.open(filename);
    image.filter(TEST_FILTER).show();
    del image;
if (__name__ =="__main__"):
   main();

The result will be this:


Now for each filter will change this source code...

    image.filter(TEST_FILTER).show();

...with the new filter source code.

Let's see some filters ...

EMBOSS - filter

    image.filter(ImageFilter.EMBOSS).show();

FIND_EDGES - filter

    image.filter(ImageFilter.FIND_EDGES).show();

BLUR - filter

    image.filter(ImageFilter.BLUR).show();

CONTOUR - filter

    image.filter(ImageFilter.CONTOUR).show();

DETAIL - filter

    image.filter(ImageFilter.DETAIL).show();

EDGE_ENHANCE - filter

    image.filter(ImageFilter.EDGE_ENHANCE).show();

Now image convert with bit 1.

    image.convert("1").show();

Invert image with ImageChops.

    ImageChops.invert(image).show();

Thursday, October 31, 2013

News Python 2.6.9 final was released on October 29 2013.

News about python from www.python.org.
Python 2.6.9 is a security-fix source-only release for Python 2.6.8, fixing several reported security issues: issue 16037, issue 16038, issue 16039, issue 16040, issue 16041, and issue 16042 (CVE-2013-1752, long lines consuming too much memory), as well as issue 14984 (security enforcement on $HOME/.netrc files), issue 16248 (code execution vulnerability in tkinter), and issue 18709 (CVE-2013-4238, SSL module handling of NULL bytes inside subjectAltName).