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

Automatcally export lab or rgb histogram values from a selection

New Here ,
Sep 23, 2016 Sep 23, 2016

Copy link to clipboard

Copied

Hi,

I use Photoshop a lot for color analysis from digital images.

I basically take a selection of the object to analyse in the image and get the lab and/or rgb values from the histogram panel.

I haven't found yet a method to automatically export the data as a text or excel file so I punch it manually and this is time consuming.

I came across the "measurement log" panel and was wondering if I could use this tool to export the data I need e.g. mean values of L, a and b corresponding to my selection.

When I open the histogram.csv file exported from the measurement log I only get 3 rows of a long list of numbers. I guess this is the pixel distribution among the 3 channels. How can I extract the mean values, eventually st. dev and median, in a simple way that would be faster than manual data punching.

Thanks for you help.

Pierrick

TOPICS
Actions and scripting

Views

2.7K

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

correct answers 1 Correct answer

Community Expert , Jul 15, 2017 Jul 15, 2017

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 23, 2016 Sep 23, 2016

Copy link to clipboard

Copied

Histogram can be accessed via Scripting – do you have JavaScript experience?

How do you get Histogram Mean Value?

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
New Here ,
Sep 23, 2016 Sep 23, 2016

Copy link to clipboard

Copied

Hi and thanks for the rapid answer.

I do not have a JavaScript experience. I've just been playing around with CSS and PHP.

Is it just to copy this code on a text file and rename it with the .js extension? If yes, where should the file be located? I just had a quick look on that documentation http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/photoshop/pdfs/photoshop-cc-scripting-guide-2...which specifies the following path (i use Mac) : ~/Library/Application support/Adobe/Startup script CC/Adobe Photoshop, but I do not find the Startup script CC folder.

I really appreciate your help

Pierrick

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 Expert ,
Sep 23, 2016 Sep 23, 2016

Copy link to clipboard

Copied

// https://forums.adobe.com/thread/493796?q=export%20histogram

// creates a text-file from the histogram of active file/selection;

// 2009, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

var myDocument = app.activeDocument;

var theName = myDocument.name.match(/(.*)\.[^\.]+$/)[1];

var thePath = myDocument.path;

var theHistogram = myDocument.histogram;

var theText = new File(thePath+"/"+theName+"_histo.txt");

theText.open("w");

for (a = 0; a < theHistogram.length; a++){

// this line adds the number of the histogram-level;

theText.write(bufferNumberWithZeros(a,3)+"_");

// this line adds the number pixels of the respective histogram-level;

theText.write(theHistogram);

theText.write("\n")

}

theText.close();

}

else {

alert ("no open document")

};

////// buffer number with zeros //////

function bufferNumberWithZeros (number, places) {

var theNumberString = String(number);

for (var o = 0; o < (places - String(number).length); o++) {

theNumberString = String("0" + theNumberString)

};

return theNumberString

};

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 Expert ,
Sep 23, 2016 Sep 23, 2016

Copy link to clipboard

Copied

// https://forums.adobe.com/message/7246695

// Get the histogram data

// ----------------------

var luminosity = activeDocument.histogram;

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

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

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

var datFile = new File("~/Desktop/Histogram.csv");

datFile.open("e");

datFile.writeln("Level,Luminosity,Red,Green,Blue\r");

for ( i = 0; i <= 255; i++ ) {

  datFile.writeln(i + "," + luminosity + "," + red + "," + green + "," + blue + "\r");

}

datFile.close();

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
New Here ,
Sep 23, 2016 Sep 23, 2016

Copy link to clipboard

Copied

Hi Stephen,

This is nice, but it gives me 255 pixels values for each channel. What I need is the mean value and st. error for each channel.

This last script should be modified so these values are extracted instead of pixel values. Unfortunately my JS skills won't take me far on that. Do you have any idea on how to do it?

Otherwise the Photoshop math should be applied on the extracted pixel values to calculate mean and st. err.

Thanks

Pierrick

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 Expert ,
Sep 23, 2016 Sep 23, 2016

Copy link to clipboard

Copied

No Pierrick, I can’t script either, just passing on what I could in the hopes that it may help you or somebody else that can help. You will likely need this topic moved to the scripting forum. Looking around it appears that this info may not be scriptable and that you may have to perform mathematical operations on what can be scripted (either doing the math in the script or on the exported values via a spreadsheet formula etc). Good luck.

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 Expert ,
Jul 15, 2017 Jul 15, 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