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

Scripting a layer style for each layer to make a depth pass from focus stacking information.

Community Beginner ,
Sep 21, 2013 Sep 21, 2013

I'm trying to generate a depth pass from rack focus. Basically where I've gotten to right now is importing the rack focus footage each frame from as an individual layer. Then running Auto Blend Layers and letting photoshop do it's magic to mask out each layer's out of focus information. This basically gives me a bunch of layers that tell me exactly where the camera's focus was at each frame in the shot. What I need to do now is Add a color overlay (maybe in the form of a layer style) that starts at 100% black and goes to 100% white stepping through each layer.

Right now I have this, which is so very far away.

try {

    var docName = app.activeDocument.name;  // save the app.activeDocument name before duplicate.

    var layerCount = app.documents[docName].layers.length; //figure out how many layers

    var colorStep = 255/layerCount; //figure out how big the step of grey is between each layer.

        for (i = 1; i <= layerCount; i++){

            my_layer = [docName].layer(i);

            my_layer.applyStyle (solidFill) //add the color overly layer style

            //color the overlay using the colorStep information and layer number

         

            }

        }

    }

What I want is an end result that looks like this.

rendering_mattes_05.jpg

TOPICS
Actions and scripting
582
Translate
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
Guru ,
Sep 23, 2013 Sep 23, 2013
LATEST

The only focus stacking I have done is with macro photography. Below is a script that adds the layer effects but the results with my macro samples did not turn out looking good. Maybe you will have better luck with the type of photography you are doing.

function ftn1(r,g,b) {

    var desc = new ActionDescriptor();

        var ref = new ActionReference();

        ref.putProperty( charIDToTypeID('Prpr'), charIDToTypeID('Lefx') );

        ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

    desc.putReference( charIDToTypeID('null'), ref );

        var effectsDesc = new ActionDescriptor();

        //effectsDesc.putUnitDouble( charIDToTypeID('Scl '), charIDToTypeID('#Prc'), 333.333333 );

            var colorfillDesc = new ActionDescriptor();

            colorfillDesc.putBoolean( charIDToTypeID('enab'), true );

            colorfillDesc.putEnumerated( charIDToTypeID('Md  '), charIDToTypeID('BlnM'), charIDToTypeID('Nrml') );

            colorfillDesc.putUnitDouble( charIDToTypeID('Opct'), charIDToTypeID('#Prc'), 100.000000 );

                var rgbcDesc = new ActionDescriptor();

                rgbcDesc.putDouble( charIDToTypeID('Rd  '), r );

                rgbcDesc.putDouble( charIDToTypeID('Grn '), g );

                rgbcDesc.putDouble( charIDToTypeID('Bl  '), b );

            colorfillDesc.putObject( charIDToTypeID('Clr '), charIDToTypeID('RGBC'), rgbcDesc );

        effectsDesc.putObject( charIDToTypeID('SoFi'), charIDToTypeID('SoFi'), colorfillDesc );

    desc.putObject( charIDToTypeID('T   '), charIDToTypeID('Lefx'), effectsDesc );

    executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );

};

try {

    // var docName = app.activeDocument.name;  // save the app.activeDocument name before duplicate.

    // var layerCount = app.documents[docName].layers.length; //figure out how many layers

    var docRef = app.activeDocument;

    var layerCount = docRef.artLayers.length;

    var colorStep = 255/layerCount; //figure out how big the step of grey is between each layer.

    var color = 255;

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

        docRef.activeLayer = docRef.artLayers;

        ftn1( color, color, color);

        color=color-colorStep;

    }

}catch(e){}

Translate
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