Action abstraction

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
xpt
Posts: 59
Joined: 2010-10-06T20:18:24-07:00
Authentication code: 8675308

Action abstraction

Post by xpt »

Hi,

I coined this term "action abstraction" for not knowing a better phrase to describe what I want to do.

I want to remove as much details as possible from images so as just to preserver the "main action". Take a look the following images then you may understand what I'm talking about:

http://imagebin.ca/view/JFiG6TZ.html
http://imagebin.ca/view/M6Z7FeQ.html

The ideal result would be, a BW cartoon image with no (gray) tones. Details are remove as much as possible as long as the major elements are there (I don't even care if nothing is left on their face).

I know there are many photo to sketch scripts out there, but nothing come close to the abstraction level that I want now. I know it's not an easy job, so I need your help.

I've prepared a set of 16 images for you to test/try on, some are easy and some are more difficult, but not in any special order. The above 2 being two of them. I've upload the set to:

http://www.zshare.net/download/811736231ff4e200/
http://www.megaupload.com/?d=5F0VYKE8
http://depositfiles.com/en/files/pqy1jcd76
http://www.badongo.com/file/24286807

Any one of above link will do (all have the same 1.01MB file 'action-abstract.rar'). Please note that I don't have any account there, so the file might be gone in several days. Please try to grab a copy as early as you can.

xpt
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Action abstraction

Post by fmw42 »

try


convert Action-Abstract-01.jpg -monochrome Action-Abstract-01_mono.gif
xpt
Posts: 59
Joined: 2010-10-06T20:18:24-07:00
Authentication code: 8675308

Re: Action abstraction

Post by xpt »

fmw42 wrote:try


convert Action-Abstract-01.jpg -monochrome Action-Abstract-01_mono.gif
Actually, I was kinda expecting something even better than this,

http://www.imagemagick.org/Usage/photos/#color-in

well, maybe that's the best I can get so far.

thanks all the same.
xpt
Posts: 59
Joined: 2010-10-06T20:18:24-07:00
Authentication code: 8675308

Re: Action abstraction

Post by xpt »

This is the best that I can get from Action-Abstract-01.jpg,

Image

Anyone can get it better?

Thanks
xpt
Posts: 59
Joined: 2010-10-06T20:18:24-07:00
Authentication code: 8675308

Re: Action abstraction

Post by xpt »

If use

Code: Select all

convert Action-Abstract-01.jpg -colorspace gray -lat 20x20+3% output.gif
I'll get

Image

which size is bigger than the previous one (8345B vs. 7358B).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Action abstraction

Post by fmw42 »

try adding -depth 2 -type bilevel

convert Action-Abstract-01.jpg -colorspace gray -lat 20x20+3% -depth 2 -type bilevel Action-Abstract-01_tmp1.gif

result is Filesize: 7.46KB

original jpg is Filesize: 29.1KB


or you can strip all the textual info

convert Action-Abstract-01.jpg -strip -colorspace gray -lat 20x20+3% -depth 2 -type bilevel Action-Abstract-01_tmp2.gif

result is Filesize: 6.44KB
xpt
Posts: 59
Joined: 2010-10-06T20:18:24-07:00
Authentication code: 8675308

Re: Action abstraction

Post by xpt »

fmw42 wrote:try adding . . .

result is Filesize: 6.44KB
Thanks a lot, that's amazing.
xpt
Posts: 59
Joined: 2010-10-06T20:18:24-07:00
Authentication code: 8675308

Re: Action abstraction

Post by xpt »

Ok, I found another way, here is the result:

Image

The command is:

Code: Select all

convert Action-Abstract-01.jpg -colorspace gray \( +clone -blur 0x2 \) +swap -compose divide -composite -linear-stretch 5%x0% photocopy.gif
However, I wasn't able to make it of BW color depth of 2, I tried

Code: Select all

convert Action-Abstract-01.jpg -colorspace gray \( +clone -blur 0x2 \) +swap -compose divide -composite -linear-stretch 5%x0% -monochrome -depth 2 -type bilevel  photocopy.png
convert Action-Abstract-01.jpg -colorspace gray \( +clone -blur 0x2 \) +swap -compose divide -composite -linear-stretch 5%x0% -depth 2 -type bilevel  photocopy.png
convert Action-Abstract-01.jpg -colorspace gray \( +clone -blur 0x2 \) +swap -compose divide -composite -linear-stretch 5%x0% -depth 2 photocopy.png
but all end up with distorted image. Please help.

Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Action abstraction

Post by fmw42 »

that is because you have a grayscale image and any method of binarizing it will not keep the grays as they were.

You can take your image and threshold it at some percent that looks good, then try

+dither -colors 2 -depth 2 -type bilevel result.gif

NOTE use GIF as it supports bilevel, but I am not sure PNG will do that.
xpt
Posts: 59
Joined: 2010-10-06T20:18:24-07:00
Authentication code: 8675308

Re: Action abstraction

Post by xpt »

fmw42 wrote:+dither -colors 2 -depth 2 -type bilevel result.gif
Perfect! Thanks a lot!

PS. Here is how it looks now:

Image

Here is how it is converted:

Code: Select all

convert Action-Abstract-01.jpg -colorspace gray \( +clone -blur 0x3 \) +swap -compose divide -composite -linear-stretch 5%x0% +dither -colors 2 -depth 2 -type bilevel result3.gif
Thanks again.
Post Reply