Page 1 of 1
How to get max saturation from image sequence
Posted: 2017-02-19T16:01:35-07:00
by Przemek89
I used
to get the brightest pixel and set it in OUT.jpg
Is it possible to do the same with saturation?
Get the most colorful pixel and set it in out.jpg...
Something like:
Code: Select all
convert *.jpg -maximumSaturation OUT.jpg
Re: How to get max saturation from image sequence
Posted: 2017-02-19T18:11:34-07:00
by snibgo
I can't see an easy way of doing this.
It is easy to set the output pixel to the highest saturation: just convert to HSL and select the saturation channel. But the output will contain only the saturation, not the hue and lightness.
Re: How to get max saturation from image sequence
Posted: 2017-02-19T18:24:33-07:00
by fmw42
I do not see any command -maximum for IM 6 or 7 at
http://www.imagemagick.org/script/comma ... ptions.php.
Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at
viewtopic.php?f=1&t=9620
For novices, see
viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
Re: How to get max saturation from image sequence
Posted: 2017-02-19T18:42:45-07:00
by snibgo
"-maximum" is there, though not in the contents at the top. [strike]I think it is a synonym for "-statistic maximum".[/strike]
What was I thinking? As Fred says below, it is "-evaluate-sequence max".
Re: How to get max saturation from image sequence
Posted: 2017-02-19T18:52:56-07:00
by fmw42
Thanks, snibgo. It is clearly an legacy command and I have never used it in all my years of using IM. But it says:
return the maximum intensity of an image sequence.
This would make me believe it was a synonym for -evaluate max.
I would suggest the OP use whatever is the proper current option that is consistent with what he is trying to do.
P.S. The porting guide for IM 7 says it is deprecated but allowed for now.
-maximum
Replaced by -evaluate-sequence Max.
Re: How to get max saturation from image sequence
Posted: 2017-02-19T18:59:54-07:00
by snibgo
Oops, yes, as you say. Corrected above.
Re: How to get max saturation from image sequence
Posted: 2017-02-19T21:10:13-07:00
by fmw42
You could try getting the max saturation and max brightness from colorspace HSL and combine that with any of your image's hue channel.
Code: Select all
convert *.jpg -colorspace HSB -channel g -separate -evaluate-sequence max maxsat.png
convert *.jpg -colorspace HSB -channel b -separate -evaluate-sequence max maxbri.png
convert anyimage.jpg -colorspace HSB -channel r -separate maxsat.png maxbri.png -set colorspace HSL -combine -colorspace sRGB result.png
This assume that all images are registered and are for the same scene.
I assume your IM version is not too old that -evaluate-sequence did not exist. If so, then use your -maximum.
Can you post about 6 of your images to some free hosting service such as dropbox.com and put the URLs here? Then we can test a few ideas.
Also what is your IM version and platform/OS, since syntax may differ.
Re: How to get max saturation from image sequence
Posted: 2017-02-20T07:33:54-07:00
by snibgo
@Przemek89: Can you provide some sample inputs? You can upload to somewhere like dropbox.com and paste URLs here. That will help us understand what you want.
If there are only two inputs, we can make an output where each pixel is taken from whichever source has the greatest saturation at that pixel. The method is: make an output of the saturation channel only, where this is the maximum. Compare this to the saturation of the first image. This gives us a mask which says whether the pixel should come from the first or second image, so we can do a masked composite.
We can iterate that method over (n) images: apply it to the first two images, then to the result of that and the third image, then the result of that and the fourth image, and so on.
That's the simplest way [EDIT: at the command level] I can think of to do what I think you want. If, instead, you want the saturation of each pixel to be the maximum of the inputs but the hue and lightness could come from any input, the method shown by Fred is simpler and faster.
EDIT: A simpler and quicker way would be to write a process module that does what "-evaluate max" does, but for saturation instead of lightness.
Re: How to get max saturation from image sequence
Posted: 2017-03-03T04:29:40-07:00
by Przemek89
@snibgo: I searched for "evaluate max" source code here:
https://github.com/ImageMagick/ImageMagick
but i coud not find it.
If code uses HSL model to get the brightest pixel from many images, it should not be complicated to change it to saturation.
Re: How to get max saturation from image sequence
Posted: 2017-03-03T08:44:34-07:00
by snibgo
See magick\statistic.c
EDIT: the v6 directory is "magick". The v7 directory is "MagickCore".
Re: How to get max saturation from image sequence
Posted: 2017-03-03T12:55:45-07:00
by Przemek89
Re: How to get max saturation from image sequence
Posted: 2017-03-03T13:30:49-07:00
by snibgo
Almost anything can be done with "-fx", provided you don't mind it taking a long time.
I have an idea for doing it in a single "convert", quickly and easily. But I have no inputs to test it on.
Re: How to get max saturation from image sequence
Posted: 2017-03-03T21:22:18-07:00
by snibgo
Okay, I created some inputs. The IM v6, Windows BAT syntax, command is:
Code: Select all
convert ^
maxsat_r.jpg maxsat_g.jpg maxsat_b.jpg ^
NULL: ^
( -clone 0--2 ^
-colorspace HCL -channel G -separate +channel ^
NULL: ^
( -clone 0--2 ^
-evaluate-sequence Max ^
) ^
-compose Difference -layers Composite ^
-fill White +opaque Black -negate ^
) ^
-compose CopyOpacity -layers Composite ^
-compose Over -layers Merge ^
maxsat_out.jpg
Replace my three inputs with any number of same-size images. I use JPEGs only for web performance.
I use the Chroma channel of HCL because I prefer it to HSL.
Inputs:
Output: