Strange "add" behaviour

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?".
Langschwert
Posts: 17
Joined: 2013-08-19T12:04:09-07:00
Authentication code: 6789

Strange "add" behaviour

Post by Langschwert »

As so often - is it a bug or a feature? Or am I just entering the wrong commands? See the bright pixels that weren´t expected.

compose test3.png t1.png -compose add -layers flatten test2.png

Pic one: http://files.homepagemodules.de/b167881 ... 1561n2.png
added to
Pic two: http://files.homepagemodules.de/b167881 ... 1561n3.png

What it shlould look like (Paint.net): http://files.homepagemodules.de/b167881 ... 1561n5.png

What it does look like ImageMagick): http://files.homepagemodules.de/b167881 ... 1561n4.png

Wrong command or wrong calculation? ;)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Strange "add" behaviour

Post by fmw42 »

what version of IM and what platform?

use -compose plus and not -compose add. The latter will wrap around outside the quantrum range of your IM compile.

see
http://www.imagemagick.org/Usage/compose/#plus
http://www.imagemagick.org/Usage/compose/#modulus_add

modulusAdd is the new syntax for add, but the old syntax still works.
Langschwert
Posts: 17
Joined: 2013-08-19T12:04:09-07:00
Authentication code: 6789

Re: Strange "add" behaviour

Post by Langschwert »

Of course I alreday tried using plus. I should have mentioned that. It results in a plane white image with nothing but white at all. *sigh*
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Strange "add" behaviour

Post by snibgo »

What do you hope "-layers flatten", using whichever "-composite" you have specified, will do?
snibgo's IM pages: im.snibgo.com
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Strange "add" behaviour

Post by snibgo »

The first input (I call it pic1.png) is sRGB but the second (pic2.png) is RGB.

This is very close (3%) to Paint.net result:

Code: Select all

convert pic1.png pic2.png -compose screen -composite -auto-gamma -colorspace RGB p3s.png
snibgo's IM pages: im.snibgo.com
Langschwert
Posts: 17
Joined: 2013-08-19T12:04:09-07:00
Authentication code: 6789

Re: Strange "add" behaviour

Post by Langschwert »

Code: Select all

convert pic1.png pic2.png -compose screen -composite -auto-gamma -colorspace RGB p3s.png
Hey, that looks muuuch better - thank you. :)

Simple change for you - a miracle for me. ;)
Langschwert
Posts: 17
Joined: 2013-08-19T12:04:09-07:00
Authentication code: 6789

Re: Strange "add" behaviour

Post by Langschwert »

BTW - Problem solved - this thread might better be moved to "Noob questions" or so since it´s no bug. ;)

I do have a more complex question. I am creating skins for World of Tanks an am not content with the quality I produced yet.
See http://wot.langschwert.de

I am trying to go to complete automatic production - there I ran into a few problems since I am forced to use command line operations in good old Dos batches.

In theory it is quite simple.

There is a standard tank skin with no camo: http://files.homepagemodules.de/b167881 ... 1562n2.png

Then there is a shadow map that presents shadow an spares all parts that shouldn´t be painted like rubber an wood an so on: http://files.homepagemodules.de/b167881 ... 1562n3.png

And finally there is a camo pattern: http://files.homepagemodules.de/b167881 ... 1562n4.png

What I was doing till now is to multiply camo pattern an shadow map. That leaves a lot of black areas. http://files.homepagemodules.de/b167881 ... 1563n2.png

Then I used add to merge it with the original skin. The result is not satisfying at all. http://files.homepagemodules.de/b167881 ... 1563n3.png
Complete tank: http://files.homepagemodules.de/b167881 ... 1564n2.png

What I am looking for now is a better way to do it. The parts that are covered with black in the shadow map should remain untouched, and everything else should be covered - and shadowed - by the camo pattern in bright, original colors. How could I achieve this?

And second question: how could I do this using ImageMagick? Most of the command lines still are a mystery to me. Since all this should be done in a batch job there is no room for different parameters for each image, so I know that the results may differ from the source tanks but I have to live with that. It doesn´t have to be perfect but it should be better than all I managed to do myself. ;)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Strange "add" behaviour

Post by snibgo »

It looks as if you've got the basics. Windows script:

Code: Select all

%IM%convert ^
  tank_skin.png ^
  tank_camo.png ^
  tank_shadow.png ^
  -compose Over -composite ^
  -gamma 1.5 ^
  tank_out.png
The three input colorspaces are sRGB, so no need to convert them.

Another compose method may be better than "Over".

"-gamma 1.5" is a tweak to make it look more like the 3-D image.

Sorry, my time is limited today.
snibgo's IM pages: im.snibgo.com
Langschwert
Posts: 17
Joined: 2013-08-19T12:04:09-07:00
Authentication code: 6789

Re: Strange "add" behaviour

Post by Langschwert »

Perfect! Absolutely perfect! May I proclaim you to a demigod on trial? Image
Langschwert
Posts: 17
Joined: 2013-08-19T12:04:09-07:00
Authentication code: 6789

Re: Strange "add" behaviour

Post by Langschwert »

Here first results of your kindly given hints. It´s all your fault now. :D

Just click any of the listed links containing a version number:
http://167881.homepagemodules.de/f42-Ko ... -sets.html
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Strange "add" behaviour

Post by snibgo »

Good stuff. Thanks for sharing the results.
snibgo's IM pages: im.snibgo.com
Langschwert
Posts: 17
Joined: 2013-08-19T12:04:09-07:00
Authentication code: 6789

Re: Strange "add" behaviour

Post by Langschwert »

Things are working great. :)

I still have a little problem not concerning ImageMagick. Ich have to convert the results do .dds - I use PNG2DDS by EasyConvert. It is working fine but it opens a new window and closes it every time it is started. Since that is every two seconds for about half an hour (batch processing) the computer becomes unusable for that time. Do you have any idea how to keep PNG2DDS from doing so? Just keeping in in the background?
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Strange "add" behaviour

Post by dlemstra »

I am working on adding support for writing dds files (DTX1/5) to ImageMagick, I have no idea when this will be finished, might take a couple of weeks or even months.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Langschwert
Posts: 17
Joined: 2013-08-19T12:04:09-07:00
Authentication code: 6789

Re: Strange "add" behaviour

Post by Langschwert »

Make it just a few hours, just to please me. Image
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Strange "add" behaviour

Post by dlemstra »

Making it will probably just take a few hours :) But I don't know when I will be able to spend time on it so you still have to wait that long.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
Post Reply