# HG changeset patch # User tomasz-bednarz # Date 1385431950 18000 # Node ID a44112280169a7c7fe6b5493aa7593ff0a029f10 # Parent 795060eb6643e87fe7da072dfae20214e5ed2c38 Uploaded diff -r 795060eb6643 -r a44112280169 filter_tools --- a/filter_tools Mon Nov 25 21:11:51 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,157 +0,0 @@ - - - - - - - - -filter_tools: log - - - - - -
- - -
-

filter_tools

-

log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ageauthordescription
Tue, 29 Oct 2013 14:01:57 +1100tomaszbednarzREADME updatedefault tip
Tue, 29 Oct 2013 13:58:09 +1100tomaszbednarzimage
Tue, 29 Oct 2013 13:21:34 +1100tomaszbednarzfilters
Tue, 29 Oct 2013 13:18:24 +1100tomaszbednarzadded filters
Tue, 29 Oct 2013 13:12:34 +1100tomaszbednarzfilter tools
Tue, 29 Oct 2013 13:11:26 +1100tomaszbednarz.
Fri, 18 Oct 2013 04:11:27 -0700tomasz bednarz.
Fri, 18 Oct 2013 04:09:45 -0700tomasz bednarz.
Fri, 18 Oct 2013 04:02:06 -0700tomasz bednarzfilters
Fri, 18 Oct 2013 00:40:53 -0700tomasz bednarz.
Thu, 17 Oct 2013 23:13:07 -0700tomasz bednarz.
Thu, 17 Oct 2013 22:57:23 -0700tomasz bednarztest only
Wed, 16 Oct 2013 16:34:53 -0700tomasz bednarzmedium
Wed, 16 Oct 2013 16:24:36 -0700tomasz bednarzFirst tool
Wed, 16 Oct 2013 23:17:28 +0000tomaszbednarzUploaded
- - - -
-
- - - - - - - diff -r 795060eb6643 -r a44112280169 test-data/images/sydney.jpg Binary file test-data/images/sydney.jpg has changed diff -r 795060eb6643 -r a44112280169 tools/blur.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/blur.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,32 @@ + + + Apply a blur filter on the image. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output blur jpeg + #else: + pil_filter.py $input $output blur ${input.ext} + #end if + + + + + + + + + + + + Apply a blur filter on the image (soften the image). + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/contour.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/contour.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,32 @@ + + + Apply a contour filter on image. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output contour jpeg + #else: + pil_filter.py $input $output contour ${input.ext} + #end if + + + + + + + + + + + + Apply a sharpen filter on the image. + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/detail.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/detail.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,32 @@ + + + Apply a detail filter on image. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output detail jpeg + #else: + pil_filter.py $input $output detail ${input.ext} + #end if + + + + + + + + + + + + Apply a detail filter on image (unsharp mask). + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/detial.xml diff -r 795060eb6643 -r a44112280169 tools/edge_enhance.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/edge_enhance.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,32 @@ + + + Apply an edge_enhance filter on the image. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output edge_enhance jpeg + #else: + pil_filter.py $input $output edge_enhance ${input.ext} + #end if + + + + + + + + + + + + Apply an edge_enhance filter on the image. + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/edge_enhance_more.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/edge_enhance_more.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,32 @@ + + + Apply an edge_enhance_more filter on the image. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output edge_enhance_more jpeg + #else: + pil_filter.py $input $output edge_enhance_more ${input.ext} + #end if + + + + + + + + + + + + Apply an edge_enhance_more filter on the image. + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/emboss.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/emboss.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,32 @@ + + + Apply an emboss filter on image. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output emboss jpeg + #else: + pil_filter.py $input $output emboss ${input.ext} + #end if + + + + + + + + + + + + An emboss filter gives a 3D shadow effect to the image, the result is very useful for a bumpmap of the image. It can be achieved by taking a pixel on one side of the center, and subtracting one of the other side from it. Pixels can get either a positive or a negative result. + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/find_edges.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/find_edges.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,32 @@ + + + Apply find_edges filter on the image. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output find_edges jpeg + #else: + pil_filter.py $input $output find_edges ${input.ext} + #end if + + + + + + + + + + + + Apply an find_edges filter on the image. + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/invert.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/invert.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,32 @@ + + + Apply an invert filter on the image. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output invert jpeg + #else: + pil_filter.py $input $output invert ${input.ext} + #end if + + + + + + + + + + + + Invert the image (colours). + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/max.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/max.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,34 @@ + + + Apply a max filter of the given size. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output max $size jpeg + #else: + pil_filter.py $input $output max $size ${input.ext} + #end if + + + + + + + + + + + + + Create a max filter of the given size. For each pixel in the input image, this filter copies the largest pixel value from a (size, size) environment to the output image. + + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/median.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/median.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,34 @@ + + + Apply a median filter of the given size. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output median $size jpeg + #else: + pil_filter.py $input $output median $size ${input.ext} + #end if + + + + + + + + + + + + + Create a median filter of the given size. For each pixel in the input image, this filter copies the median pixel value from a (size, size) environment to the output image. + + + + + + + + + + + diff -r 795060eb6643 -r a44112280169 tools/min.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/min.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,34 @@ + + + Apply a min filter of the given size. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output min $size jpeg + #else: + pil_filter.py $input $output min $size ${input.ext} + #end if + + + + + + + + + + + + + Create a min filter of the given size. For each pixel in the input image, this filter copies the smallest pixel value from a (size, size) environment to the output image. + + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/mode.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/mode.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,34 @@ + + + Apply a mode filter of the given size. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output mode $size jpeg + #else: + pil_filter.py $input $output mode $size ${input.ext} + #end if + + + + + + + + + + + + + Create a mode filter of the given size. For each pixel in the input image, this filter copies the most common pixel value in a (size, size) environment to the output image. If no pixel value occurs more than once, the original pixel value is used. + + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/pil_filter.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/pil_filter.py Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,117 @@ +import Image +import ImageFilter +import ImageChops +import os +import sys + +def isodd(num): + return num & 1 and True or False + +def main(): + numArgs = len(sys.argv) + + if numArgs < 2: + print "USAGE: provide input, output, functions, parameters" + exit(1) + + listOfValues = sys.argv[1:] + + try: + imageIn = Image.open(listOfValues[0]) + except IOError: + print "cannot open: ", listOfValues[0] + + if listOfValues[2] == "median": + size = int(listOfValues[3]); + # prevent size to be even + if size & 1 == False: + size = size + 1 + imageMedian = imageIn.filter(ImageFilter.MedianFilter(size)) + imageOut = imageMedian.save(listOfValues[1], listOfValues[4]) + # imageMedian.show() + print "Applied a median filter of the given size." + elif listOfValues[2] == "emboss": + imageEmboss = imageIn.filter(ImageFilter.EMBOSS) + imageOut = imageEmboss.save(listOfValues[1], listOfValues[3]) + # imageEmboss.show() + print "Applied an emboss filter on the image." + elif listOfValues[2] == "blur": + imageBlur = imageIn.filter(ImageFilter.BLUR) + imageOut = imageBlur.save(listOfValues[1], listOfValues[3]) + # imageBlur.show() + print "Applied a blur filter on the image." + elif listOfValues[2] == "contour": + imageContour = imageIn.filter(ImageFilter.CONTOUR) + imageOut = imageContour.save(listOfValues[1], listOfValues[3]) + # imageContour.show() + print "Applied a contour filter on the image." + elif listOfValues[2] == "detail": + imageDetail = imageIn.filter(ImageFilter.DETAIL) + imageOut = imageDetail.save(listOfValues[1], listOfValues[3]) + # imageDetail.show() + print "Applied a detial filter on the image." + elif listOfValues[2] == "edge_enhance": + imageEdgeEnhance = imageIn.filter(ImageFilter.EDGE_ENHANCE) + imageOut = imageEdgeEnhance.save(listOfValues[1], listOfValues[3]) + # imageEdgeEnhance.show() + print "Applied an edge enhance filter on the image." + elif listOfValues[2] == "edge_enhance_more": + imageEdgeEnhanceMore = imageIn.filter(ImageFilter.EDGE_ENHANCE_MORE) + imageOut = imageEdgeEnhanceMore.save(listOfValues[1], listOfValues[3]) + # imageEdgeEnhanceMore.show() + print "Applied an eddge enhance more filter on the image." + elif listOfValues[2] == "find_edges": + imageFindEdges = imageIn.filter(ImageFilter.FIND_EDGES) + imageOut = imageFindEdges.save(listOfValues[1], listOfValues[3]) + # imageFindEdges.show() + print "Applied a find_edges filter on the image." + elif listOfValues[2] == "sharpen": + imageSharpen = imageIn.filter(ImageFilter.SHARPEN) + imageOut = imageSharpen.save(listOfValues[1], listOfValues[3]) + # imageSharpen.show() + print "Applied a sharpen filter on the image." + elif listOfValues[2] == "smooth": + imageSmooth = imageIn.filter(ImageFilter.SMOOTH) + imageOut = imageSmooth.save(listOfValues[1], listOfValues[3]) + # imageSmooth.show() + print "Applied a smooth filter on the image." + elif listOfValues[2] == "smooth_more": + imageSmoothMore = imageIn.filter(ImageFilter.SMOOTH_MORE) + imageOut = imageSmoothMore.save(listOfValues[1], listOfValues[3]) + # imageSmoothMore.show() + print "Applied a smooth_more filter on the image." + elif listOfValues[2] == "min": + size = int(listOfValues[3]) + # prevent size to be even + if size & 1 == False: + size = size + 1 + imageMin = imageIn.filter(ImageFilter.MinFilter(size)) + imageOut = imageMin.save(listOfValues[1], listOfValues[4]) + # imageMin.show() + print "Applied a min filter of the given size on the image" + elif listOfValues[2] == "max": + size = int(listOfValues[3]) + # prevent size to be even + if size & 1 == False: + size = size + 1 + imageMax = imageIn.filter(ImageFilter.MaxFilter(size)) + imageOut = imageMax.save(listOfValues[1], listOfValues[4]) + # imageMax.show() + print "Applied a max filter of the given size on the image" + elif listOfValues[2] == "mode": + size = int(listOfValues[3]) + # prevent size to be even + if size & 1 == False: + size = size + 1 + imageMode = imageIn.filter(ImageFilter.ModeFilter(size)) + imageOut = imageMode.save(listOfValues[1], listOfValues[4]) + # imageMode.show() + print "Applied a mode filter of the given size on the image" + elif listOfValues[2] == "invert": + imageInvert = ImageChops.invert(imageIn) + imageOut = imageInvert.save(listOfValues[1], listOfValues[3]) + # imageInvert.show() + print "Inverted the image." + +if __name__ == "__main__": + main() \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/sharpen.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/sharpen.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,32 @@ + + + Apply a sharpen filter on image. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output sharpen jpeg + #else: + pil_filter.py $input $output sharpen ${input.ext} + #end if + + + + + + + + + + + + Apply a sharpen filter on the image. + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/smooth.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/smooth.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,32 @@ + + + Apply a smooth filter on the image. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output smooth jpeg + #else: + pil_filter.py $input $output smooth ${input.ext} + #end if + + + + + + + + + + + + Apply a smooth filter on the image (soften the image). + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/smooth_more.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/smooth_more.xml Mon Nov 25 21:12:30 2013 -0500 @@ -0,0 +1,32 @@ + + + Apply a smooth_more filter on the image. + + + #if (str($input.ext) == 'jpg'): + pil_filter.py $input $output smooth_more jpeg + #else: + pil_filter.py $input $output smooth_more ${input.ext} + #end if + + + + + + + + + + + + Apply a smooth_more filter on the image (soften the image). + + + + + + + + + + \ No newline at end of file diff -r 795060eb6643 -r a44112280169 tools/smoth.xml diff -r 795060eb6643 -r a44112280169 tools/smoth_more.xml