Page 3 of 5
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T17:32:49-07:00
by ProGamer
fmw42 wrote: ↑2017-01-28T15:16:19-07:00
If you need more input images, just append them first and use that as the reference image. If you need to apply one image's color to many output images, then you would need to write a script over all the output images.
Code: Select all
convert image1 image2 image3 ... -append miff:- | transfercolor <arguments> - output
I need to input more images to from which the color will be transferred to, while there is still a single image that the color is applied to. The later can be done by running the script more than once.
Does the convert command accept images separated by commas? And can you explain how your code snipped works? I don't really have experience with the -append parameter and "miff". Are you creating a ".miff" image that is composed multiple images, to use with the script?
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T18:12:04-07:00
by fmw42
Are you creating a ".miff" image that is composed multiple images, to use with the script?
Yes, it just stacks them vertically into one new image in miff format. Then the miff image is piped to the script as input. I have not tested the pipe into transfercolor. It may not work. If that is the case, then you will need to append and save the result as a new image in a non-compressed format, such as PNG or TIFF or even as a named miff file (imagename.miff). Then call transfercolor in a second command using the named image as input rather than the pipe input from the "-" (minus sign).
See
http://www.imagemagick.org/Usage/layers/#append. I assume all your images are the same size. If not, then the append will pad with whatever color you want and that may change the statistics.
If you do not have same sized inputs, then I will have to modify the script to gather statistics from multiple images and merge them into one mean and std.
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T18:21:43-07:00
by fmw42
The piping does not work. So you will have to make it two commands. The first to append and save to an output image. And the second to use transfercolor.
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T18:36:07-07:00
by snibgo
fmw42 wrote:I assume all your images are the same size. If not, then the append will pad with whatever color you want and that may change the statistics.
Instead of appending entire images, the inputs can be chopped into lines, and these appended horizontally. This creates a wide Nx1 image, with no "invented" pixels.
Code: Select all
convert in1.png in2.png in3.png -crop x1 +append +repage out.png
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T18:36:28-07:00
by fmw42
If your images are not the same size, you can still append them with a transparent background to fill in. I can then modify my script to compute the mean and std so as to ignore the transparent pixels. Let me know if this is needed.
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T18:37:29-07:00
by fmw42
snibgo wrote:Instead of appending entire images, the inputs can be chopped into lines, and these appended horizontally
Good point. But it may be better to use -append, since some image formats restrict to some maximum width. However, one could save to miff format in this case, since I don't think miff has that restriction. I do not know about PNG.
So there are now at least two ways to solve the issue.
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T18:48:57-07:00
by snibgo
IM doesn't like images wider than 10,000,000 pixels (on my computer). For some statistics, resizing or scaling down first will give good-enough results.
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T18:59:26-07:00
by ProGamer
fmw42 wrote: ↑2017-01-28T18:36:28-07:00
If your images are not the same size, you can still append them with a transparent background to fill in. I can then modify my script to compute the mean and std so as to ignore the transparent pixels. Let me know if this is needed.
For the airplane image and the other image, I used 3 gigapixel style images from Google's Art Project that are: 30000x20922 30000x20857 30000x18840, in size. But the sizes can change if I am using different style images, and I have used 245 styles in one case before, but using that many style images is probably more of an extreme use case. So I guess that modifying the script is the best option at the moment.
snibgo wrote: ↑2017-01-28T18:36:07-07:00
fmw42 wrote:I assume all your images are the same size. If not, then the append will pad with whatever color you want and that may change the statistics.
Instead of appending entire images, the inputs can be chopped into lines, and these appended horizontally. This creates a wide Nx1 image, with no "invented" pixels.
Code: Select all
convert in1.png in2.png in3.png -crop x1 +append +repage out.png
This resulted in the following output for my 3 gigapixel images:
Code: Select all
ubuntu@ip-Address:~/neural-style$ convert Canaletto_-_Bucentaur.jpg Sandro_Botticelli_-_La_nascita_di_Venere_-_Google_Art_Project_-_edited.jpg russian_-_Google_Art_Project.jpg -crop x1 +append +repage out.png
convert: Image width exceeds user limit in IHDR `out.png' @ warning/png.c/MagickPNGWarningHandler/1671.
convert: Invalid IHDR data `out.png' @ error/png.c/MagickPNGErrorHandler/1645.
ubuntu@ip-Address:~/neural-style$
And the same error for small style images:
Code: Select all
ubuntu@ip-Address:~/neural-style$ convert a4a4d328101435.5636fa70c7fc0.7d87a428101435.5636fa70d1bed.jpg -crop x1 +append +repage out.png
convert: Image width exceeds user limit in IHDR `out.png' @ warning/png.c/MaPNGWarningHandler/1671.
convert: Invalid IHDR data `out.png' @ error/png.c/MagickPNGErrorHandler/164
ubuntu@ip-Address:~/neural-style$
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T19:20:36-07:00
by snibgo
I suggest you resize so the input is no more than, say, 100,000 pixels. For calculating mean and standard deviation, this won't make a significant difference.
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T20:02:59-07:00
by ProGamer
snibgo wrote: ↑2017-01-28T19:20:36-07:00
I suggest you resize so the input is no more than, say, 100,000 pixels. For calculating mean and standard deviation, this won't make a significant difference.
So testing this out, created this output:
https://i.imgur.com/EYa7fos.jpg
I made the image to transfer the color from like this:
Code: Select all
convert Canaletto_-_Bucentaur.jpg Sandro_Botticelli_-_La_nascita_di_Venere_-_Google_Art_Project_-_edited.jpg russian_-_Google_Art_Project.jpg -crop x1 +append +repage -resize 100000 linecolor.png
Code: Select all
./transfercolor.sh -c rgb neuraldream_0.png line.png neuraldream_0_linecolor_rgb.png
./transfercolor.sh -c rgb neuraldream_1.png line.png neuraldream_1_linecolor_rgb.png
./transfercolor.sh -c rgb neuraldream_2.png line.png neuraldream_2_linecolor_rgb.png
./transfercolor.sh -c rgb neuraldream_3.png line.png neuraldream_3_linecolor_rgb.png
I guess this doesn't bode well for Fred's idea of a modified transfercolor script? Or will that create a different?
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T20:47:28-07:00
by fmw42
You list linecolor.png in the first convert command, but you use line.png in the transfercolor script. Are these the same images?
I do not know if it will make a difference or not unless I change it. But what snibgo said is true, small changes in the statistics won't really make much difference. So if all your convert input images have very close statistics, the results from using only one and from using all of them won't be too different. You should look at the mean and std of each of your input images using
or
Code: Select all
convert image -format "mean=%[mean] std=%[standard_deviation]" info:
and see how different they are.
Also when comparing your result, you should look at the result and the individual tiles at the same scale factor.
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T20:53:52-07:00
by fmw42
Send me your direct email address (via PM on the forum if you want it private) and I will email your a modified version of the script that ignores transparency in the input images when computing statistics, so that you can append image of different sizes with transparent background. I will let you experiment and if it works, then I will modify the documentation to reflect the changes.
Code: Select all
convert image1 image2 image3 ... -background none -append result
You may still want to scale the images, as snibgo pointed out, to have a smaller appended input, if the size is too large.
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T21:10:01-07:00
by ProGamer
fmw42 wrote: ↑2017-01-28T20:47:28-07:00
You list linecolor.png in the first convert command, but you use line.png in the transfercolor script. Are these the same images?
They are the same image.
fmw42 wrote: ↑2017-01-28T20:47:28-07:00
So if all your convert input images have very close statistics, the results from using only one and from using all of them won't be too different. You should look at the mean and std of each of your input images using
or
Code: Select all
convert image -format "mean=%[mean] std=%[standard_deviation]" info:
and see how different they are.
Also when comparing your result, you should look at the result and the individual tiles at the same scale factor.
Ok, I'll try looking at the mean and std.
fmw42 wrote: ↑2017-01-28T20:53:52-07:00
Send me your direct email address (via PM on the forum if you want it private) and I will email your a modified version of the script that ignores transparency in the input images when computing statistics, so that you can append image of different sizes with transparent background. I will let you experiment and if it works, then I will modify the documentation to reflect the changes.
Code: Select all
convert image1 image2 image3 ... -background none -append result
You may still want to scale the images, as snibgo pointed out, to have a smaller appended input, if the size is too large.
I sent you a PM.
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T21:21:25-07:00
by fmw42
Check your direct email for my modified script.
Re: Correcting tile luminance and/or color differences?
Posted: 2017-01-28T22:15:42-07:00
by ProGamer
fmw42 wrote: ↑2017-01-28T20:47:28-07:00
So if all your convert input images have very close statistics, the results from using only one and from using all of them won't be too different. You should look at the mean and std of each of your input images using
or
Code: Select all
convert image -format "mean=%[mean] std=%[standard_deviation]" info:
and see how different they are.
Also when comparing your result, you should look at the result and the individual tiles at the same scale factor.
For my "Neural Dream: output image:
https://i.imgur.com/UedL6gc.jpg
The order of the below outputs:
https://gist.github.com/ProGamerGov/93c ... file-order
The unprocessed tiles:
https://gist.github.com/ProGamerGov/93c ... an-and-std
https://gist.github.com/ProGamerGov/93c ... ssed-tiles
The processed tiles:
https://gist.github.com/ProGamerGov/93c ... an-and-std
https://gist.github.com/ProGamerGov/93c ... ssed-tiles
Originally styled output and the tiled outputs:
https://gist.github.com/ProGamerGov/93c ... an-and-std
https://gist.github.com/ProGamerGov/93c ... ed-outputs
Code used:
https://gist.github.com/ProGamerGov/93c ... -code-used
As for the style images, using Ubuntu on Virtualbox froze while trying to run the code on them:
https://commons.wikimedia.org/wiki/File ... roject.jpg
https://commons.wikimedia.org/wiki/File ... edited.jpg
https://commons.wikimedia.org/wiki/File ... roject.jpg
The 3rd image has a weird URL due to Russian characters in the name.
I used the 30,000 image version (the largest one) for the style images, but the size might not be important? I'll see about getting the outputs for the style images.