I have some photos of a person over a background. The clothes and the background are always the same but because of the different distance between the person, the light and the photographer in each image (the person has to move) there are some color variations.
The fact is that I would like to establish some kind of predefined color for the background, make the (slight) modification... and then the modification would affect all the image in the same way, so the colors would be more or less the same for all images. Is there any way to make this?
Modify one color... and all the others in the same way
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Modify one color... and all the others in the same way
please supply some links to examples to show us what you have and are trying to do. It is very hard to make recommendations without a clear understanding and specific examples to reference.
Re: Modify one color... and all the others in the same way
I'll try to explain the problem again using examples...
I have some images like these:
http://i875.photobucket.com/albums/ab31 ... ines/1.jpg
http://i875.photobucket.com/albums/ab31 ... ines/2.jpg
As you can see, it's the same person and the same clothes, but there are differences between the colors. I would like to have exactly the same colors, and I think that I could use the background color in the first image to make the global transformation in the second one, so it would have the colors of the first image. It would be something like a White balance, but in blue color. Is it possible?
I have some images like these:
http://i875.photobucket.com/albums/ab31 ... ines/1.jpg
http://i875.photobucket.com/albums/ab31 ... ines/2.jpg
As you can see, it's the same person and the same clothes, but there are differences between the colors. I would like to have exactly the same colors, and I think that I could use the background color in the first image to make the global transformation in the second one, so it would have the colors of the first image. It would be something like a White balance, but in blue color. Is it possible?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Modify one color... and all the others in the same way
see -color-matrix http://www.imagemagick.org/script/comma ... lor-matrix
you can just use the upper left 3x3 matrix part and take the ratio of the red, green and blue colors along the diagonal to make the transformation.
you might also try my histmatch script (link below), but I have not tried that on such images with only a few colors.
you can just use the upper left 3x3 matrix part and take the ratio of the red, green and blue colors along the diagonal to make the transformation.
you might also try my histmatch script (link below), but I have not tried that on such images with only a few colors.
Re: Modify one color... and all the others in the same way
When I use the 3x3 matrix way the results are quite strange, I think that it could be because of the unexpected values (4,18,45) that I get from the first image. These are the commands that I use:
R1=convert R_Olaf1.JPG[1x1+0+0] -format '%[fx:round(255*u.r)]' info:
G1=convert Olaf1.JPG[1x1+1+1] -format '%[fx:round(255*u.g)]' info:
B1=convert Olaf1.JPG[1x1+2+2] -format '%[fx:round(255*u.b)]' info:
matrix_blue_balance=[R1 0 0 0 G1 0 0 0 B1]
convert Olaf2.JPG -recolor "+matrix_blue_balance+" new_Olaf2.JPG
On the other way, I have tried to use the equivalent IM commands in the histmatch script but I don't know how to use the two last command lines:
* echo "P2 $len 1 $maxval\n ${lutArr[*]}" | convert - -scale 256x1! $tmpL
* convert $infile2 $tmpL -clut $outfile
Could you explain me the parameters or what I'm doing wrong?
Thanks in advance!
R1=convert R_Olaf1.JPG[1x1+0+0] -format '%[fx:round(255*u.r)]' info:
G1=convert Olaf1.JPG[1x1+1+1] -format '%[fx:round(255*u.g)]' info:
B1=convert Olaf1.JPG[1x1+2+2] -format '%[fx:round(255*u.b)]' info:
matrix_blue_balance=[R1 0 0 0 G1 0 0 0 B1]
convert Olaf2.JPG -recolor "+matrix_blue_balance+" new_Olaf2.JPG
On the other way, I have tried to use the equivalent IM commands in the histmatch script but I don't know how to use the two last command lines:
* echo "P2 $len 1 $maxval\n ${lutArr[*]}" | convert - -scale 256x1! $tmpL
* convert $infile2 $tmpL -clut $outfile
Could you explain me the parameters or what I'm doing wrong?
Thanks in advance!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Modify one color... and all the others in the same way
LeyreM wrote:When I use the 3x3 matrix way the results are quite strange, I think that it could be because of the unexpected values (4,18,45) that I get from the first image. These are the commands that I use:
R1=convert R_Olaf1.JPG[1x1+0+0] -format '%[fx:round(255*u.r)]' info:
G1=convert Olaf1.JPG[1x1+1+1] -format '%[fx:round(255*u.g)]' info:
B1=convert Olaf1.JPG[1x1+2+2] -format '%[fx:round(255*u.b)]' info:
matrix_blue_balance=[R1 0 0 0 G1 0 0 0 B1]
convert Olaf2.JPG -recolor "+matrix_blue_balance+" new_Olaf2.JPG
On the other way, I have tried to use the equivalent IM commands in the histmatch script but I don't know how to use the two last command lines:
* echo "P2 $len 1 $maxval\n ${lutArr[*]}" | convert - -scale 256x1! $tmpL
* convert $infile2 $tmpL -clut $outfile
Could you explain me the parameters or what I'm doing wrong?
Thanks in advance!
For -color-matrix, you need ratios of color values between the output and the input images. Ratios are in the range 0 to 1.
On Unix you color retrieval command should be
R1=`convert R_Olaf1.JPG[1x1+0+0] -format '%[fx:round(255*u.r)]' info:`
or
R1=$(convert R_Olaf1.JPG[1x1+0+0] -format '%[fx:round(255*u.r)]' info:)
You don't have to do the multiply by 255 or round as you need to get the values in the two images and take ratios.
I am not really sure that this will actually help or is the right command.
I cannot go into much description of how my histmatch works right now as I am very busy. But just download and run the script on your two images rather than borrowing code. See if it even works. I tried it on your images and the results were not as good as I would have like.
* echo "P2 $len 1 $maxval\n ${lutArr[*]}" | convert - -scale 256x1! $tmpL
takes an array of values and makes it into a 256x1 image as a look up table
* convert $infile2 $tmpL -clut $outfile
applies the lookup table to the input image.
see examples of -clut at http://www.imagemagick.org/Usage/color/#color_lut
also see http://www.imagemagick.org/Usage/color/#recolor (-recolor was renamed to -color-matrix and expanded)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Modify one color... and all the others in the same way
It looks like the differences in color are due to a difference is brightness across the whole image. Have you tried adjusting the brightness by using the ratio of the mean statistics between your two images. Or try my script bcmatch.
histmatch -c rgb 2.jpg 1.jpg 1_histmatch.jpg
http://www.fmwconcepts.com/misc_tests/c ... tmatch.jpg
bcmatch -c rgb 2.jpg 1.jpg 1_bcmatch.jpg
http://www.fmwconcepts.com/misc_tests/c ... cmatch.jpg
histmatch -c rgb 2.jpg 1.jpg 1_histmatch.jpg
http://www.fmwconcepts.com/misc_tests/c ... tmatch.jpg
bcmatch -c rgb 2.jpg 1.jpg 1_bcmatch.jpg
http://www.fmwconcepts.com/misc_tests/c ... cmatch.jpg
Re: Modify one color... and all the others in the same way
Hi, I think that maybe the best solution would be changing all the range colors using the gradient of the first image (Olaf1), as any change (a shadow, for example) in the pixels used to create the change-matrix could "destroy" the other images. On the other hand, it seems that my version doesn't allow me to use histmatch and bcmatch.
The problem is that it doesn't seem easy to create the gradients, as it's a RGB image. I'm trying to extract the gradient of each channel and then I could modify the channels separately to mix them later, but I'm having problems even with that, as all examples that I get are based on an image created using ImageMagick, not in a real one.
Any idea, please?
The problem is that it doesn't seem easy to create the gradients, as it's a RGB image. I'm trying to extract the gradient of each channel and then I could modify the channels separately to mix them later, but I'm having problems even with that, as all examples that I get are based on an image created using ImageMagick, not in a real one.
Any idea, please?