Why one image gets affected better then another

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
Post Reply
naive
Posts: 9
Joined: 2018-04-26T23:53:58-07:00
Authentication code: 1152

Why one image gets affected better then another

Post by naive »

Hello all, Firstly i have to say that I'm a avid user of Imagemagick and am very thankful for the great work that you guys are doing to support this fantastic project!

I'm working with animated gifs to transform them into sort of line drawings, and i can't understand why one of them has really strong vivid colors while the other doesnt, maybe someone can help me out?

so my process of work is the following:
1. I take a color gif Image
2. I apply this - > convert gif.gif -morphology EdgeIn Octagon edgeinoctagon.gif
3. I receive effect like this Image

I tried the same process on this image:
Image
and got this:
Image

It's a similar effect but the colors are not as vivid as in the first one. I should mention that the first one is a gif of bigger size, so it probably contains more color information and less compression, but what could I do to make the second one, or any other image have the same vividness?

thanks so much for whoever can help me!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Why one image gets affected better then another

Post by snibgo »

naive wrote:It's a similar effect but the colors are not as vivid as in the first one.
The first input has "strong vivid colours", compared to the second. So the outputs have similar differences.

One measure of "strong vivid color" is chroma, the second channel of HCL. We can increase chroma like this (Windows BAT syntax):

Code: Select all

convert ^
  Screen_Shot_2018-04-27_at_10_08_03.png ^
  -colorspace HCL -channel G -evaluate Pow 0.3 +channel -colorspace sRGB ^
  -morphology EdgeIn octagon ^
  x.png
snibgo's IM pages: im.snibgo.com
naive
Posts: 9
Joined: 2018-04-26T23:53:58-07:00
Authentication code: 1152

Re: Why one image gets affected better then another

Post by naive »

Thanks Snibgo it worked really good, I experimented with different color channels and another one which was bringing the colors to the edge was HSI I'm running under Mac OS, so on LINUX the code for me was:

convert image.gif -colorspace HCL -channel G -evaluate Pow 0.3 +channel -colorspace sRGB -morphology EdgeIn Octagon HCLFSEdgeOct.gif

However now the image has so much compressions noise in black color, do you think there's a way to get rid of that?
Image
Is there a smart way to denoise the black color, or somehow to leave it unaffected?

Thanks again!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Why one image gets affected better then another

Post by snibgo »

You can change pixels that are near black to exactly black with "-black threshold 10%" after reading the input.

The input image Screen_Shot_2018-04-27_at_10_08_03.png has only 159 colours, probably has a result of a conversion to GIF, which can record only 256 colours. The image has dither patterns instead of smooth variations. A small blur, eg "-blur 0x1" smooths the dither away.

This also blurs edges within the image, which can be prevented by using an adaptive blur.

The best solution is to start from a better source, ie one that has not had colours reduced.
snibgo's IM pages: im.snibgo.com
naive
Posts: 9
Joined: 2018-04-26T23:53:58-07:00
Authentication code: 1152

Re: Why one image gets affected better then another

Post by naive »

Thanks for the patience
snibgo wrote: 2018-04-27T07:15:16-07:00 You can change pixels that are near black to exactly black with "-black threshold 10%" after reading the input.
By saying to apply the black-threshold after reading the input you mean smth like this? ->

convert gif.gif -black-threshold 10% -colorspace HCL -channel G -evaluate Pow 0.3 +channel -colorspace sRGB -morphology EdgeIn Octagon HCLFSEdgeOctBlack.gif

Because this just leaves me with a blank transparent image.. (I'm pasting it here, but you prob won't see it)
Image

And regarding the conversion, what about the first normal image with the girl, does it have better compression? What's better about that one, just curious to know, for the future so i could make better gif's hehe

here's the original ->
Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Why one image gets affected better then another

Post by snibgo »

naive wrote:By saying to apply the black-threshold after reading the input you mean smth like this?
Yes, like that. With the source you linked (Screen_Shot_2018-04-27_at_10_08_03.png) my GIF output is:
Image
It has 256 colours. When I save as PNG, that has 5450 colours.

Your animated GIF of a woman in a yellow dress has major variation in the background between frames, and GIF won't compress these well. After simplifying with morphology, I would expect compression to be better.
snibgo's IM pages: im.snibgo.com
Post Reply