Image analysis (histogramm, brightness, colour channels, etc. )

Hi!
How to get spectral analysis of images or values of brightness, colour channels or any other value to characterize an image?

I use Linux.
Thank you.

Thatā€™s a very vague and generic question.

I personally use OpenCV and/or rawpy to load in image data, and numpy to process it.

1 Like

ImageMagick can calculate loads of data about an image.

@Zener The best way to get a good response is to do some homework yourself and present what you have been working with: images, software, camera, computer, etc. The more information and files you send our way the more we can help you through the problem.

Hi Alanā€¦
Iā€™m trying to find similar pictures in order to group them (e.g. in darktable by a script lua).
Iā€™m using photils but itā€™s not enough and Iā€™d like probe other paramenter as in object.

Byeā€¦

As far as I know, raw processors donā€™t have object detection if that is what you are looking for. You still havenā€™t shown us any examples. Drag and drop a few images, some similar, others different, to illustrate what you mean by ā€œsimilarā€. That term can mean 1000 different things to 1000 different people. Having access to files also lets us show you what can be done.

1 Like

a






Well ā€¦
a and b are similar (without object recognition, similar color, exposition, histogramm ā€¦)
c, d and f are similar but different from a and b (similar color like green unlike a and b)
g has different color and exposition (more dark ā€¦)

So, without AI (Iā€™m alredy using photils but I accept suggestions) Iā€™m tryng to recognize images in similar situations.

regards ā€¦

I tryed by ImageMagick but I couldnā€™t find correct commandā€¦
might you help me about?

@snibgo has a neat website you may want to visit: im.snibgo.com. However, it may be a bit more on the technical/programming side, but since you are asking about processing I assume you can handle it. :stuck_out_tongue:

A basic command is:

magick zen1.jpeg -verbose info:

This gives numerical statistics about the mean, standard deviation and so on, per channel and overall.

More detail is available for histograms, features and moments, and perceptual hashes, and images can be compared for structural similarity.

I donā€™t know how useful this would be for you. I canā€™t immediately see any statistic that would give you simple answers.

1 Like

yesā€¦ thanksā€¦
butā€¦

How to extract each value?
For example, from
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
How to extract just each number?

You could try to check the sources of digikam to see what they do, what library of tool they use (of any).

Those number are metadata, and exiftool will extract that for any image that contains them, either as native tags in DNG or from an embedded ICC profile.

1 Like

Geeqie can find duplicates, and you can set the similarity threshold to ā€œlowā€.

How to extract each value?
For example, from
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
How to extract just each number?

Some of the numbers can be extracted as escapes like this:

magick yourfile.ext -format %[gamma] info:

See ImageMagick ā€“ Format and Print Image Properties

The chromaticities of the primaries are not available as escapes. You can obtain them from a shell script that parses the output of a magick command. In Windows, I would use ā€œforā€ to loop through the output.

IM doesnā€™t use primary chromaticities for anything. They are set to the sRGB primaries, however the image is actually encoded.

Or, if they are recorded as EXIF metadata, you can:

magick nok.tiff -format %[EXIF:PrimaryChromaticities] info:

Thank youā€¦
but I canā€™t understand how to extract info for each channel as follow:

Channel statistics:
Pixels: 314041
Red:
min: 237 (0.929412)
max: 255 (1)
mean: 254.976 (0.999906)
median: 255 (1)
standard deviation: 0.615749 (0.0024147)
kurtosis: 758.13
skewness: -27.2343
entropy: 0.00575536
Green:
min: 28 (0.109804)
max: 255 (1)
mean: 254.699 (0.998821)
median: 255 (1)
standard deviation: 7.78659 (0.0305357)
kurtosis: 758.75
skewness: -27.2673
entropy: 0.00499482
Blue:
min: 36 (0.141176)
max: 255 (1)
mean: 254.71 (0.998862)
median: 255 (1)
standard deviation: 7.51061 (0.0294534)
kurtosis: 758.847
skewness: -27.2687
entropy: 0.00499482

okā€¦good!
but Iā€™m looking for something to integrate in a lua script for darktable.
A command from shell can be usefulā€¦I canā€™t find it for that function of Geeqieā€¦

With IM, two ways,

You pipe the output to grep:

identify -verbose IMG_6919.JPG | grep -A 4 Chromaticity | grep -Eo '[0-9.]+'

yields:

0.64
0.33
0.3
0.6
0.15
0.06
0.3127
0.329

Howeverā€¦ using two very different pictures from my collection (including one which is almost monochrome) I get exactly the same values as what you show, so I wonder if IMā€™s output is correctā€¦

You ask IM politely

Reading between the lines in the doc there may be ways to ask the output of some specific values, however there is very little doc on this (may be ask on the ImageMagick forum).

Howeverā€¦ using two very different pictures from my collection (including one which is almost monochrome) I get exactly the same values as what you show, so I wonder if IMā€™s output is correctā€¦

As I said:

IM doesnā€™t use primary chromaticities for anything. They are set to the sRGB primaries, however the image is actually encoded.

A monochrome image may still be encoded as sRGB. If so, the primaries would be correct.

Within an IM command, we can change primaries, like this:

magick in.png -red-primary 0.1,0.2 -green-primary 0.3,0.4 out.png

But this merely changes metadata. It wonā€™t adapt the image pixel values to the new primaries.

okā€¦ Iā€™ve taken the array value of ā€˜Channel statistics:ā€™ but without signsā€¦
How to modify ā€œ| grep -Eo ā€˜[0-9.]+ā€™ā€ to have signs too?

Thank you so much.

P.S.
Excuse me but how can I register to IM forum?!?!?