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:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_DBpAcOe8Jh69vL8Y7cPIgGXwId7ocjCbeTK_UFupT1JdGtOs68SQSXxPK3ha5Z_oEZPoqGJUq6ZU-JxnSnkCitfG7JN4i06AoV_79sXUkV-M7Bmd3M9oroabuEvhDQQHBPJ6aiUZ3J4/s320/test-gentoo.jpg)
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:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnP18cwUH_Xj5l_Ubyb_DKbz7JNV1OMK7f5sX13n703QkSwpfHXL6nyebopaKGK-qcTlCeg1OsfaF-NvC8MZi9HqzqvQ26NN7WJbchNQN4JRvO0ENRhvn7BlIPY6ypHYZQ4UotKYByV18/s320/1.png)
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();
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaH57hsUO4C6VQfM-AjRT9di6YuHZKHl8I3prFNJzIrnRacRfco3nbXMqyzHc_XhVIVBUti4WuR7uZxEIg7oYhue1TYhDyUHX1c6K97jwE4qQgMjk5DQx1U8D7gZ28KEVaVSMFoHPgLc0/s320/2.png)
FIND_EDGES - filter
image.filter(ImageFilter.FIND_EDGES).show();
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZY1mCId0xtjw15zI1_5-9tFY7fHlMh4KJTzSACp3ANNWjrIr16kftCJ0E1QoEhywxWgrXURb_fIaIQTnr0V26NVMsI8wphF3yKFZ82rnDN25vdBS7ako_Bxlp10n6tDaevfsy7JYT7U4/s320/3.png)
BLUR - filter
image.filter(ImageFilter.BLUR).show();
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUl_Gj_vPTb1SARSTV6pDSI7x8qIMtlqB273wcoComXeTRrNJCTofbjOKJ_7bOUtsf5QzA6qWPbKezLken9nrmwpI48ffrnY-qk8bFND-Puc26eSTmAG5-bOFv7BtaGH9rRI_bFVdP9Ks/s320/4.png)
CONTOUR - filter
image.filter(ImageFilter.CONTOUR).show();
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYZFTMQB3JIB1JnRADC4ZLOVb8nG6qSn9O9AtMdY1-Cr7UWgM8e6Cf3yR6aHCQmdDbk6P0b_35s7fENKc4tlbxwE-VzBDR7hKG64Ogr0aJIKBk_RXqAjDR1lESU_qHIqrFbvhNFOcvy7I/s320/5.png)
DETAIL - filter
image.filter(ImageFilter.DETAIL).show();
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjs3p4p90gJdPSvtwVdrkfrCfPUmLjTtUvlK5EUIngt8gSAflbw7QR_MB-8VUFhSy1Bzh-H8e2ascIiqNeGjUpOCNoivThBPjkCqW2IjWPAGfUi6an8R8tleFRmgN96yP7XARERvZIV2j0/s320/6.png)
EDGE_ENHANCE - filter
image.filter(ImageFilter.EDGE_ENHANCE).show();
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzHSNxVzvWrdWw2UrBCgJgR-nl0tNqUGzl4Mxk7GJ4UqBkrCVeiKh7W_CUlnBwCNVIaYbLEeLAZWeV778LXLtZ_Nu5Ljq-CoZf109k7GwdN3VbNlZqYGUYFXBYnIH-MjXTZDqNO_rAP6U/s320/7.png)
Now image convert with bit 1.
image.convert("1").show();
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgow7HhTPErRJQwXaf0arhdNNn2GfL6ufVgmCeDfSzfSJM3aEfwmedfzfZBWR-Ho2tlle63Rm3L0ssRYNe10CDiJB0LRFo0bOTsx1Ad0kvUVLFPXMheia7H-m6otnElpJwmFXfMS_PRbDY/s320/8.png)
Invert image with ImageChops.
ImageChops.invert(image).show();
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSIxP-Sv0NJYl7OdRCyAlE_CMIo7ILcJnUfmbOk4SQjXTnTDbHrzj5v3vV38ETNgs5uzuhXVFE0aSBWCt7VYaYsrRQuWJnowz6M-6l7u19bquDmX8SUUlX3nn-BWgjgW3GxHW7OrIJNzQ/s320/9.png)