Page 4 of 5

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-28T22:50:32-07:00
by fmw42
Sorry, I did not mean for you to have to list all the verbose data. Just wanted you to compare the overall mean and std. I probably should have had you use "%[fx:mean]" and "%[fx:standard_deviation]" so that you get the normalized mean and std in the range of 0 to 1 or "%[fx:255*mean]" and "%[fx:255*standard_deviation]" to get values in the range of 0 to 255. Then just list these results to see how much variation you had between tiles and between the tiles and the result image.

I really do not need to see these. I just wanted you to have some idea whether it was worth using more than one image for the reference image in the transfercolor.

Also did using the new script make any difference to when you used snibgo's suggestion?

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T13:53:31-07:00
by ProGamer
fmw42 wrote: 2017-01-28T22:50:32-07:00 Sorry, I did not mean for you to have to list all the verbose data. Just wanted you to compare the overall mean and std. I probably should have had you use "%[fx:mean]" and "%[fx:standard_deviation]" so that you get the normalized mean and std in the range of 0 to 1 or "%[fx:255*mean]" and "%[fx:255*standard_deviation]" to get values in the range of 0 to 255. Then just list these results to see how much variation you had between tiles and between the tiles and the result image.

I really do not need to see these. I just wanted you to have some idea whether it was worth using more than one image for the reference image in the transfercolor.

Also did using the new script make any difference to when you used snibgo's suggestion?
The transfercolor2 script seems to result in this error constantly:

Code: Select all

ubuntu@ip-Address:~/neural-style/test$ convert 1200px-Canaletto_-_Bucentaur.jpg 1200px-Sandro_Botticelli.jpg russian.jpg -append -background transparent line.miff
ubuntu@ip-Address:~/neural-style/test$ ./transfercolor2.sh -c rgb neuraldream_3.png line.miff neuraldream_3_style.png
convert: divide by zero `0/0' @ error/fx.c/FxEvaluateSubexpression/2188.
convert: unknown image property "%[fx:0/0]" @ warning/property.c/InterpretImageProperties/3678.
convert: divide by zero `0/0' @ error/fx.c/FxEvaluateSubexpression/2188.
convert: unknown image property "%[fx:0/0]" @ warning/property.c/InterpretImageProperties/3678.
convert: divide by zero `0/0' @ error/fx.c/FxEvaluateSubexpression/2188.
convert: unknown image property "%[fx:0/0]" @ warning/property.c/InterpretImageProperties/3678.
ubuntu@ip-Address:~/neural-style/test$
The script is mean to take a bunch of images that have been appended together with a transparent background, right?

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T14:01:14-07:00
by ProGamer
Also, from my earlier post containing lots of data on the tiles, I noticed this:


Unprocessed tiles:

Code: Select all

Tile 0:  mean=27582.4 std=13036.9

Tile 1: mean=25540.2 std=14461.4

Tile 2: mean=27393.2 std=15110.1

Tile 3: mean=33869.1 std=11170.8

Processed Tiles:

Code: Select all

Tile 0: mean=26306.6 std=13965.7

Tile 1: mean=26522.1 std=14042.9

Tile 2: mean=26734.3 std=14085.8

Tile 3: mean=27101 std=14801.8
Notice tile 3, which has the farthest color space drift when compared with the other 3 tiles: https://i.imgur.com/gvhK5VQ.jpg

Unprocessed tile 3 is really far off of the other tiles, but it appears corrected when it's run through Neural-Style again. Though from viewing the output image, we know it's not corrected. So maybe the key is to modify the tiles before they are run through Neural-Style again?

This is assuming that the following code produced data that we can use:

Code: Select all

convert neuraldream_3.png -format "mean=%[mean] std=%[standard_deviation]" info:
For the originally styled image that was chopped into 2x2 tiles, you can clearly see that the styles appear to have been applied a bit differently to the area from which the 4th tile (tile 3) is from: https://i.imgur.com/m6JSfWS.png

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T14:07:17-07:00
by fmw42
The transfercolor2 script seems to result in this error constantly:
What is your IM version and platform? I think some variable is not getting computed, which could be due to an IM version difference.

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T14:09:47-07:00
by ProGamer
fmw42 wrote: 2017-01-29T14:07:17-07:00
The transfercolor2 script seems to result in this error constantly:
What is your IM version and platform? I think some variable is not getting computed, which could be due to an IM version difference.
The output of convert -version:

Code: Select all

Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-11-29

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T14:17:03-07:00
by fmw42
It may be due to your Unix system. Some need ! escaped to \!. So I am sending you via direct email a new version with that change. Let me know if that fixes the issue.

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T16:29:03-07:00
by ProGamer
fmw42 wrote: 2017-01-29T14:17:03-07:00 It may be due to your Unix system. Some need ! escaped to \!. So I am sending you via direct email a new version with that change. Let me know if that fixes the issue.
It's still giving the same error.

Here's the -xv output of trying to run the script:

https://gist.github.com/ProGamerGov/928 ... a2822bd5dc

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T18:14:00-07:00
by fmw42
See my new email to you. I think I have it fixed now.

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T19:01:14-07:00
by ProGamer
So trying this:

Code: Select all

convert 1200px-Canaletto_-_Bucentaur.jpg 1200px-Sandro_Botticelli.jpg russian.jpg -append -background transparent line.miff
And

Code: Select all

convert neuraldream_0.png neuraldream_1.png neuraldream_2.png neuraldream_3.png -append -background transparent line.miff
And then both lab and rgb:

Code: Select all

./transfercolor2.sh -c rgb neuraldream_3.png line.miff neuraldream_3_miff.png
./transfercolor2.sh -c rgb neuraldream_2.png line.miff neuraldream_2_miff.png
./transfercolor2.sh -c rgb neuraldream_1.png line.miff neuraldream_1_miff.png
./transfercolor2.sh -c rgb neuraldream_0.png line.miff neuraldream_0_miff.png

./transfercolor2.sh -c lab neuraldream_3.png line.miff neuraldream_3_miff.png
./transfercolor2.sh -c lab neuraldream_2.png line.miff neuraldream_2_miff.png
./transfercolor2.sh -c lab neuraldream_1.png line.miff neuraldream_1_miff.png
./transfercolor2.sh -c lab neuraldream_0.png line.miff neuraldream_0_miff.png
Am I using the script incorrectly? Because the outputs still look really similar and the same issue still exists.

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T19:03:13-07:00
by ProGamer
In a follow up to my previous post about the original tile 3 showing signs of drift, I tried this:


I did this for the original tile 3:

Code: Select all

convert 1200px-Canaletto_-_Bucentaur.jpg 1200px-Sandro_Botticelli.jpg russian.jpg -append -background transparent line.miff
./transfercolor.sh -c rgb neuraldream_3.png line.miff neuraldream_3_style.png
And now the mean and std are changed:

Code: Select all

convert neuraldream_3_style.png -format "mean=%[mean] std=%[standard_deviation]" info:

Tile 3: mean=27505.7 std=14772.3
The mean and std changed from:

Code: Select all

Tile 3: mean=33869.1 std=11170.8
The results are clearly visible in a side by side comparison of tile 3: https://i.imgur.com/uPy58J9.png

But tile 3 is still extremely visible even with this change.

Edit: The contents of this comment were not made with transfercolor2.sh

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T19:32:20-07:00
by ProGamer
Digging into the unmodified tiles, both original and processed:

Original tile 0, tile 3:

https://i.imgur.com/WNkYkIx.png

Processed tile 0, 3:

https://i.imgur.com/inLlp7I.png

Original tile 1, tile 2

https://i.imgur.com/YbFZfZT.png

Processed tile 0, 3:

https://i.imgur.com/3S7Lw9U.png

I am not sure what is creating the "white haze" that outlines online the 4th processed tile, as the original 4 tiles blend together perfectly. Do you see anything obvious in this data? Another clue to this puzzle is that the lab color space seems to work best for disguising the issue.

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T19:48:40-07:00
by fmw42
You must put -background none before -append. IM operators such as append must have their settings (-background) define before the operator. See if that makes any difference. Are your 4 tiles different sizes? If not, then the change for transparency will not matter. -background defaults to white for filling the "holes" in the append. You have a white fill and after appending you have set the background to transparent, which is too late in the command chain.

If you want to look at the appended image, replace the output format from .miff to .png in the convert append command.

Try this:

Code: Select all

convert 1200px-Canaletto_-_Bucentaur.jpg 1200px-Sandro_Botticelli.jpg russian.jpg -background transparent -append line.png

Code: Select all

./transfercolor.sh -c rgb neuraldream_3.png line.png neuraldream_3_style.png
You might want to use -c lab. I think it generally works better than rgb

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T19:58:29-07:00
by ProGamer
I tried to rethink this issue, and used a variety of words that I thought people with a similar issue might use when searching for a solution. I think I might be on to something here. Instead of trying to correct the 4th tile, I think there is an issue with the 3 other tiles.

I googled "white haze", and I saw someone correct what appeared to be a similar issue with their image in Photoshop. Then I found the corresponding tool they used, in GIMP: https://docs.gimp.org/en/gimp-tool-levels.html

So I edited tile 0: https://i.imgur.com/jp47027.jpg

And then tile 0 and tile 2: https://i.imgur.com/ano1xys.jpg

On the GIMP Levels tool, I changed the left most value to remove the "white haze":

Image

So what is the "white haze", and how can we remove it with ImageMagick.

So maybe we can modify the Red, Green and Blue color channels to fix the issue?

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T20:15:13-07:00
by fmw42
Imagemagick has similar tools for clipping the image/histogram. See -level or -contrast-stretch or my script levels.

If you modify each image separately, you might get a result that is not what you want. Perhaps you should modify one tile the way you want it to look visually using PS or IM -level etc. Then use transfercolor to modify each of the other 3 tiles. Then combine them into your final image.

Did you try my modified commands above putting -background transparent before -append?

Re: Correcting tile luminance and/or color differences?

Posted: 2017-01-29T20:20:38-07:00
by fmw42
The left side of the histogram slider in GIMP/PS adjust the black point graylevel and the right side adjusts the white point graylevel. This is a stretch to full dynamic range (or actual clipping) so that the darkest colors are black and the lightest colors are white. The iM tool -level is basically the same. You set the black point and the white point as -level blkpt,whitept,gamma.

The blkpt and whitept are in the range of your IM compile, so if Q16, the value would be in the range 0 to 65535 (not 0 to 255). But you can always convert the GIMP values from the range 0 to 255, to percent and use percent graylevel values in -level by adding % symbol.

See http://www.imagemagick.org/script/comma ... .php#level.

With -contrast-stretch, you can clip by percent count (not percent graylevel). See http://www.imagemagick.org/script/comma ... st-stretch