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!
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?
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
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;
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
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)
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
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].
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
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.
Copy link to clipboard
Copied