How to get values in the histogram from a script?
For example: Mean,Std Dev,Median,Pixels.
How to get vaules in the histogram
How to get vaules in the histogram
With mathematic, I guess.
At least I don’t know another way to access that information.
Maybe this helps somewhat:
Code: Select all// 2012, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theHist = myDocument.histogram;
// get total number;
var thePixels = 0;
for (var m = 0; m < theHist.length; m++) {
thePixels = thePixels + theHist[m]
};
// get mean and median;
var theMean = 0;
var aTotal = 0;
var check = false;
for (var n = 0; n < theHist.length; n++) {
theMean = theMean + (n * theHist[n] / thePixels);
aTotal = aTotal + theHist[n];
if (aTotal >= thePixels / 2 && check == false) {
theMedian = n;
check = true;
}
};
alert (thePixels + " pixels\n" + theMean + " mean\n" + theMedian + " median")
};
At least I don’t know another way to access that information.
Maybe this helps somewhat:
Code: Select all// 2012, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theHist = myDocument.histogram;
// get total number;
var thePixels = 0;
for (var m = 0; m < theHist.length; m++) {
thePixels = thePixels + theHist[m]
};
// get mean and median;
var theMean = 0;
var aTotal = 0;
var check = false;
for (var n = 0; n < theHist.length; n++) {
theMean = theMean + (n * theHist[n] / thePixels);
aTotal = aTotal + theHist[n];
if (aTotal >= thePixels / 2 && check == false) {
theMedian = n;
check = true;
}
};
alert (thePixels + " pixels\n" + theMean + " mean\n" + theMedian + " median")
};
How to get vaules in the histogram
These code is to get the Histogram of whole document , how to get a layer's histograms? Like photoshop can select whole document or a layer selected .
How to get vaules in the histogram
The Document Object Model does not seem to provide a histogram-property for (art)layers.
So short of hiding all other layers and loading the layer’s transparency as a selection I can’t think of a (reasonable) method to get that.
Maybe one of the regulars knows more about it, though.
What is your ultimate target for this information anyway?
So short of hiding all other layers and loading the layer’s transparency as a selection I can’t think of a (reasonable) method to get that.
Maybe one of the regulars knows more about it, though.
What is your ultimate target for this information anyway?
How to get vaules in the histogram
Code: Select allSo short of hiding all other layers and loading the layer’s transparency as a selection I can’t think of a (reasonable) method to get that.
This is true. Also, the histogram is shallow, only 8 bits instead of 16 or 32. You are getting a rough approximation using Document.histogram regardless of what you do. There is a file in xtools that handles some of the maths needed but I've never figured a way to get exactly the numbers that show up in the histogram palette.
This is true. Also, the histogram is shallow, only 8 bits instead of 16 or 32. You are getting a rough approximation using Document.histogram regardless of what you do. There is a file in xtools that handles some of the maths needed but I've never figured a way to get exactly the numbers that show up in the histogram palette.
How to get vaules in the histogram
There are many artlayers in the document.
I want to get the histogram of a artlayer by name.
If the artlayer has transparent pixels, the best not statistics the transparent pixels.
Can you give me the script?
I want to get the histogram of a artlayer by name.
If the artlayer has transparent pixels, the best not statistics the transparent pixels.
Can you give me the script?
How to get vaules in the histogram
As xbytor has confirmed that a viable approach would be to hide the other Layers and load the transparency you could just try amending the Script accordingly yourself.