1 2 Previous Next 64 Replies Latest reply on Mar 13, 2013 9:47 AM by bala281972

    Color samplers - dark, light & grey point - how to adjust curves

    bala281972 Level 1

      Hi all

       

      I've set dark, light & grey point in an image. Wondering how to adjust the curves based on the color samplers. Manually i invoke the curve dialog box and select the dark pen and choose sampler no1, select light pen and choose sampler no2, select grey pen and choose sampler no3. Any idea how this can be done in script?

        • 1. Re: Color samplers - dark, light & grey point - how to adjust curves
          c.pfaffenbichler Level 9

          This creates a Curves Layer via two equally long Arrays for each RGB Channel for the In- and Output values.

          #target photoshop
          var theArray = [[0, 128, 255], [0, 150, 255], [0, 128, 255], [0, 90, 255], [0, 75, 230, 255], [0, 30, 180, 255]];
          rgbCurvesLayer (theArray);
          ////// make rgb curves layer //////
          function rgbCurvesLayer (theArray) {
          // =======================================================
          var idMk = charIDToTypeID( "Mk  " );
              var desc5 = new ActionDescriptor();
              var idnull = charIDToTypeID( "null" );
                  var ref2 = new ActionReference();
                  var idAdjL = charIDToTypeID( "AdjL" );
                  ref2.putClass( idAdjL );
              desc5.putReference( idnull, ref2 );
              var idUsng = charIDToTypeID( "Usng" );
                  var desc6 = new ActionDescriptor();
                  var idType = charIDToTypeID( "Type" );
                      var desc7 = new ActionDescriptor();
                      var idpresetKind = stringIDToTypeID( "presetKind" );
                      var idpresetKindType = stringIDToTypeID( "presetKindType" );
                      var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
                      desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
                  var idCrvs = charIDToTypeID( "Crvs" );
                  desc6.putObject( idType, idCrvs, desc7 );
              var idAdjL = charIDToTypeID( "AdjL" );
              desc5.putObject( idUsng, idAdjL, desc6 );
          executeAction( idMk, desc5, DialogModes.NO );
          // =======================================================
          var idsetd = charIDToTypeID( "setd" );
              var desc8 = new ActionDescriptor();
              var idnull = charIDToTypeID( "null" );
                  var ref3 = new ActionReference();
                  var idAdjL = charIDToTypeID( "AdjL" );
                  var idOrdn = charIDToTypeID( "Ordn" );
                  var idTrgt = charIDToTypeID( "Trgt" );
                  ref3.putEnumerated( idAdjL, idOrdn, idTrgt );
              desc8.putReference( idnull, ref3 );
              var idT = charIDToTypeID( "T   " );
                  var desc9 = new ActionDescriptor();
                  var idpresetKind = stringIDToTypeID( "presetKind" );
                  var idpresetKindType = stringIDToTypeID( "presetKindType" );
                  var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
                  desc9.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
                  var idAdjs = charIDToTypeID( "Adjs" );
                      var list1 = new ActionList();
                          var desc10 = new ActionDescriptor();
                          var idChnl = charIDToTypeID( "Chnl" );
                              var ref4 = new ActionReference();
                              var idChnl = charIDToTypeID( "Chnl" );
                              var idChnl = charIDToTypeID( "Chnl" );
                              var idRd = charIDToTypeID( "Rd  " );
                              ref4.putEnumerated( idChnl, idChnl, idRd );
                          desc10.putReference( idChnl, ref4 );
                          var idCrv = charIDToTypeID( "Crv " );
                              var list2 = new ActionList();
          // add r points;
          for (var m = 0; m < theArray[0].length; m++) {
                    addCurvePoint (list2, theArray[0][m], theArray[1][m])
                    }; 
                          desc10.putList( idCrv, list2 );
                      var idCrvA = charIDToTypeID( "CrvA" );
                      list1.putObject( idCrvA, desc10 );
                          var desc15 = new ActionDescriptor();
                          var idChnl = charIDToTypeID( "Chnl" );
                              var ref5 = new ActionReference();
                              var idChnl = charIDToTypeID( "Chnl" );
                              var idChnl = charIDToTypeID( "Chnl" );
                              var idGrn = charIDToTypeID( "Grn " );
                              ref5.putEnumerated( idChnl, idChnl, idGrn );
                          desc15.putReference( idChnl, ref5 );
                          var idCrv = charIDToTypeID( "Crv " );
                              var list3 = new ActionList();
          // add g points;
          for (var m = 0; m < theArray[2].length; m++) {
                    addCurvePoint (list3, theArray[2][m], theArray[3][m])
                    };
                          desc15.putList( idCrv, list3 );
                      var idCrvA = charIDToTypeID( "CrvA" );
                      list1.putObject( idCrvA, desc15 );
                          var desc20 = new ActionDescriptor();
                          var idChnl = charIDToTypeID( "Chnl" );
                              var ref6 = new ActionReference();
                              var idChnl = charIDToTypeID( "Chnl" );
                              var idChnl = charIDToTypeID( "Chnl" );
                              var idBl = charIDToTypeID( "Bl  " );
                              ref6.putEnumerated( idChnl, idChnl, idBl );
                          desc20.putReference( idChnl, ref6 );
                          var idCrv = charIDToTypeID( "Crv " );
                              var list4 = new ActionList();
          // add b points;
          for (var m = 0; m < theArray[4].length; m++) {
                    addCurvePoint (list4, theArray[4][m], theArray[5][m])
                    };
                          desc20.putList( idCrv, list4 );
                      var idCrvA = charIDToTypeID( "CrvA" );
                      list1.putObject( idCrvA, desc20 );
                  desc9.putList( idAdjs, list1 );
              var idCrvs = charIDToTypeID( "Crvs" );
              desc8.putObject( idT, idCrvs, desc9 );
          executeAction( idsetd, desc8, DialogModes.NO );
          //
          return app.activeDocument.activeLayer;
          ////// add curve point //////
          function addCurvePoint (theList, valueHor, valueVer) {
          var desc11 = new ActionDescriptor();
          var idHrzn = charIDToTypeID( "Hrzn" );
          desc11.putDouble( idHrzn, valueHor );
          var idVrtc = charIDToTypeID( "Vrtc" );
          desc11.putDouble( idVrtc, valueVer );
          var idPnt = charIDToTypeID( "Pnt " );
          theList.putObject( idPnt, desc11 );
          };
          };
          
          • 2. Re: Color samplers - dark, light & grey point - how to adjust curves
            bala281972 Level 1

            Hi

             

            Im sorry. I guess I have not explained properly. I have set 3 color samplers in the image. One is the lightest portion and one darkest position and the last one being mid tone. Now I would like to apply thest pointa using set white dark mid tone pens available in the curve tool. How to set this using script.

            • 3. Re: Color samplers - dark, light & grey point - how to adjust curves
              c.pfaffenbichler Level 9

              As you have the RGB values of the three points feed them into above function with the corresponding target values you want.

              Could you please post an example where you have already set the color samplers?

              • 4. Re: Color samplers - dark, light & grey point - how to adjust curves
                bala281972 Level 1

                I am sorry. Im still not clear. I have rgb values of each sampler. But what you mean by target color hw to get it. I will share grab in couple of hrs  as I am sending these msgs fm my mobile

                • 5. Re: Color samplers - dark, light & grey point - how to adjust curves
                  bala281972 Level 1

                  Hi

                  The co-ordinates of pt. no1 is 705.5px, 988.5px and pt no 2 is 806.5px, 990.5px and pt no 3 is 355.5px,1827.5px

                  The RGB values of pt1 is 45.0, 54, 61.0 and pt no 2 is 211 189 191 and pt no 3 is 221, 217, 207

                   

                  Not sure what you mean by input and output values

                   

                   

                  Screen Shot 2013-03-05 at 8.51.00 AM.png

                  • 6. Re: Color samplers - dark, light & grey point - how to adjust curves
                    c.pfaffenbichler Level 9

                    Could you please post (the part of) the image, not a screenshot.

                    • 7. Re: Color samplers - dark, light & grey point - how to adjust curves
                      bala281972 Level 1

                      This is the script listener code, while doing trials the co-ordinates been changed. Not sure whether i need to re-post the co-ordinates as well as the colors, pl. let me know

                       

                      var idLvls = charIDToTypeID( "Lvls" );

                          var desc7 = new ActionDescriptor();

                          var idpresetKind = stringIDToTypeID( "presetKind" );

                          var idpresetKindType = stringIDToTypeID( "presetKindType" );

                          var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );

                          desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );

                          var idAdjs = charIDToTypeID( "Adjs" );

                              var list1 = new ActionList();

                                  var desc8 = new ActionDescriptor();

                                  var idChnl = charIDToTypeID( "Chnl" );

                                      var ref5 = new ActionReference();

                                      var idChnl = charIDToTypeID( "Chnl" );

                                      var idChnl = charIDToTypeID( "Chnl" );

                                      var idRd = charIDToTypeID( "Rd  " );

                                      ref5.putEnumerated( idChnl, idChnl, idRd );

                                  desc8.putReference( idChnl, ref5 );

                                  var idInpt = charIDToTypeID( "Inpt" );

                                      var list2 = new ActionList();

                                      list2.putInteger( 20 );

                                      list2.putInteger( 218 );

                                  desc8.putList( idInpt, list2 );

                              var idLvlA = charIDToTypeID( "LvlA" );

                              list1.putObject( idLvlA, desc8 );

                                  var desc9 = new ActionDescriptor();

                                  var idChnl = charIDToTypeID( "Chnl" );

                                      var ref6 = new ActionReference();

                                      var idChnl = charIDToTypeID( "Chnl" );

                                      var idChnl = charIDToTypeID( "Chnl" );

                                      var idGrn = charIDToTypeID( "Grn " );

                                      ref6.putEnumerated( idChnl, idChnl, idGrn );

                                  desc9.putReference( idChnl, ref6 );

                                  var idInpt = charIDToTypeID( "Inpt" );

                                      var list3 = new ActionList();

                                      list3.putInteger( 25 );

                                      list3.putInteger( 214 );

                                  desc9.putList( idInpt, list3 );

                              var idLvlA = charIDToTypeID( "LvlA" );

                              list1.putObject( idLvlA, desc9 );

                                  var desc10 = new ActionDescriptor();

                                  var idChnl = charIDToTypeID( "Chnl" );

                                      var ref7 = new ActionReference();

                                      var idChnl = charIDToTypeID( "Chnl" );

                                      var idChnl = charIDToTypeID( "Chnl" );

                                      var idBl = charIDToTypeID( "Bl  " );

                                      ref7.putEnumerated( idChnl, idChnl, idBl );

                                  desc10.putReference( idChnl, ref7 );

                                  var idInpt = charIDToTypeID( "Inpt" );

                                      var list4 = new ActionList();

                                      list4.putInteger( 28 );

                                      list4.putInteger( 203 );

                                  desc10.putList( idInpt, list4 );

                              var idLvlA = charIDToTypeID( "LvlA" );

                              list1.putObject( idLvlA, desc10 );

                          desc7.putList( idAdjs, list1 );

                      executeAction( idLvls, desc7, DialogModes.NO );Kate-Hudson-Smiling-Against-Pale-Pink-Photo-Shoot-kate-hudson-9695712-1591-2003.jpg

                      • 8. Re: Color samplers - dark, light & grey point - how to adjust curves
                        bala281972 Level 1

                        By the way, the code what has given earlier belongs to levels, and not curves, i'm just trying out whether i'm able to get an idea on the codes generated. but going mad reading those junks

                        • 9. Re: Color samplers - dark, light & grey point - how to adjust curves
                          bala281972 Level 1

                          This is curves SL code

                           

                          var idCrvs = charIDToTypeID( "Crvs" );

                              var desc9 = new ActionDescriptor();

                              var idpresetKind = stringIDToTypeID( "presetKind" );

                              var idpresetKindType = stringIDToTypeID( "presetKindType" );

                              var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );

                              desc9.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );

                              var idAdjs = charIDToTypeID( "Adjs" );

                                  var list1 = new ActionList();

                                      var desc10 = new ActionDescriptor();

                                      var idChnl = charIDToTypeID( "Chnl" );

                                          var ref3 = new ActionReference();

                                          var idChnl = charIDToTypeID( "Chnl" );

                                          var idChnl = charIDToTypeID( "Chnl" );

                                          var idRd = charIDToTypeID( "Rd  " );

                                          ref3.putEnumerated( idChnl, idChnl, idRd );

                                      desc10.putReference( idChnl, ref3 );

                                      var idCrv = charIDToTypeID( "Crv " );

                                          var list2 = new ActionList();

                                              var desc11 = new ActionDescriptor();

                                              var idHrzn = charIDToTypeID( "Hrzn" );

                                              desc11.putDouble( idHrzn, 17.000000 );

                                              var idVrtc = charIDToTypeID( "Vrtc" );

                                              desc11.putDouble( idVrtc, 0.000000 );

                                          var idPnt = charIDToTypeID( "Pnt " );

                                          list2.putObject( idPnt, desc11 );

                                              var desc12 = new ActionDescriptor();

                                              var idHrzn = charIDToTypeID( "Hrzn" );

                                              desc12.putDouble( idHrzn, 230.000000 );

                                              var idVrtc = charIDToTypeID( "Vrtc" );

                                              desc12.putDouble( idVrtc, 255.000000 );

                                          var idPnt = charIDToTypeID( "Pnt " );

                                          list2.putObject( idPnt, desc12 );

                                      desc10.putList( idCrv, list2 );

                                  var idCrvA = charIDToTypeID( "CrvA" );

                                  list1.putObject( idCrvA, desc10 );

                                      var desc13 = new ActionDescriptor();

                                      var idChnl = charIDToTypeID( "Chnl" );

                                          var ref4 = new ActionReference();

                                          var idChnl = charIDToTypeID( "Chnl" );

                                          var idChnl = charIDToTypeID( "Chnl" );

                                          var idGrn = charIDToTypeID( "Grn " );

                                          ref4.putEnumerated( idChnl, idChnl, idGrn );

                                      desc13.putReference( idChnl, ref4 );

                                      var idCrv = charIDToTypeID( "Crv " );

                                          var list3 = new ActionList();

                                              var desc14 = new ActionDescriptor();

                                              var idHrzn = charIDToTypeID( "Hrzn" );

                                              desc14.putDouble( idHrzn, 26.000000 );

                                              var idVrtc = charIDToTypeID( "Vrtc" );

                                              desc14.putDouble( idVrtc, 0.000000 );

                                          var idPnt = charIDToTypeID( "Pnt " );

                                          list3.putObject( idPnt, desc14 );

                                              var desc15 = new ActionDescriptor();

                                              var idHrzn = charIDToTypeID( "Hrzn" );

                                              desc15.putDouble( idHrzn, 223.000000 );

                                              var idVrtc = charIDToTypeID( "Vrtc" );

                                              desc15.putDouble( idVrtc, 255.000000 );

                                          var idPnt = charIDToTypeID( "Pnt " );

                                          list3.putObject( idPnt, desc15 );

                                      desc13.putList( idCrv, list3 );

                                  var idCrvA = charIDToTypeID( "CrvA" );

                                  list1.putObject( idCrvA, desc13 );

                                      var desc16 = new ActionDescriptor();

                                      var idChnl = charIDToTypeID( "Chnl" );

                                          var ref5 = new ActionReference();

                                          var idChnl = charIDToTypeID( "Chnl" );

                                          var idChnl = charIDToTypeID( "Chnl" );

                                          var idBl = charIDToTypeID( "Bl  " );

                                          ref5.putEnumerated( idChnl, idChnl, idBl );

                                      desc16.putReference( idChnl, ref5 );

                                      var idCrv = charIDToTypeID( "Crv " );

                                          var list4 = new ActionList();

                                              var desc17 = new ActionDescriptor();

                                              var idHrzn = charIDToTypeID( "Hrzn" );

                                              desc17.putDouble( idHrzn, 27.000000 );

                                              var idVrtc = charIDToTypeID( "Vrtc" );

                                              desc17.putDouble( idVrtc, 0.000000 );

                                          var idPnt = charIDToTypeID( "Pnt " );

                                          list4.putObject( idPnt, desc17 );

                                              var desc18 = new ActionDescriptor();

                                              var idHrzn = charIDToTypeID( "Hrzn" );

                                              desc18.putDouble( idHrzn, 214.000000 );

                                              var idVrtc = charIDToTypeID( "Vrtc" );

                                              desc18.putDouble( idVrtc, 255.000000 );

                                          var idPnt = charIDToTypeID( "Pnt " );

                                          list4.putObject( idPnt, desc18 );

                                      desc16.putList( idCrv, list4 );

                                  var idCrvA = charIDToTypeID( "CrvA" );

                                  list1.putObject( idCrvA, desc16 );

                              desc9.putList( idAdjs, list1 );

                          executeAction( idCrvs, desc9, DialogModes.NO );

                          • 10. Re: Color samplers - dark, light & grey point - how to adjust curves
                            c.pfaffenbichler Level 9

                            I’m stymied by the gray point at current, it does not seem to use the measured values directly.

                            The white and black points seem to be straightforward and can be set easily with a Script when one knows the values.

                            #target photoshop
                            var theArray = [[17, 224], [0, 255], [27, 215], [0, 255], [28, 206], [0, 255]];
                            rgbCurvesLayer (theArray);
                            ////// make rgb curves layer //////
                            function rgbCurvesLayer (theArray) {
                            // =======================================================
                            var idMk = charIDToTypeID( "Mk  " );
                                var desc5 = new ActionDescriptor();
                                var idnull = charIDToTypeID( "null" );
                                    var ref2 = new ActionReference();
                                    var idAdjL = charIDToTypeID( "AdjL" );
                                    ref2.putClass( idAdjL );
                                desc5.putReference( idnull, ref2 );
                                var idUsng = charIDToTypeID( "Usng" );
                                    var desc6 = new ActionDescriptor();
                                    var idType = charIDToTypeID( "Type" );
                                        var desc7 = new ActionDescriptor();
                                        var idpresetKind = stringIDToTypeID( "presetKind" );
                                        var idpresetKindType = stringIDToTypeID( "presetKindType" );
                                        var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
                                        desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
                                    var idCrvs = charIDToTypeID( "Crvs" );
                                    desc6.putObject( idType, idCrvs, desc7 );
                                var idAdjL = charIDToTypeID( "AdjL" );
                                desc5.putObject( idUsng, idAdjL, desc6 );
                            executeAction( idMk, desc5, DialogModes.NO );
                            // =======================================================
                            var idsetd = charIDToTypeID( "setd" );
                                var desc8 = new ActionDescriptor();
                                var idnull = charIDToTypeID( "null" );
                                    var ref3 = new ActionReference();
                                    var idAdjL = charIDToTypeID( "AdjL" );
                                    var idOrdn = charIDToTypeID( "Ordn" );
                                    var idTrgt = charIDToTypeID( "Trgt" );
                                    ref3.putEnumerated( idAdjL, idOrdn, idTrgt );
                                desc8.putReference( idnull, ref3 );
                                var idT = charIDToTypeID( "T   " );
                                    var desc9 = new ActionDescriptor();
                                    var idpresetKind = stringIDToTypeID( "presetKind" );
                                    var idpresetKindType = stringIDToTypeID( "presetKindType" );
                                    var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
                                    desc9.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
                                    var idAdjs = charIDToTypeID( "Adjs" );
                                        var list1 = new ActionList();
                                            var desc10 = new ActionDescriptor();
                                            var idChnl = charIDToTypeID( "Chnl" );
                                                var ref4 = new ActionReference();
                                                var idChnl = charIDToTypeID( "Chnl" );
                                                var idChnl = charIDToTypeID( "Chnl" );
                                                var idRd = charIDToTypeID( "Rd  " );
                                                ref4.putEnumerated( idChnl, idChnl, idRd );
                                            desc10.putReference( idChnl, ref4 );
                                            var idCrv = charIDToTypeID( "Crv " );
                                                var list2 = new ActionList();
                            // add r points;
                            for (var m = 0; m < theArray[0].length; m++) {
                                      addCurvePoint (list2, theArray[0][m], theArray[1][m])
                                      }; 
                                            desc10.putList( idCrv, list2 );
                                        var idCrvA = charIDToTypeID( "CrvA" );
                                        list1.putObject( idCrvA, desc10 );
                                            var desc15 = new ActionDescriptor();
                                            var idChnl = charIDToTypeID( "Chnl" );
                                                var ref5 = new ActionReference();
                                                var idChnl = charIDToTypeID( "Chnl" );
                                                var idChnl = charIDToTypeID( "Chnl" );
                                                var idGrn = charIDToTypeID( "Grn " );
                                                ref5.putEnumerated( idChnl, idChnl, idGrn );
                                            desc15.putReference( idChnl, ref5 );
                                            var idCrv = charIDToTypeID( "Crv " );
                                                var list3 = new ActionList();
                            // add g points;
                            for (var m = 0; m < theArray[2].length; m++) {
                                      addCurvePoint (list3, theArray[2][m], theArray[3][m])
                                      };
                                            desc15.putList( idCrv, list3 );
                                        var idCrvA = charIDToTypeID( "CrvA" );
                                        list1.putObject( idCrvA, desc15 );
                                            var desc20 = new ActionDescriptor();
                                            var idChnl = charIDToTypeID( "Chnl" );
                                                var ref6 = new ActionReference();
                                                var idChnl = charIDToTypeID( "Chnl" );
                                                var idChnl = charIDToTypeID( "Chnl" );
                                                var idBl = charIDToTypeID( "Bl  " );
                                                ref6.putEnumerated( idChnl, idChnl, idBl );
                                            desc20.putReference( idChnl, ref6 );
                                            var idCrv = charIDToTypeID( "Crv " );
                                                var list4 = new ActionList();
                            // add b points;
                            for (var m = 0; m < theArray[4].length; m++) {
                                      addCurvePoint (list4, theArray[4][m], theArray[5][m])
                                      };
                                            desc20.putList( idCrv, list4 );
                                        var idCrvA = charIDToTypeID( "CrvA" );
                                        list1.putObject( idCrvA, desc20 );
                                    desc9.putList( idAdjs, list1 );
                                var idCrvs = charIDToTypeID( "Crvs" );
                                desc8.putObject( idT, idCrvs, desc9 );
                            executeAction( idsetd, desc8, DialogModes.NO );
                            //
                            return app.activeDocument.activeLayer;
                            ////// add curve point //////
                            function addCurvePoint (theList, valueHor, valueVer) {
                            var desc11 = new ActionDescriptor();
                            var idHrzn = charIDToTypeID( "Hrzn" );
                            desc11.putDouble( idHrzn, valueHor );
                            var idVrtc = charIDToTypeID( "Vrtc" );
                            desc11.putDouble( idVrtc, valueVer );
                            var idPnt = charIDToTypeID( "Pnt " );
                            theList.putObject( idPnt, desc11 );
                            };
                            };
                            

                             

                            Edit: I had assumed the gray point picker would set the input values of the point picked to output 127/127/127, but he operation seems to be quite different.

                            • 11. Re: Color samplers - dark, light & grey point - how to adjust curves
                              c.pfaffenbichler Level 9

                              This is curves SL code

                               

                              var idCrvs = charIDToTypeID( "Crvs" );

                              This code does only set the white and black points, did the gray point not register in the recording or did you not set it?

                              • 12. Re: Color samplers - dark, light & grey point - how to adjust curves
                                bala281972 Level 1

                                I ran the SL again and this is what i got not sure whether its recorded or not

                                 

                                 

                                var idLvls = charIDToTypeID( "Lvls" );

                                    var desc20 = new ActionDescriptor();

                                    var idpresetKind = stringIDToTypeID( "presetKind" );

                                    var idpresetKindType = stringIDToTypeID( "presetKindType" );

                                    var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );

                                    desc20.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );

                                    var idAdjs = charIDToTypeID( "Adjs" );

                                        var list5 = new ActionList();

                                            var desc21 = new ActionDescriptor();

                                            var idChnl = charIDToTypeID( "Chnl" );

                                                var ref7 = new ActionReference();

                                                var idChnl = charIDToTypeID( "Chnl" );

                                                var idChnl = charIDToTypeID( "Chnl" );

                                                var idRd = charIDToTypeID( "Rd  " );

                                                ref7.putEnumerated( idChnl, idChnl, idRd );

                                            desc21.putReference( idChnl, ref7 );

                                            var idInpt = charIDToTypeID( "Inpt" );

                                                var list6 = new ActionList();

                                                list6.putInteger( 17 );

                                                list6.putInteger( 224 );

                                            desc21.putList( idInpt, list6 );

                                        var idLvlA = charIDToTypeID( "LvlA" );

                                        list5.putObject( idLvlA, desc21 );

                                            var desc22 = new ActionDescriptor();

                                            var idChnl = charIDToTypeID( "Chnl" );

                                                var ref8 = new ActionReference();

                                                var idChnl = charIDToTypeID( "Chnl" );

                                                var idChnl = charIDToTypeID( "Chnl" );

                                                var idGrn = charIDToTypeID( "Grn " );

                                                ref8.putEnumerated( idChnl, idChnl, idGrn );

                                            desc22.putReference( idChnl, ref8 );

                                            var idInpt = charIDToTypeID( "Inpt" );

                                                var list7 = new ActionList();

                                                list7.putInteger( 26 );

                                                list7.putInteger( 216 );

                                            desc22.putList( idInpt, list7 );

                                        var idLvlA = charIDToTypeID( "LvlA" );

                                        list5.putObject( idLvlA, desc22 );

                                            var desc23 = new ActionDescriptor();

                                            var idChnl = charIDToTypeID( "Chnl" );

                                                var ref9 = new ActionReference();

                                                var idChnl = charIDToTypeID( "Chnl" );

                                                var idChnl = charIDToTypeID( "Chnl" );

                                                var idBl = charIDToTypeID( "Bl  " );

                                                ref9.putEnumerated( idChnl, idChnl, idBl );

                                            desc23.putReference( idChnl, ref9 );

                                            var idInpt = charIDToTypeID( "Inpt" );

                                                var list8 = new ActionList();

                                                list8.putInteger( 27 );

                                                list8.putInteger( 204 );

                                            desc23.putList( idInpt, list8 );

                                        var idLvlA = charIDToTypeID( "LvlA" );

                                        list5.putObject( idLvlA, desc23 );

                                    desc20.putList( idAdjs, list5 );

                                executeAction( idLvls, desc20, DialogModes.NO );

                                • 13. Re: Color samplers - dark, light & grey point - how to adjust curves
                                  bala281972 Level 1

                                  This works fine. But not sure how i customize this. The white, grey & black points are set by the script automatically, means open an image run the script it will set the white, grey & black points, i'm still debating the accuracy of the code what i've coded, so there's definitely a chance of flaw in the code.

                                   

                                  I would like to know how to generalize the code, the array values represents what ? How to arrive the array values using the co-ordinates & rgb values?

                                   

                                  Appreciate your help on this

                                  • 14. Re: Color samplers - dark, light & grey point - how to adjust curves
                                    c.pfaffenbichler Level 9

                                    You set the Color Pickers, didn’t you? So you already have the values for the white and black points available.

                                    The gray point, like I mentioned, seems to work differently; so the values from that color picker do not produce the same results as manually setting the gray point for me at current …

                                     

                                    In the posted function the first array repesents input values for Red, second one output values for Red, third one input values for Green etc.

                                    • 15. Re: Color samplers - dark, light & grey point - how to adjust curves
                                      bala281972 Level 1

                                      I'm sorry. I am aware of only colorSamplers[0].colors.rgb.red and colorSamplers[0].position functions only. Not sure how to retrieve the input and output values using the samplers. Appreciate your guidance

                                      • 16. Re: Color samplers - dark, light & grey point - how to adjust curves
                                        c.pfaffenbichler Level 9

                                        colorSamplers[0].colors.rgb.red

                                        would be the input value for the red black point in the example, the other input values for the black and white point can be determined accordingly.

                                        • 17. Re: Color samplers - dark, light & grey point - how to adjust curves
                                          bala281972 Level 1

                                          Thanks. will check it out and guidance on how to calculate output values pl

                                          • 18. Re: Color samplers - dark, light & grey point - how to adjust curves
                                            c.pfaffenbichler Level 9

                                            The output values should be obvious for the white and black point, just look at the last script I posted.

                                            The output for the gray points is also clear (127),  unfortunately the input values mystify me.

                                            • 19. Re: Color samplers - dark, light & grey point - how to adjust curves
                                              bala281972 Level 1

                                              [0,255][0,255],[0,255] represents midpoint is it?

                                              • 20. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                c.pfaffenbichler Level 9

                                                No, they represent the output values for the black and white points for red, green and blue.

                                                Again: The first array lists the input values for red, the second the output values for red, the second the input values for green and so on.

                                                So this function takes six arrays as arguments.

                                                The arrays could have more values, if you wanted to include them.

                                                • 21. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                  bala281972 Level 1

                                                  Does this point makes sense?

                                                  dark 28, 11, 14

                                                  light 255, 255, 255

                                                  mid 161, 120, 85

                                                  Kate-Hudson-Smiling-Against-Pale-Pink-Photo-Shoot-kate-hudson-9695712-1591-2003-new.jpg

                                                  • 22. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                    bala281972 Level 1

                                                    can you suggests me the array values for these points pl, i'm kinda confused.

                                                    • 23. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                      c.pfaffenbichler Level 9

                                                      Like I said, I don’t know how to set the gray point because it seems to use different values than the selected pixel’s.

                                                      #target photoshop
                                                      var sampler1 = app.activeDocument.colorSamplers[0].color.rgb;
                                                      var sampler2 = app.activeDocument.colorSamplers[2].color.rgb;
                                                      var theArray = [[sampler1.red, sampler2.red], [0, 255], [sampler1.green, sampler2.green], [0, 255], [sampler1.blue, sampler2.blue], [0, 255]];
                                                      rgbCurvesLayer (theArray);
                                                      ////// make rgb curves layer //////
                                                      function rgbCurvesLayer (theArray) {
                                                      // =======================================================
                                                      var idMk = charIDToTypeID( "Mk  " );
                                                          var desc5 = new ActionDescriptor();
                                                          var idnull = charIDToTypeID( "null" );
                                                              var ref2 = new ActionReference();
                                                              var idAdjL = charIDToTypeID( "AdjL" );
                                                              ref2.putClass( idAdjL );
                                                          desc5.putReference( idnull, ref2 );
                                                          var idUsng = charIDToTypeID( "Usng" );
                                                              var desc6 = new ActionDescriptor();
                                                              var idType = charIDToTypeID( "Type" );
                                                                  var desc7 = new ActionDescriptor();
                                                                  var idpresetKind = stringIDToTypeID( "presetKind" );
                                                                  var idpresetKindType = stringIDToTypeID( "presetKindType" );
                                                                  var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
                                                                  desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
                                                              var idCrvs = charIDToTypeID( "Crvs" );
                                                              desc6.putObject( idType, idCrvs, desc7 );
                                                          var idAdjL = charIDToTypeID( "AdjL" );
                                                          desc5.putObject( idUsng, idAdjL, desc6 );
                                                      executeAction( idMk, desc5, DialogModes.NO );
                                                      // =======================================================
                                                      var idsetd = charIDToTypeID( "setd" );
                                                          var desc8 = new ActionDescriptor();
                                                          var idnull = charIDToTypeID( "null" );
                                                              var ref3 = new ActionReference();
                                                              var idAdjL = charIDToTypeID( "AdjL" );
                                                              var idOrdn = charIDToTypeID( "Ordn" );
                                                              var idTrgt = charIDToTypeID( "Trgt" );
                                                              ref3.putEnumerated( idAdjL, idOrdn, idTrgt );
                                                          desc8.putReference( idnull, ref3 );
                                                          var idT = charIDToTypeID( "T   " );
                                                              var desc9 = new ActionDescriptor();
                                                              var idpresetKind = stringIDToTypeID( "presetKind" );
                                                              var idpresetKindType = stringIDToTypeID( "presetKindType" );
                                                              var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
                                                              desc9.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );
                                                              var idAdjs = charIDToTypeID( "Adjs" );
                                                                  var list1 = new ActionList();
                                                                      var desc10 = new ActionDescriptor();
                                                                      var idChnl = charIDToTypeID( "Chnl" );
                                                                          var ref4 = new ActionReference();
                                                                          var idChnl = charIDToTypeID( "Chnl" );
                                                                          var idChnl = charIDToTypeID( "Chnl" );
                                                                          var idRd = charIDToTypeID( "Rd  " );
                                                                          ref4.putEnumerated( idChnl, idChnl, idRd );
                                                                      desc10.putReference( idChnl, ref4 );
                                                                      var idCrv = charIDToTypeID( "Crv " );
                                                                          var list2 = new ActionList();
                                                      // add r points;
                                                      for (var m = 0; m < theArray[0].length; m++) {
                                                                addCurvePoint (list2, theArray[0][m], theArray[1][m])
                                                                }; 
                                                                      desc10.putList( idCrv, list2 );
                                                                  var idCrvA = charIDToTypeID( "CrvA" );
                                                                  list1.putObject( idCrvA, desc10 );
                                                                      var desc15 = new ActionDescriptor();
                                                                      var idChnl = charIDToTypeID( "Chnl" );
                                                                          var ref5 = new ActionReference();
                                                                          var idChnl = charIDToTypeID( "Chnl" );
                                                                          var idChnl = charIDToTypeID( "Chnl" );
                                                                          var idGrn = charIDToTypeID( "Grn " );
                                                                          ref5.putEnumerated( idChnl, idChnl, idGrn );
                                                                      desc15.putReference( idChnl, ref5 );
                                                                      var idCrv = charIDToTypeID( "Crv " );
                                                                          var list3 = new ActionList();
                                                      // add g points;
                                                      for (var m = 0; m < theArray[2].length; m++) {
                                                                addCurvePoint (list3, theArray[2][m], theArray[3][m])
                                                                };
                                                                      desc15.putList( idCrv, list3 );
                                                                  var idCrvA = charIDToTypeID( "CrvA" );
                                                                  list1.putObject( idCrvA, desc15 );
                                                                      var desc20 = new ActionDescriptor();
                                                                      var idChnl = charIDToTypeID( "Chnl" );
                                                                          var ref6 = new ActionReference();
                                                                          var idChnl = charIDToTypeID( "Chnl" );
                                                                          var idChnl = charIDToTypeID( "Chnl" );
                                                                          var idBl = charIDToTypeID( "Bl  " );
                                                                          ref6.putEnumerated( idChnl, idChnl, idBl );
                                                                      desc20.putReference( idChnl, ref6 );
                                                                      var idCrv = charIDToTypeID( "Crv " );
                                                                          var list4 = new ActionList();
                                                      // add b points;
                                                      for (var m = 0; m < theArray[4].length; m++) {
                                                                addCurvePoint (list4, theArray[4][m], theArray[5][m])
                                                                };
                                                                      desc20.putList( idCrv, list4 );
                                                                  var idCrvA = charIDToTypeID( "CrvA" );
                                                                  list1.putObject( idCrvA, desc20 );
                                                              desc9.putList( idAdjs, list1 );
                                                          var idCrvs = charIDToTypeID( "Crvs" );
                                                          desc8.putObject( idT, idCrvs, desc9 );
                                                      executeAction( idsetd, desc8, DialogModes.NO );
                                                      //
                                                      return app.activeDocument.activeLayer;
                                                      ////// add curve point //////
                                                      function addCurvePoint (theList, valueHor, valueVer) {
                                                      var desc11 = new ActionDescriptor();
                                                      var idHrzn = charIDToTypeID( "Hrzn" );
                                                      desc11.putDouble( idHrzn, valueHor );
                                                      var idVrtc = charIDToTypeID( "Vrtc" );
                                                      desc11.putDouble( idVrtc, valueVer );
                                                      var idPnt = charIDToTypeID( "Pnt " );
                                                      theList.putObject( idPnt, desc11 );
                                                      };
                                                      };
                                                      
                                                      • 24. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                        bala281972 Level 1

                                                        oh NO, what to do now? how to set grey point value?

                                                        • 25. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                          bala281972 Level 1

                                                          I've changed this a bit due to sampler1-black, sampler2-represents-midtone, sampler3-represents-light

                                                          var sampler1 = app.activeDocument.colorSamplers[0].color.rgb;

                                                          var sampler2 = app.activeDocument.colorSamplers[2].color.rgb;

                                                          var sampler3 = app.activeDocument.colorSamplers[1].color.rgb;

                                                          var theArray = [[sampler1.red, sampler3.red], [0, 255], [sampler1.green, sampler3.green], [0, 255], [sampler1.blue, sampler3.blue], [0, 255]];

                                                           

                                                          I presume 0,255 means we are not changing the mid tone values

                                                          • 26. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                            c.pfaffenbichler Level 9

                                                            You seem to have defined a variable but then don’t use it.

                                                            • 27. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                              bala281972 Level 1

                                                              that's been reserved for mid point, since we still not got logic on how to use this i just declared it and never used. I'm trying various values but dont know how else to proceed. 0 is input but dont know what is 255

                                                               

                                                              any luck ?

                                                              • 28. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                                c.pfaffenbichler Level 9

                                                                0 and 255 are the output values for black and white.

                                                                • 29. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                                  bala281972 Level 1

                                                                  going mad looking at the codes CP, any thoughts on how to complete this ? should we give a try @ SL code for curves ? The Gamma values stood at R0.61 G1.17 & B1.39 Not sure how to set values

                                                                  • 30. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                                    Michael L Hale Level 5

                                                                    Sorry I am late to this party. The color values in the 3 colorSamplers should be used as the input values in the curve. The output values could be 0,127,255 assuming you want to set the black and white points to the min/max.

                                                                     

                                                                    Here is an example using the values I found in the post with the sample image. Note it assumes that a curve adjustment layer is the activeLayer.

                                                                     

                                                                    function setCurveAdjustmentChannel(curvePoints, channel){
                                                                        var IDMap = new Object();
                                                                          IDMap['CMP'] = charIDToTypeID( "Cmps" );
                                                                          IDMap['R'] = charIDToTypeID( "Rd  " );
                                                                          IDMap['G'] = charIDToTypeID( "Grn " );
                                                                          IDMap['B'] = charIDToTypeID( "Bl  " );
                                                                          IDMap['Y'] = charIDToTypeID( "Yllw" );
                                                                          IDMap['M'] = charIDToTypeID( "Mgnt" );
                                                                          IDMap['C'] = charIDToTypeID( "Cyn " );
                                                                          IDMap['K'] = charIDToTypeID( "Blck" );
                                                                    
                                                                            var desc = new ActionDescriptor();
                                                                                var ref = new ActionReference();
                                                                                ref.putEnumerated( charIDToTypeID( "AdjL" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
                                                                            desc.putReference( charIDToTypeID( "null" ), ref );
                                                                                var curveDesc = new ActionDescriptor();
                                                                                    var list = new ActionList();
                                                                                        var channelDesc = new ActionDescriptor();
                                                                                            var channelRef = new ActionReference();
                                                                                            channelRef.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), IDMap[channel] );// Note use "K" with greyscale mode
                                                                                        channelDesc.putReference( charIDToTypeID( "Chnl" ), channelRef );
                                                                    
                                                                                            var pointsList = new ActionList();
                                                                                               for(i=0;i<curvePoints.length;i++){
                                                                                                    var pointsDesc = new ActionDescriptor();
                                                                                                    pointsDesc.putDouble( charIDToTypeID( "Hrzn" ), curvePoints[i][0] );
                                                                                                    pointsDesc.putDouble( charIDToTypeID( "Vrtc" ), curvePoints[i][1] );
                                                                                                pointsList.putObject( charIDToTypeID( "Pnt " ), pointsDesc );}
                                                                                                
                                                                                        channelDesc.putList( charIDToTypeID( "Crv " ), pointsList );
                                                                                    list.putObject( charIDToTypeID( "CrvA" ), channelDesc );
                                                                                curveDesc.putList( charIDToTypeID( "Adjs" ), list );
                                                                            desc.putObject( charIDToTypeID( "T   " ), charIDToTypeID( "Crvs" ), curveDesc );
                                                                        executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
                                                                    };
                                                                    var curvePoints = new Array;
                                                                    curvePoints[0] = [28,0];// black
                                                                    curvePoints[1] = [161,127];// gray
                                                                    curvePoints[2] = [255,255];// white
                                                                    setCurveAdjustmentChannel(curvePoints,  "R");
                                                                    var curvePoints = new Array;
                                                                    curvePoints[0] = [11,0];
                                                                    curvePoints[1] = [120,127];
                                                                    curvePoints[2] = [255,255];
                                                                    setCurveAdjustmentChannel(curvePoints,  "G");
                                                                    var curvePoints = new Array;
                                                                    curvePoints[0] = [14,0];
                                                                    curvePoints[1] = [85,127];
                                                                    curvePoints[2] = [255,255];
                                                                    setCurveAdjustmentChannel(curvePoints,  "B");
                                                                    
                                                                    • 31. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                                      bala281972 Level 1

                                                                      Thanks for chipping in michael. Unfortunately im out of office and will update you in10 hrs

                                                                      • 32. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                                        bala281972 Level 1

                                                                        Awesome work Michael. Appreciate your efforts in taking trouble.

                                                                         

                                                                        CP, you have been very helpful though. I can see how much i've troubled you a lot with repeated questions. Appreciate your patience and i'm sure without your support i wouldnt have come through this level. Great Help.

                                                                         

                                                                        Hats off to both of you

                                                                        • 33. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                                          bala281972 Level 1

                                                                          Michael, i've a question too. If you read the previous posts, i've given SL code for levels dialog box, any idea how to plot points there? there were only 2 pts per channel not sure how to get the values for these points. Any calculation involved in it ?

                                                                          • 34. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                                            c.pfaffenbichler Level 9

                                                                            I’m afraid the gray point created by this script is not the same as if set manually at a point of the the value 161/120/85.

                                                                            It seems the gray point does not simply change the input values to 127 but is arrived at by some calculation, as I’ve mentioned before.

                                                                            • 35. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                                              c.pfaffenbichler Level 9

                                                                              To illustrate what I have been writing about I created an image that is only 161/120/85 and once used the Script that set those values to 127 and once set the gray point manually.

                                                                              grayPointSettingScr.jpg

                                                                              • 37. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                                                Michael L Hale Level 5

                                                                                Christoph, when you say 'set the gray point manually' do you mean using the input/output boxes? Or do you mean using the mid-tone eyedropper? I would expect the eyedropper to give a different result depending on the settings in the curve panel options and the brightness/luminosity of the color sampled. I think if the sampled color is not near mid-tone grey then there can be a difference between the resulting image with these two methods. The farther away from min-tone grey the bigger the difference. I think with enough effort it would be possible to come up with some forumla that gets the input/output values closer to the values used by the eyedropper.

                                                                                 

                                                                                I think a bigger problem is not so much how to change that color but do we really want to. In other words but we really think that sampler is at an area that should be a netural gray? It looks to me like that sampler is in the corner of an eye. Somewhere I would expect the color to be on the red/pink side of netural. I would think that the 'whites' of the eye or the teeth would be a better place set to netural.

                                                                                 

                                                                                I don't think that levels would be useful. You could set the black/white points with a levels adjustment layer. But as you can do that with curves as well as set the mid-tones I would just use curvres and have only one adjustment layer.

                                                                                • 38. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                                                  c.pfaffenbichler Level 9

                                                                                  Or do you mean using the mid-tone eyedropper?

                                                                                  Yes, I mean the »Sample in image to set gray point« eyedropper from the Curves dialog.

                                                                                  And the calculation that is performed on the picked pixel’s values (with default options) has eluded me so far.

                                                                                  • 39. Re: Color samplers - dark, light & grey point - how to adjust curves
                                                                                    bala281972 Level 1

                                                                                    Michael, could you try this image with your script. Something seems to be wrong.MAJ STATE CAPITOL.JPG

                                                                                    1 2 Previous Next