Page 2 of 3

Re: Remove too dark photos from batch

Posted: 2016-04-12T04:19:56-07:00
by snibgo
That's it. You just need the convert. With the arguments you have, it converts file1 to match the statistics of file2.

Code: Select all

convert file1.jpg -function Polynomial $gain,$bias out.jpg

Re: Remove too dark photos from batch

Posted: 2016-04-12T09:48:50-07:00
by salmen
Terrific! One step further.
Out of curiosity, what is the PS equivalent to this? If there is any?

Re: Remove too dark photos from batch

Posted: 2016-04-12T09:59:48-07:00
by fmw42
I don't think PS has such a function that uses gain and bias as multiplier and addition. The closest I know is just contrast-brightness sliders.

You can also do this with -color-matric by adjusting the diagonal. In PS, that would be the channel mixer.

see
http://www.imagemagick.org/script/comma ... lor-matrix

Re: Remove too dark photos from batch

Posted: 2016-04-13T11:03:40-07:00
by salmen
The scripting is getting a bit cumbersome for me and I am thinking about trying imagemagick using another language. Took a look at python and wand but it does not seem to support many functions (though I gather you can work around it). Is it possible to recommend another language? I do not know any of the ones listed, so preferably easy to learn and with good support of IM.
Thanks

Re: Remove too dark photos from batch

Posted: 2016-04-13T11:08:22-07:00
by fmw42
My belief is that most of the other APIs are far behind in their functionality compared to the command line. The two that might have the most besides MagickCore (which is likely up to date) are probably Perlmagick or Magick.NET. But I do not use any of them. So one of the developers would likely need to comment.

Re: Remove too dark photos from batch

Posted: 2016-04-13T13:42:32-07:00
by salmen
Ok, thanks. Also found this:
https://github.com/aheckmann/gm
But not getting anywhere with it

Re: Remove too dark photos from batch

Posted: 2016-04-13T23:28:09-07:00
by salmen
Is it possible to do "identify" on the embedded preview of a dng.file? To speed up the process?
snibgo wrote:Shells are often bad at handling floating-point. Either use a calculator like bc, or do more calculation within IM, eg:

Code: Select all

identify -format "%[fx:mean>0.345?1:0]\n" filename
This returns 1 when the mean is greater than 0.345; otherwise it returns 0.

You may need to escape the ">".

Re: Remove too dark photos from batch

Posted: 2016-04-14T05:08:50-07:00
by snibgo
Yes, but you need to extract it first, eg:

Code: Select all

exiftool -Composite:PreviewImage -b myfile.dng >preview.jpg

Re: Remove too dark photos from batch

Posted: 2016-04-14T10:33:35-07:00
by salmen
Thanks!

Code: Select all

exiftool -b -PreviewImage -w _preview.jpg -ext dng .
in case someone googles here, the above worked for doing a batch in the same folder and naming them as the dng + _preview. It threw an error also: "Error: File format error - ./.__filename.dng" but the previews are available.
I am looking to sort out more images, got the very dark ones removed. Now I think I will prioritize the nice weather pictures. What would be a good way to distinguish between the attached photos? And maybe abit more subtle differences. Seems like the temperature is changing alot, maybe better than the standard deviation? Is compare the way to do it?
Niceweather
Notsonice

Re: Remove too dark photos from batch

Posted: 2016-04-14T11:22:18-07:00
by snibgo
Well, what is "nice weather"? To me, it is blue skies and high contrast. The hue of the sky won't change much, but the saturation will. Here I use the Chroma from HCL colorspace, on a scale of 0.0 to 1.0:

Code: Select all

f:\web\im>%IM%convert cons3.jpg -gravity North -crop x50%+0+0 +repage -colorspace HCL -format %[fx:mean.g] info:
0.254661

f:\web\im>%IM%convert cons4.jpg -gravity North -crop x50%+0+0 +repage -colorspace HCL -format %[fx:mean.g] info:
0.0418506
That's a very clear difference.

The standard deviation gives a measure of contrast. "-auto-gamma" makes the mean of both images 0.5.

Code: Select all

f:\web\im>%IM%convert cons3.jpg -gravity South -crop x50%+0+0 +repage -auto-gamma -format %[fx:standard_deviation] info:
0.146643

f:\web\im>%IM%convert cons4.jpg -gravity South -crop x50%+0+0 +repage -auto-gamma -format %[fx:standard_deviation] info:
0.0988983
The difference isn't so great, but it's probably enough to distinguish "nice" from "not nice".

Colour temperature can be measured as the ratio mean(red)/mean(blue):

Code: Select all

f:\web\im>%IM%convert cons3.jpg -gravity South -crop x50%+0+0 +repage -auto-gamma -format %[fx:mean.r/mean.b] info:
1.17196

f:\web\im>%IM%convert cons4.jpg -gravity South -crop x50%+0+0 +repage -auto-gamma -format %[fx:mean.r/mean.b] info:
1.00884

Re: Remove too dark photos from batch

Posted: 2016-04-14T15:28:38-07:00
by salmen
Makes sense, thought I'd give saturation a go but bash seems to hang from the following?

Code: Select all

chroma=$(convert "$file" -gravity North -crop x50%+0+0 +repage -colorspace HCL -format %[fx:mean.g] info:)

Re: Remove too dark photos from batch

Posted: 2016-04-14T15:37:46-07:00
by fmw42
chroma=$(convert "$file" -gravity North -crop x50%+0+0 +repage -colorspace HCL -format %[fx:mean.g] info:)
In unix, the %[...] needs to be quoted. Try

Code: Select all

chroma=$(convert "$file" -gravity North -crop x50%+0+0 +repage -colorspace HCL -format "%[fx:mean.g]" info:)

Re: Remove too dark photos from batch

Posted: 2016-04-15T03:50:50-07:00
by salmen
Thanks, lots of things to learn.. I am not getting anywhere with floats in bash. I can store the chroma, but not compare them

Code: Select all

refchroma=$(convert "$refimg" -gravity North -crop x50%+0+0 +repage -colorspace HCL -format "%[fx:mean.g]" info:)
chroma=$(convert "$file" -gravity North -crop x50%+0+0 +repage -colorspace HCL -format "%[fx:mean.g]" info:)
Then I would like to do something like diff=$(bc -l<< "$refchroma-$chroma"), but cant figure it out

Re: Remove too dark photos from batch

Posted: 2016-04-15T04:25:47-07:00
by snibgo
You could do calcs in IM, eg:

Code: Select all

refchroma=$(convert "$refimg" -gravity North -crop x50%+0+0 +repage -colorspace HCL -format "%[fx:mean.g]" info:)

diff=$(convert "$file" -gravity North -crop x50%+0+0 +repage -colorspace HCL -format "%[fx:$refchroma-mean.g]" info:)

Re: Remove too dark photos from batch

Posted: 2016-04-15T09:07:24-07:00
by fmw42
diff=$(bc -l<< "$refchroma-$chroma"),
try

Code: Select all

diff=$(echo "scale=6; ($refchroma-$chroma)/1" | bc)
The divide by 1 seems to be needed (for me) to force floating point results, despite the scale=6.

or in IM

Code: Select all

diff=$(convert xc: -format "%[fx:$refchroma-$chroma]" info:)