Page 1 of 1

Image to Sketch Diff. Result ..

Posted: 2012-06-19T14:36:30-07:00
by k00lhunt3rz
HI i am using a photoshop Technique to make sketch here is url

http://www.photoshopessentials.com/phot ... to-sketch/

and here is the Result of my image

http://imagepick.heliohost.org/images/Untitled-2.jpg

Using Photoshop

And here is the code

for my PHP FIle

Code: Select all

<?php
     

    $average = new Imagick("ph1.jpg");
    $average->modulateImage(100,0,100);
     $av=$average->clone();
$average->negateImage( FALSE, imagick::CHANNEL_ALL );
$average->gaussianBlurImage( 5,5,imagick::CHANNEL_ALL); 

$average->compositeImage($av,imagick::COMPOSITE_COLORDODGE,0,0,imagick::CHANNEL_ALL);

header('Content-type: image/jpeg');
echo $average;
    ?>
Here is the result

http://imagepick.heliohost.org/images/file.jpg

See the diff. i think its becase of gaussianBlurImage but i can't find the exact values to put i tried reading new technique for this but :'(

Please if anybody can help

Thanks

Re: Image to Sketch Diff. Result ..

Posted: 2012-06-19T14:53:19-07:00
by fmw42
In your blur, set the radius to 0 and the sigma to 5 or 12 as in the PS article or try values as best works out. By setting the radius=sigma you have truncated the gaussian. By setting the radius to 0, IM will then compute the optimal radius for a gaussian from the sigma. Normally this will about rad=3xsigma. If the result is not of enough contrast, then add -auto-level or -contrast-stretch 0 or -normalize and see if that helps.

Re: Image to Sketch Diff. Result ..

Posted: 2012-06-19T14:57:25-07:00
by k00lhunt3rz
actually my Math is very weak so when i openend Wikipedia in blur topic it showing sigma etc...


i will try your example and reply here if its not works then i will go for making a new algo for Blur in php


Thanks for Fast Reply

Re: Image to Sketch Diff. Result ..

Posted: 2012-06-19T16:09:40-07:00
by fmw42
Here is my command line code:

original
Image

convert original.jpg \
\( -clone 0 -modulate 100,0,100 \) \
\( -clone 1 -negate -blur 0x4 \) \
\( -clone 1 -clone 2 -compose color_dodge -composite -level 25x100% -write original_sketch_gray.jpg \) \
\( -clone 3 -clone 3 -compose multiply -composite \) \
\( -clone 0 -modulate 100,200,100 \) \
-delete 0-3 -compose screen -composite original_sketch2.jpg

Image

The intermediate grayscale sketch from the -write step
Image


Note in the last step I had to use -compose screen rather than -compose colorize as the IM -compose colorize and luminize seem to do something different than what Photoshop does with color and luminosity blend. Note these are complements, that is if the images are swapped you change from one to the other. To compensate and bring out more color I use -modulate in the step before it to enhance the saturation.

see
http://photoblogstop.com/photoshop/phot ... -explained

OK, I have a feeling that IM is using HSB colorspace to do the -compose colorize/luminize and it should be using -colorspace HSL. So I wrote my own manual swapping of the lightness with the grayscale image in HSL colorspace. Which is what photoshop says it does with blend of luminosity.


convert original.jpg \
\( -clone 0 -modulate 100,0,100 \) \
\( -clone 1 -negate -blur 0x4 \) \
\( -clone 1 -clone 2 -compose color_dodge -composite \) \
\( -clone 3 -alpha set -channel a -evaluate set 50% +channel \) \
\( -clone 3 -clone 4 -compose multiply -composite \) \
-delete 1-4 \
\( -clone 0 -colorspace HSL -channel RG -separate +channel +swap \) \
-delete 0 -reverse \
-set colorspace HSL -combine -colorspace sRGB -modulate 100,150,100 \
original_sketch10.jpg


Image


This is a bit better especially in the flower area. But, note I still had to use modulate to emphasize the coloring.

Re: Image to Sketch Diff. Result ..

Posted: 2012-06-19T22:22:06-07:00
by k00lhunt3rz
Really Thanks for this Sir

actually i was struggling for this from 2 days 24 Hours because i completed design of my Site but when it come to Converting photo i got stucked

Thanks :)

EDIT : I just tried it with my own pic & its same :D

Re: Image to Sketch Diff. Result ..

Posted: 2012-06-19T22:26:26-07:00
by fmw42
If it is not proprietary, could you show us our input and output examples.

Re: Image to Sketch Diff. Result ..

Posted: 2012-06-19T22:43:58-07:00
by k00lhunt3rz
Input
Image
Output (There are some dots)
Image

Its using Command line tool COnvert

i think the small dots are of pixels its also in original pic

Re: Image to Sketch Diff. Result ..

Posted: 2012-06-20T01:41:53-07:00
by k00lhunt3rz
bro what is the meaning of this line i mean what is doing above code i understood but this line making me confuse because php extension have some diff. functions

Code: Select all

\( -clone 1 -clone 2 -compose color_dodge -composite -level 25x100% -write original_sketch_gray.jpg \) \
is it like

Code: Select all


Take make clone of 1 and save it in 2 then compose a color_dodge -> ??
EDIT: Got it now its all fine

Once again really really Thanks :)