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

Hide the layer with less color

New Here ,
Dec 23, 2024 Dec 23, 2024

Copy link to clipboard

Copied

I have two layers of color on top of each other, is there a way to calculate and hide the layer with less or lighter color?
I would like to ask for a script to do that

Capture.PNG

TOPICS
Actions and scripting

Views

157

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 , Dec 23, 2024 Dec 23, 2024

@powerful_Zephyr5EF9 

 

Try the following script. It assumes the target layers are the 2nd and 3rd in the stack from the bottom. The colour of each target layer will be compared using Lab colour where the a and b values of zer0 = neutral. The layer closest to neutral will be automatically hidden.

 

/*
Hide Closest Layer to Neutral of Target Pair.jsx
v1.0, 24th December 2024
Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/hide-the-layer-with-less-color/td-p/15054871
*
...

Votes

Translate

Translate
Adobe
Community Expert ,
Dec 23, 2024 Dec 23, 2024

Copy link to clipboard

Copied

If you're wondering whether Photoshop actions or built-in functionality are available, the answer is no. Please wait for the scripters to respond @c.pfaffenbichler 

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 ,
Dec 23, 2024 Dec 23, 2024

Copy link to clipboard

Copied

@powerful_Zephyr5EF9 

 

Your request isn't clear to me. Can you please explain the process? Step by step...

 

For example, based on your screenshot:

 

1) The user will manually select the lowest layer

 

2) The script will compare the selected layer to the layer directly above and hide whichever of the two layers has "less colour"

 

Or do you want to do something else? What relevance do the two groups in your screenshot have?

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 ,
Dec 23, 2024 Dec 23, 2024

Copy link to clipboard

Copied

I find the neutral gray point of an image using two methods:
When the image is well exposed, neutral gray point A has more color and B has less color and is lighter.
When the image is not well exposed, neutral gray point B has more color and A has less color and is lighter.

Photos from birthday parties, graduations, or trips often contain many images with unstable exposure. so i have to click many times.

I stacked them on top of each other and created an action in Photoshop to call the curve and used the auto click program to click exactly at the point where the two layers A,B overlap.
But the new problem that arises is that when stacking, I even have to hide the mismatched layer manually.
So I want to find a way to automatically hide the inappropriate layer (the layer with less color)

 

Capture2.PNGCapture23.PNG

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 ,
Dec 23, 2024 Dec 23, 2024

Copy link to clipboard

Copied

@powerful_Zephyr5EF9 

 

Thank you for the explanation. I feel that I should be in a better position than before, but I'm not.

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 ,
Dec 23, 2024 Dec 23, 2024

Copy link to clipboard

Copied

My need is actually just to hide the layer with less colors (usually more color than 808080 gray) automatically.

 

For example in the image above I need to hide circle B (closer to grey), in other cases it could be circle A if it is less colorful than B, closer to grey than B.

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 ,
Dec 23, 2024 Dec 23, 2024

Copy link to clipboard

Copied

quote

My need is actually just to hide the layer with less colors (usually more color than 808080 gray) automatically.

 

For example in the image above I need to hide circle B (closer to grey), in other cases it could be circle A if it is less colorful than B, closer to grey than B.


By @powerful_Zephyr5EF9

 

At the risk of repeating myself:

Please explain the mechanics, the process that will be performed.

 

1) The user will manually select the lowest colour circle layer

2) The script will compare the selected layer circle colour to the layer directly above and hide whichever of the two layers has "less colour" (closer to neutral).

 

How do you envision this working?

 

Do the circle layers always have the same name, or the same position or colour label in the groups and layer stack to aid automatic selection?

 

Scripting requires a process, instructions, rules to follow...

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 ,
Dec 23, 2024 Dec 23, 2024

Copy link to clipboard

Copied

@powerful_Zephyr5EF9 

 

Try the following script. It assumes the target layers are the 2nd and 3rd in the stack from the bottom. The colour of each target layer will be compared using Lab colour where the a and b values of zer0 = neutral. The layer closest to neutral will be automatically hidden.

 

/*
Hide Closest Layer to Neutral of Target Pair.jsx
v1.0, 24th December 2024
Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/hide-the-layer-with-less-color/td-p/15054871
*/

#target photoshop

try {
    // Ensure there are at least 3 layers, assuming that the target layers are the 2nd and 3rd in the stack
    if (app.activeDocument.artLayers.length < 3) {
        throw new Error("There should be a back layer and at least two additional target layers directly above!");
    }

    // Get the Back(ground) layer and the first two layers above it
    var backLayer = app.activeDocument.artLayers[app.activeDocument.artLayers.length - 1];
    var targetLayerA = app.activeDocument.artLayers[app.activeDocument.artLayers.length - 2];
    var targetLayerB = app.activeDocument.artLayers[app.activeDocument.artLayers.length - 3];

    // Get the average Lab color of each layer
    var labColor1 = getAverageLabColor(targetLayerA);
    var labColor2 = getAverageLabColor(targetLayerB);

    // Calculate the distance from neutral for each layer
    var distance1 = distanceFromNeutral(labColor1);
    var distance2 = distanceFromNeutral(labColor2);

    // Hide the layer that is closer to neutral
    if (distance1 < distance2) {
        targetLayerA.visible = false;
        var layerName = targetLayerA.name;
    } else {
        targetLayerB.visible = false;
        layerName = targetLayerB.name;
    }

    //alert('Layer "' + layerName + '" hidden!');
} catch (error) {
    alert('Error!' + '\r' + error + '\r' + 'Line: ' + error.line);
}


function distanceFromNeutral(labColor) {
    var a = labColor.a;
    var b = labColor.b;
    return Math.sqrt(a * a + b * b);
}

function getAverageLabColor(layer) {
    var samplePoint = [layer.bounds[0] + (layer.bounds[2] - layer.bounds[0]) / 2, layer.bounds[1] + (layer.bounds[3] - layer.bounds[1]) / 2];
    var sampleColor = app.activeDocument.colorSamplers.add(samplePoint);
    var labColor = sampleColor.color.lab;
    sampleColor.remove();
    return labColor;
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

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 ,
Dec 23, 2024 Dec 23, 2024

Copy link to clipboard

Copied

the program works very well, it will help me a lot.

i really appreciate your help.

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 ,
Dec 24, 2024 Dec 24, 2024

Copy link to clipboard

Copied

LATEST

You're welcome!

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