Skip to main content
Participating Frequently
October 17, 2019
Question

expert needed for a tricky scripting challenge

  • October 17, 2019
  • 3 replies
  • 920 views

Hi,

I have a proof of concept to develop that requires significantly higher levels of photoshop expertise (more particularly photoshop scripting expertise) than mine.

I thought to start the search in this forum, hoping to find an expert or to get advice on where to look for it.

I would like to get in contact with experts who feel they are up for the following challenge, to talk about a possible engagement in developing the proof of concept

Setup:

  • Two images of the same object (Image 1, Image 2) are given  which have been captured under the two different environmental light conditions.
  • All other variables are the same for these two images (size, object position in the image, resolution, units etc.).

Hypothesis 1:

  • Comparing just two images, the adjustment layer/s can be determined, which when applied on the Image 1 will produce an (as close as practicable) match to the Image 2.

 

Hypothesis 2:

  • This process can be automated and completed without human intervention during the process.

 

Looking forward to your comments, interest and/or advice.

Thank you.

Best

Boris

This topic has been closed for replies.

3 replies

greless
Inspiring
October 17, 2019

For example, you want to get the brightness/contrast adjustment layer,

Read the value of the current brightness and contrast adjustment layer:

 

var ref = new ActionReference();  
ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );   
var layerDesc = executeActionGet(ref);  
var adjList = layerDesc.getList(stringIDToTypeID('adjustment'));  
 var theColors = adjList.getObjectValue(0);
 var rawData=theColors.getData(theColors.getKey(0)); 
 
 var val="",valtemp="";
 for(var _i=0;_i<rawData.length;_i++)
 {
     valtemp=rawData.charCodeAt(_i);
  //  if(valtemp>127) valtemp = 0xFFFFFF00^valtemp;
     val=val+"\t"+valtemp;
  }
alert(rawData.toSource()+"\n"+val,"data analysis ")
 
var brightness = rawData.charCodeAt(1); 
alert(rawData.length)
if(brightness>127) brightness = 0xFFFFFF00^brightness;// check sign  
var contrast = rawData.charCodeAt(3);  
alert(contrast)
if(contrast>127) contrast = 0xFFFFFF00^contrast;  
alert('The brightness is '+brightness+'\rContrast is '+contrast+"\n"+rawData.toSource());
 

write the value of the current brightness and contrast adjustment layer:

///////////////////////////////////////////////////////////////////////////////
(function make_24472045898438()
    {
    try {
        var d = new ActionDescriptor();
        var r = new ActionReference();
        r.putClass(stringIDToTypeID("adjustmentLayer"));
        d.putReference(stringIDToTypeID("null"), r);
        var d1 = new ActionDescriptor();
        var d2 = new ActionDescriptor();
        d2.putBoolean(stringIDToTypeID("useLegacy"), false);
        d1.putObject(stringIDToTypeID("type"), stringIDToTypeID("brightnessEvent"), d2);
        d.putObject(stringIDToTypeID("using"), stringIDToTypeID("adjustmentLayer"), d1);
        executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
        }
    catch (e) { if (e.number!=8007) { alert("Line: "+e.line+"\n\n"+e,"Bug!",true); throw(e); } }
    }
)();

///////////////////////////////////////////////////////////////////////////////
(function set_20187377929688()
    {
    try {
        var d = new ActionDescriptor();
        var r = new ActionReference();
        r.putEnumerated(stringIDToTypeID("adjustmentLayer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
        d.putReference(stringIDToTypeID("null"), r);
        var d1 = new ActionDescriptor();
        d1.putInteger(stringIDToTypeID("brightness"), 25);
        d1.putInteger(stringIDToTypeID("center"), 23);
        d.putObject(stringIDToTypeID("to"), stringIDToTypeID("brightnessEvent"), d1);
        executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
        }
    catch (e) { if (e.number!=8007) { alert("Line: "+e.line+"\n\n"+e,"Bug!",true); throw(e); } }
    }
)();
Participating Frequently
October 17, 2019
Hi 龚亮g64532194, thank you for the detailed example! Clearly you have an excellent scripting exprience. It would be great to chat further about the broader conceptual problem (Hypotesis 1). If suits you better, I would be OK with taking the chat on private message channel. Let me know. Thanks again. Boris
Participating Frequently
October 17, 2019
Of course, I would appreciate any further comments and ideas from other exprets interested in the problem! So please share your thoughts. Thanks.
Prof.AhmedBilal
Participant
October 17, 2019

Before you consider automation, you need to verify what you can do manually

Dr. Ahmed Belal
ajabon grinsmith
Community Expert
Community Expert
October 17, 2019

>Comparing just two images, adjustment layer/s can be determined, which when applied on Image 1 will produce an (as close as practicable) match to Image 2.

 

Hi.

Before you consider automation, you need to verify what you can do manually.
Because if you do n’t have a clear procedure, you wo n’t be able to automate.

Participating Frequently
October 17, 2019

Hi ajabon, thank you for the reply!

 

I agree, identifying the steps to define the adjustment layers parameters is a part of the challenge which requires expertise.

 

I think that, in general terms, there are two possible approaches to consider this problem.

 

The first one is the one you are referring to, define the steps that human would take in Photoshop UI to achieve an objective and to automate these actions.

 

The second one would be to use a code to manage a comparison of images (on a practicable level of details, pixels, histogram intervals…) and define an algorithm to calculate adjustments, apply them and verify achievement of the desired results.

 

My, not very well funded, guess would be that the first method would still require certain human input in analysis during the steps which would decrease the efficiency of automation.