Is there a cli way of getting the average value of all the pixels in an image
for example – if i have an all black image, I would want to type:
*cmd* black-img.jpg
and the output will be 0 in the shell
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Oh, this is simple:
The command uses ImageMagick’s
convertto enforce scaling of the input image to a size 1×1 pixels. Output will be something like this for an 8-bit RGBA image:or this for an 8-bit sRGB image:
It represents the color value of the single-pixel image that was produced:
0,0:are the coordinates of this pixel: 1st row in 1st column.(151,161,212, 92)represent the R ed, G reen, B lue and A lpha values of the RGBA pixel.(229,226,229)represent the R ed, G reen and B lue values of the sRGB pixel.#97A1D45Cand#E5E2E5are the respective hex values.Now it’s your own job to compute this output into ‘a
'0'in the shell’ if it is a black pixel. 🙂