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

Seeking JavaScript Equivalent for Photoshop's "Find Neutral Gray" Technique for Batch Processing

New Here ,
Jan 15, 2025 Jan 15, 2025

Copy link to clipboard

Copied

Hi Photoshop Community,

I'm looking for a way to replicate the "Find Neutral Gray" technique described in this article ( https://www.photoshopessentials.com/photo-editing/neutral-gray/  ) using JavaScript. The article outlines a method to identify neutral gray areas in an image for color correction, which involves the following steps in Photoshop:

  1. Create a new layer and fill it with 50% gray.

  2. Set the layer's blend mode to "Difference".

  3. Add a Threshold adjustment layer.

  4. Adjust the Threshold slider to reveal the darkest areas, which represent areas closest to neutral gray.

  5. Use the Color Sampler Tool to mark a point in the darkest area.

  6. Remove the gray layer and Threshold layer.

  7. Add a Levels or Curves adjustment layer and use the "Set Gray Point" eyedropper to click on the marked point, neutralizing the midtones.

 

I need to use this technique in batch actions within Photoshop. This means the JavaScript code needs to be suitable for automation within a Photoshop batch process.

If achieving this exact workflow with JavaScript in a batch process is not feasible, I'd be grateful for alternative suggestions. What other methods do you recommend for color correction that can be automated for batch processing, besides the standard automatic calculation of curves with "Find Dark & Light Colors" and the "Snap Neutral Midtones" option? I'm looking for a robust and reliable method that can be applied to a large number of images consistently.

Any guidance or code examples on how to approach this would be greatly appreciated!

Thanks in advance for your help.

TOPICS
Actions and scripting

Views

131

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
Community Expert ,
Jan 15, 2025 Jan 15, 2025

Copy link to clipboard

Copied

I expect it might be necessary to iterate the threshold and evaluate the histogram and/or load selections to determine when the area is small enough (or disappears). 

Which would be a bit of a performance-issue but otherwise what is giving you problems? 

 

But I am talking about ESTK-Scripting, UXP-Scripting might be more efficient. 

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 ,
Jan 15, 2025 Jan 15, 2025

Copy link to clipboard

Copied

quote

If achieving this exact workflow with JavaScript in a batch process is not feasible, I'd be grateful for alternative suggestions. What other methods do you recommend for color correction that can be automated for batch processing, besides the standard automatic calculation of curves with "Find Dark & Light Colors" and the "Snap Neutral Midtones" option?

 

I'm looking for a robust and reliable method that can be applied to a large number of images consistently.

 

Any guidance or code examples on how to approach this would be greatly appreciated!

Thanks in advance for your help.


By @zelenook5F94

 

I usually don't recommend automated colour correction.

 

However, if you insist, then I'm going straight for alternatives.

 

If the images are raw camera files, JPEG or TIFF (or HEIC on Mac), then batch processing via Adobe Bridge and the Adobe Camera Raw plugin using the "Auto" setting could be an option (don't overwrite the originals).

 

Otherwise from within Photoshop, the Camera Raw Filter "Auto" can be scripted, and the script recorded into a batch action or a batch script.

 

  // Camera Raw Filter - Auto
  var desc1 = new ActionDescriptor();
  desc1.putBoolean(charIDToTypeID("AuTn"), true);
  executeAction(stringIDToTypeID('Adobe Camera Raw Filter'), desc1, DialogModes.NO);

 

YMMV, so again, don't overwrite the originals or work with duped merged layers or smart object layers etc.

 

Something that I just read about today is interesting, however, I haven't had any personal experience with it:

 

https://blog.adobe.com/en/publish/2024/10/14/the-adobe-adaptive-profile

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 ,
Jan 15, 2025 Jan 15, 2025

Copy link to clipboard

Copied

Stefano, the camera raw auto function is not suitable for doing what the user asks. Unfortunately what you ask is not possible, I have considered doing programming for this many times, but I have always had a negative outcome.

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 ,
Jan 15, 2025 Jan 15, 2025

Copy link to clipboard

Copied

LATEST

@Ciccillotto 

 

Yes, auto white balance would be closer and that too is scriptable for the CRF, but again it's auto and not designed for rendered data, so results are often less than satisfactory.

 

I'm not a fan of the method originally mentioned either.

 

Content and context aware colour correction is one of those things that should be better done with machine learning but is yet to be brought to market by Adobe.

 

https://data.csail.mit.edu/graphics/fivek/

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 ,
Jan 15, 2025 Jan 15, 2025

Copy link to clipboard

Copied

I really like the Adobe Adaptive profile, but as far as I've noticed, it only works with RAW files, so compressed JPEGs and other non-RAW formats are not supported. As for the automatic settings of the Camera Raw filter and their scripting, I found examples for auto white balance and auto tone here on the community forum. But I mostly don't use them. I mainly use the action from the screenshot, or I set the value to 0.01 instead of 0.0 for black clip and white clip. I've noticed that for certain photos where the automatic curve doesn't help, sometimes converting to a wider color space like ProPhoto or the ACES AP0 profile (I use the ICC color profile from RawTherapee) followed by an auto curve adjustment can help.

Regarding my question from the first message, I can't manage to automate steps 4, 5, and 7. It would be helpful to have this technique for batch correction "up my sleeve," so to speak, of course, if it's technically and script-wise feasible.

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