• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Getting Image Luminosity from Histogram?

New Here ,
Mar 25, 2013 Mar 25, 2013

Copy link to clipboard

Copied

Is there any clean, easy way to do this? I'm trying to create a conditional script that only applies certain effects if the image is above a certain luminosity level.

Thank you for any help!

TOPICS
Actions and scripting

Views

1.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Guru ,
Mar 25, 2013 Mar 25, 2013

Copy link to clipboard

Copied

app.activeDocument.histogram is practical speaking the luminosity levels of the document. Are those values not close enough for what you need?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 10, 2017 Dec 10, 2017

Copy link to clipboard

Copied

app.activeDocument.histogram is the document's histogram which is a histogram of RGB channel

Refer to each channel to get its histogram, but I dont think it is a luminosity histogram

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

var hL = activeDocument.histogram; // this is the luminosity histogram

var hR = activeDocument.channels["Red"].histogram;

var hG = activeDocument.channels["Green"].histogram;

var hB = activeDocument.channels["Blue"].histogram;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

Description from ps cc js ref-2015.pdf (histogram property of Document):

A histogram showing the number of pixels at each color intensity level for the composite channel. The array

contains 256 members. Valid only when mode=DocumentMode.RGB, CMYK or INDEXEDCOLOR

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

https://forums.adobe.com/people/Pedro+Cortez+Marques  wrote

var hL = activeDocument.histogram; // this is the luminosity histogram

var hR = activeDocument.channels["Red"].histogram;

var hG = activeDocument.channels["Green"].histogram;

var hB = activeDocument.channels["Blue"].histogram;

Like Pedro wrote, I've always used the .histogram as Luminosity – for display purposes, mainly. Compared to the native Histogram palette, it seems like Photoshop is applying some sort of equalizing / thresholding in the display (e.g. mine left, PS right)

Davide Barranca - PS developer and author
www.ps-scripting.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

What do you want to get exactly and for what?

The histogram of the document displays the distribution of the luminosity of the pixels,

which corresponds to the formula (for sRGB) L = 0.299*R + 0.587*G + 0.114*B.

The RGB histogram that you see in the "Histogram" or "Levels/Curves" panel is the sum of the channel histograms,

that is, hstRGB = hstR + hstG + hstB .

If you want to get a histogram for Brightnes from HSB (== MAX(R,G.B)), you can use the HSL/HSB plugin to convert layer RGB->HSB and then take the histogram of channel[2].

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 14, 2017 Dec 14, 2017

Copy link to clipboard

Copied

thanks.

But after converting layer by the HSB/HSL filter I have still only R,G,B channels and my script says the same:

OutputHistogram(app.activeDocument.channels[2].histogram,app.activeDocument.channels[2].name, fileOut);

First lines of the generated file are(X is the scaled value, but the channel name counts here):

Channel name:Blue

000 X 29

001 X 1

002 X 1

003 X 4

004  0

005 X 34

006 X 2

007 X 2

008 X 1

009 X 4

010 X 3

...

channels[3] doesnt exist and in Channels panel are: RGB, R, G, B

I cant find histogram of brightness

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Dec 14, 2017 Dec 14, 2017

Copy link to clipboard

Copied

I did not understand anything, but I will clarify just in case )

After applying the RGB-> HSB filter

Hue is in channel R, respectively, the histogram of channel R is the histogram of Hue.

Saturation is in channel G, respectively, the histogram of channel G is the histogram of Saturation.

Brigthness is in channel B, respectively, the channel B histogram is the Brigthness histogram.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 14, 2017 Dec 14, 2017

Copy link to clipboard

Copied

LATEST

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines