Brightness comparison and decrease highests

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Locked
User avatar
DynV
Posts: 18
Joined: 2011-05-23T07:16:09-07:00
Authentication code: 8675308
Location: Montreal, Canada

Brightness comparison and decrease highests

Post by DynV »

I have a set of images that I'd like to be low-brightness but some aren't. I'd like for a decrease of brightness of either of the following in order of preference:
  • the aforementioned point to be done automatically and I'd just provide the directory and percentage
  • a table/list with multiple items (for each image) of the file name, brightness mean, and perhaps the brightness standard deviation of the images for which I provide the directory then I can run a list of them in addition to normalization (say I'd like the upper quarter to be reduced, I'd pick the highest of the 3/4 (lowest) and make the average of each of the 1/4 equal to that one (ie: 15, 18, 21, 25, 28, 32, 33, 35 into 15, 18, 21, 25, 28, 32, 32, 32))
How can I do so?

Thank you kindly

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Brightness comparison and decrease highests

Post by fmw42 »

What is your ImageMagick version and platform? Syntax may differ. Can you post and example or two of your images to some free hosting service and put the URLs here.

See -brightness-contrast bri,con at https://imagemagick.org/script/command-line-options.php

Sorry, I am not following your second bullet point

User avatar
DynV
Posts: 18
Joined: 2011-05-23T07:16:09-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Brightness comparison and decrease highests

Post by DynV »

The images are mainly from Black Wallpapers: Free HD Download [500+ HQ] | Unsplash. I skip around a third of the brightest images on there but from what I downloaded, I'd like the highest brightness quarter to match the brightest of the 3/4, I gave an example in the OP point #2 in brightness percentage, the before & after the operation I'd like to be done. The table I'd like would look like this:
  • file name; brightness percentage; brightness standard deviation
  • wallpaper_97293.jpg; 23; 4
  • wallpaper_26655.jpg; 18; 3
  • wallpaper_55169.jpg; 32; 6
  • wallpaper_61836.jpg; 15; 2
  • wallpaper_96526.jpg; 21; 5
I though was already installed unfortunately it wasn't and I'm having trouble doing so, if you're interested you can see on Issues installing ImageMagick. Perhaps you can go on as it if there was the latest version Ubuntu 9.2.1 support.

Update 1:

It seems it was indeed installed properly. After doing
me@me-computer:~$ imagemagick --version
imagemagick: command not found
me@me-computer:~$ imagemagick
imagemagick: command not found
and with the response I assumed there were issues installing it. Well I just thought of something and did
me@me-computer:~$ man imagemagick
me@me-computer:~$ imagemagick -version
imagemagick: command not found
but I persisted and did
me@me-computer:~$ man imagemagick
me@me-computer:~$ man convert-im6.q16
me@me-computer:~$ convert-im6.q16 -version
Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib
and in bold is your answer.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Brightness comparison and decrease highests

Post by fmw42 »

Sorry, do not understand:
(say I'd like the upper quarter to be reduced, I'd pick the highest of the 3/4 (lowest) and make the average of each of the 1/4 equal to that one (ie: 15, 18, 21, 25, 28, 32, 33, 35 into 15, 18, 21, 25, 28, 32, 32, 32))

User avatar
DynV
Posts: 18
Joined: 2011-05-23T07:16:09-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Brightness comparison and decrease highests

Post by DynV »

Please see my lat post, since tables doesn't seem to work here, I make a list which points is equivalent to rows and what's between semicolons columns., and the 1st point corresponds to headers.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Brightness comparison and decrease highests

Post by snibgo »

@DynV: You could write a script that finds the mean of each image, then sorts these into increasing order, then processes the final quarter to reduce their brightness.
snibgo's IM pages: im.snibgo.com

User avatar
DynV
Posts: 18
Joined: 2011-05-23T07:16:09-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: Brightness comparison and decrease highests

Post by DynV »

How can I find that out using ImageMagick? Which program? It seem to include multiple ones.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Brightness comparison and decrease highests

Post by snibgo »

The ImageMagick command would be something like this, for each input file:

Code: Select all

magick toes.png -format "%[fx:mean], %f" info:
This writes text output, such as:

Code: Select all

0.488162, toes.png
The mean is a value between 0.0 (black) and 1.0 (white).

Then your script would sort the text file, and decide which images to adjust. Suppose you wanted to make the mean 0.3. Then you could multiply the RGB values of an image by 0.3/this_mean where "this_mean" is the mean value of the image:

Code: Select all

magick toes.png -evaluate Multiply %[fx:0.3/mean] out.png
snibgo's IM pages: im.snibgo.com

Locked