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

export histogram mean value for RGB to csv file

New Here ,
Nov 27, 2015 Nov 27, 2015

Copy link to clipboard

Copied

Hello,

I am trying to export the mean value of a selection that is shown in the histogram panel.

I need to collect this data point for many images and was hoping to create an action that would export this data point for an entire folder of images.

So far all I have been able to do is export the raw histogram data which I suppose I could calculate the mean value from there but it is a lot of additional steps.

Let me know if there is a solution I am overlooking.

TOPICS
Actions and scripting

Views

2.5K

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

SuperMerlin created some great scripts here:

sort bright photos from dark photos in bridge?

Votes

Translate

Translate
Adobe
Adobe Employee ,
Nov 27, 2015 Nov 27, 2015

Copy link to clipboard

Copied

Hi alantor08

Please click on the below link and see if this helps.

Photoshop Help | View histograms and pixel values

~Mrinmay

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 ,
Nov 27, 2015 Nov 27, 2015

Copy link to clipboard

Copied

You would need to write a Photoshop Script to do that. I adobe Photoshop Scripting Guide the is am example script the accesses the histogram.  Scripts can also write to files and create a csv file.

Photoshop Extended also has the Statistics script that may help you to do what you want Photoshop Help | Image Stacks

measure Photoshop Help | Measurement

Capture.jpg

JJMack

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 ,
Nov 27, 2015 Nov 27, 2015

Copy link to clipboard

Copied

https://www.adobe.com/uk/digitalimag/pdfs/ph_exportdata.pdf

Of course, the link in the PDF no longer works and I have not been able to track down the histogram.js for CS2.

EDIT: Another option here, however it is only for older versions of Photoshop and the numbers don’t exactly match Photoshop’s histogram…

Telegraphics - Free plugins for Photoshop & Illustrator...and other software

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 ,
Nov 27, 2015 Nov 27, 2015

Copy link to clipboard

Copied

Somebody with the appropriate scripting knowledge may be able to change the following script:

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

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 ,
Nov 27, 2015 Nov 27, 2015

Copy link to clipboard

Copied

With luck somebody can change the script in my previous post to output the mean histogram value for an RGB selection.

alantor08 if nobody else can help, then I have an alternative hack method that would allow you to get this value from a batch of imges into a CSV file. Copies of the images would first need to be cropped to the selection. Note, this would only be accurate to the nearest integer value and anything after the decimal point would slightly vary from Photoshop (for example if Photoshop reported 143.93, my hack would report 143.66, which I doubt would matter that much).

Another option would be to look into ImageJ:

imagej.nih.gov/ij/index.html

Process/Batch/Measure (then point it to a folder full of images), again the results would only be accurate to Photoshop to the nearest integer 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 ,
Mar 05, 2017 Mar 05, 2017

Copy link to clipboard

Copied

Hi, did you have any luck finding a method to do it ? I am doing a research and came across your question. Thank you in advance

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

SuperMerlin created some great scripts here:

sort bright photos from dark photos in bridge?

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 ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

Can believe I ran into this, have you managed to do it? I need the exact same thing and I'm unfortunately not too keen on scripting. Thanks in advance if you even read this, since it's been 9 years 🙂

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 ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

quote

I'm unfortunately not too keen on scripting. 

What is this to indicate? 

 

Did you try the Script/s @Stephen_A_Marsh referenced? 

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 ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

Thanks for the reply, I'm pretty new to scripting.

 

Well yes, but I kept getting this message:
Error 1242: Illegal argument - argument 1
- File/Folder expected
Une: 19
-> open(fileList);

and couldn't find elaboration on how to fix this. So I tried to at least load one image with

which is finally working. But now the script runs and there's no mean value exported (see picture)

galaj2511_0-1711388026764.png

 

I thought an opened file would be recognized as an activeDocument, but somehow (I think) it's not:

 

Should I set the opened file to be the active document and how do I do that?

Here's the current state of my script (commented parts are still causing errors and I plan to deal with them later when I at least get the correct exported value to the CSV):

 

#target photoshop;

app.bringToFront();

main();

function main(){

//var inputFolder = Folder.selectDialog ("Please select folder");

//if(inputFolder == null) return;

//var fileList = inputFolder.getFiles(/\.(jpg|dng|tif|psd|crw|cr2|psb|exr|nef|dcr|dc2|erf|raf|orf|tga|mrw|mos|srf|pic|pct|pxr|pdd|pef|png|x3f|rw2)$/i);

var myFile = new File("D:/Projects/MASTER/VP/test/pas01.jpg");

var outFile = File(Folder.desktop +"/"+'TEST'+".csv");

outFile.open('w');

outFile.writeln("Filename,Mean Histogram");

//for(var a in fileList){

var myFileOpen = app.open(myFile);

//open(fileList);

//for (i=0; i<fileList.length; i++) {

// open(fileList);

// }

var area = activeDocument.histogram;

outFile.writeln(decodeURI(activeDocument.name)+ "," + mean(area).toFixed(0));

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

//}

//outFile.close();

//alert("Process complete\nCSV created...\n" + decodeURI(outFile));

}

function mean(hist) {

var acc = 0;

var cnt = 0;

for (var i = 0; i < hist.length; i++) {

acc += i*hist;

cnt += hist;

}

return acc/cnt;

};

 

 

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 ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

Update:

 

in order to prevent the error, I amended the open function to "open(fileList[a]);"

 

Still getting the "NaN" in the CSV tho.

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 ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

When Adobe changed forum software all of the old code with variables in square brackets were broken!

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 ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

haha, makes sense.

 

for (var i = 0; i < hist.length; i++) {

acc += i*hist[i];

cnt += hist[i];

}

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 ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

LATEST

@dobravoda – Yes, that should clear the not-a-number issue! 

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