6

I'm curious - is it possible to ahieve in PHP:

1) Send image file to server 2) Process image = detect edges and create simple strokes basing on the edges 3) Save file on server / send it to user's browser / whatever

Here is some "sample" file ;P (as You can see it wasn't made using any edge detection enabled program, but by hand - just as an example):

http://i51.tinypic.com/5vzo0x.jpg Thanks!

Paul
  • 1,928
  • 8
  • 24
  • 32
  • 7
    I just realised how awful this arrow is... – Paul Oct 30 '10 at 10:21
  • Google on edge detection algorithm and you'll be happy :]. But wait, the GD library for PHP is not very fast; slow actually – Harmen Oct 30 '10 at 10:22
  • Shameless plug: here's a helpful guide for a noob install of ImageMagick (and GhostScript): http://stackoverflow.com/questions/3243361/pdf-convert-with-imagemagick-and-ghostscript-on-windows-vista-7-x64 – Ben Oct 30 '10 at 10:29
  • 1
    your arrow is upholding the great tradition of [freehand circles](http://meta.stackexchange.com/questions/19478/the-many-memes-of-meta/19775#19775) and is therefore more than fine! :) – Pekka Oct 30 '10 at 10:30

1 Answers1

11

If you can use ImageMagick, there is the --charcoal filter:

The charcoal effect is meant to simulate artist's charcoal sketch of the given image.

The "-charcoal" operator is in some respects similar to edge detection transforms used by Computer Vision. Basically it tries to convert the major borders and edges of object in the image into pencil and charcoal shades.

The one argument is supposed to represent the thickness of the edge lines.

The ImageMagick examples manual shows another way whose results look even better:

Artist Charcoal Sketch of Image

alt textalt text

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • I've found piece of code I'm interested in (thanks!) but have no idea how to run it in php :/ – Paul Oct 30 '10 at 11:28
  • convert holocaust_sm.jpg \ -edge 1 -negate -normalize \ -colorspace Gray -blur 0x.5 -contrast-stretch 0x50% \ color-in.gif – Paul Oct 30 '10 at 11:29
  • 1
    @Paul you need ImageMagick installed on your server, and to be able to run it from within PHP. See an example here: http://stackoverflow.com/questions/2582658/to-imagemagick-php-exec – Pekka Oct 30 '10 at 11:30