jump to navigation

Mosaify Image Filter 15. August 2017

Posted by Martin Frech in Foto-Projekt, Technik.
Tags: , , , , , , ,
add a comment

Guest post written and illustrated by Jonathan Frech

Abstract.
Dieses Python-Programm mosaifiziert ein gegebenes Bild. Dieser Effekt wird dadurch erreicht, dass pseudozufällige Strecken gezeichnet werden, welche durch ihre Schnittpunkte Polygone definieren. Eben diese werden anschließend mit den Farbdaten des ursprünglichen Bildes gefüllt. (Quelltext via pastebin)

This Python program mosaifies a given image. By pseudo-randomly drawing lines, polygons are defined which are then filled with the original image’s colors. (Sourcecode via pastebin)

Mosaify is an image filter written in Python 2.7 utilizing the Python Imaging Library. It takes in an input image and outputs a mosaified version of it.
Starting with a blank canvas the size of the original image, lines are randomly drawn, which will most likely intersect to form polygons of different sizes and shapes. Said polygons are filled with the original image’s color at each polygon’s most top-left pixel position.
As a final touch, the lines drawn at the beginning are filled in with one pseudo-randomly chosen surrounding pixel. Because of this, edges are a bit frazzled.
Other appearences can be achieved by changing parameters n and k, which define the number of lines drawn and their distribution (both floating-point numbers larger than zero, by default n = 5 and k  = 1). It may also help to run the filter a few times to get a visually pleasing output, as the polygons are pseudo-randomly determined.

The program usage is as follows: python mosaify.py <image file name> [n] [k]

Martin and ivy, mosaified with n = 5 und k = 1
Martin and ivy,
mosaified with n = 5 und k = 1 (which are the default parameters)

Martin and ivy, mosaified with n = 10 und k = 1Martin and ivy,
mosaified with n = 10 und k = 1

Martin and ivy
Martin and ivy, before processing

Images and text © 2017 Jonathan Frech, J-Blog

 


(Ich weiß, die Werbung nervt. Und ich kann nicht einmal entscheiden, was hier gezeigt wird.)

Advertisements

pygame.CaotinaCam.Portrait.Martin() 7. Februar 2016

Posted by Martin Frech in Foto-Projekt, gute Idee.
Tags: , ,
add a comment


import pygame.camera
...
cameras = pygame.camera.list_cameras()
self.CAM = pygame.camera.Camera(cameras[0], self.SIZE)
self.CAM.start()
...
img = self.CAM.get_image()
...
pygame.image.save(self.SURF, path + name)

pygame.CaotinaCam.Portrait.Martin
pygame.CaotinaCam.Portrait.Martin()

 


(Ich weiß, die Werbung nervt. Und ich kann nicht einmal entscheiden, was hier gezeigt wird.)