From photo to drawing (result is not really good)

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
libo
Posts: 5
Joined: 2018-05-01T02:54:30-07:00
Authentication code: 1152

From photo to drawing (result is not really good)

Post by libo » 2018-05-01T03:02:25-07:00

Hi all,
I'm trying to convert a photo to a drawing with ImageMagick.
The result is good but still not as the result I obtain in photoshop.

At this url http://supercolored.com/ you can find:
  • the original image
  • the result using photoshop and the steps i followed
  • the result using ImageMagick and the script I'm useing
Is there a way to close the ImageMagick result to the Photoshop result?
I'm trying many different ways but without results.

Thank you

snibgo
Posts: 10551
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: From photo to drawing (result is not really good)

Post by snibgo » 2018-05-01T04:36:00-07:00

libo wrote:-colorspace gray -separate -average
When an image is grayscale, separating the channels and taking their average won't change anything. (Because if you have three numbers that are the same, taking their average makes the same number.)

The Photoshop version is taking the minimum of two images. What images?

You have an edge detector, but the IM version uses a large blur.

This Windows BAT script gives a very similar result:

Code: Select all

convert ^
  castle.jpg ^
  -colorspace gray -colorspace sRGB +write mpr:GR ^
  ( -clone 0 -negate -blur 0x2 ) ^
  -compose ColorDodge -composite ^
  -auto-level ^
  -evaluate Pow 2.4 ^
  ( mpr:GR +level 80%%,120%% ) ^
  -compose Darken -composite -colorspace sRGB ^
  out.png
Tweaking the numbers may give an even closer result.
snibgo's IM pages: im.snibgo.com

libo
Posts: 5
Joined: 2018-05-01T02:54:30-07:00
Authentication code: 1152

Re: From photo to drawing (result is not really good)

Post by libo » 2018-05-01T05:45:26-07:00

Thank you for your help.
The Photoshop version is taking the minimum of two images. What images?
It's from the first level and the duplicate level

I did a new page with:
- image on the left: photoshop result
- centered image: your proposal
- image on the right: my new script I reported in the page

http://supercolored.com/new.php

All are still far from a good result...

snibgo
Posts: 10551
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: From photo to drawing (result is not really good)

Post by snibgo » 2018-05-01T07:56:27-07:00

I've uploaded my result from my script to: http://snibgo.com/imforums/castle_p2.png

Image
To me, it looks more like the Photoshop version than either other version.
snibgo's IM pages: im.snibgo.com

libo
Posts: 5
Joined: 2018-05-01T02:54:30-07:00
Authentication code: 1152

Re: From photo to drawing (result is not really good)

Post by libo » 2018-05-01T08:56:11-07:00

You are right. That is perfect.
Did you change anything to your script?

Here my image http://supercolored.com/new.php
I removed any resize or image optimization.
The script now is just like your: -colorspace gray -colorspace sRGB +write mpr:GR \( -clone 0 -negate -blur 0x2 \) -compose ColorDodge -composite -auto-level -evaluate Pow 2.4 \( mpr:GR +level 80%%,120%% \) -compose Darken -composite -colorspace sRGB

It could depend by the fact that I'm generating the image through php on a linux server?

snibgo
Posts: 10551
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: From photo to drawing (result is not really good)

Post by snibgo » 2018-05-01T09:27:22-07:00

In your version, the lines are similar to mine, but the tones are darker. This suggests the "+level" is working differently. Windows BAT scripts need the % doubled to %%. Bash doesn't, so change those to single %.

You probably don't need either "-colorspace sRGB", but they should be harmless.

What version IM do you use? I tested my script on v6.9.5-3 and (using "magick") under v7.0.7-28.

No, I didn't resize. That is probably best left until the end.
snibgo's IM pages: im.snibgo.com

libo
Posts: 5
Joined: 2018-05-01T02:54:30-07:00
Authentication code: 1152

Re: From photo to drawing (result is not really good)

Post by libo » 2018-05-01T10:01:37-07:00

Version: ImageMagick 6.7.2-7 2017-03-22 Q16

Changed the script in this way: -colorspace gray -colorspace sRGB +write mpr:GR \( -clone 0 -negate -blur 0x2 \) -compose ColorDodge -composite -auto-level -evaluate Pow 2.4 \( mpr:GR +level 80%,120% \) -compose Darken -composite
Result is worst in my opinion.

http://supercolored.com/new.php

snibgo
Posts: 10551
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: From photo to drawing (result is not really good)

Post by snibgo » 2018-05-01T10:22:25-07:00

libo wrote:6.7.2-7
That is ancient, and probably at the time when IM confused "sRGB" with "RGB". Try removing both occurrences of "-colorspace sRGB". If that doesn't help, I suggest you upgrade.

But I suggest you upgrade anyway. If you have many scripts, upgrade to the latest v6. Otherwise, upgrade to v7.
snibgo's IM pages: im.snibgo.com

libo
Posts: 5
Joined: 2018-05-01T02:54:30-07:00
Authentication code: 1152

Re: From photo to drawing (result is not really good)

Post by libo » 2018-05-01T10:35:23-07:00

Try removing both occurrences of "-colorspace sRGB"
It works!! :)

About update to another version, I think it is not possible on my vpn

Post Reply