Page 1 of 3

Strange "add" behaviour

Posted: 2013-08-19T12:19:39-07:00
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? ;)

Re: Strange "add" behaviour

Posted: 2013-08-19T12:34:57-07:00
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.

Re: Strange "add" behaviour

Posted: 2013-08-19T12:42:27-07:00
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*

Re: Strange "add" behaviour

Posted: 2013-08-19T13:20:10-07:00
by snibgo
What do you hope "-layers flatten", using whichever "-composite" you have specified, will do?

Re: Strange "add" behaviour

Posted: 2013-08-19T13:30:20-07:00
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

Re: Strange "add" behaviour

Posted: 2013-08-19T13:58:54-07:00
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. ;)

Re: Strange "add" behaviour

Posted: 2013-08-20T03:01:47-07:00
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. ;)

Re: Strange "add" behaviour

Posted: 2013-08-20T08:43:55-07:00
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.

Re: Strange "add" behaviour

Posted: 2013-08-20T10:39:56-07:00
by Langschwert
Perfect! Absolutely perfect! May I proclaim you to a demigod on trial? Image

Re: Strange "add" behaviour

Posted: 2013-08-20T14:31:52-07:00
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

Re: Strange "add" behaviour

Posted: 2013-08-20T22:36:22-07:00
by snibgo
Good stuff. Thanks for sharing the results.

Re: Strange "add" behaviour

Posted: 2013-08-21T13:56:34-07:00
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?

Re: Strange "add" behaviour

Posted: 2013-08-21T22:19:07-07:00
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.

Re: Strange "add" behaviour

Posted: 2013-08-22T00:49:09-07:00
by Langschwert
Make it just a few hours, just to please me. Image

Re: Strange "add" behaviour

Posted: 2013-08-22T01:59:19-07:00
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.