Hej everyone,
I'm working on a script, which should do an automatic perspective correction. Unfortunately the only way I found out until now is some code, generated with the ScriptListener Plugin - and I am having a hard time figuring out what the values / maths are doing. For better understanding what I'm trying to achieve, here is an image:
The yellow colored area is the original image. Green is the image I'm trying to get. I need to do an perspective correction on the top anchor points. Doing it manually it works fine. However, when I look at the script, the scriptListener is generating, I don't have any clue what the values in there are meaning. Perhaps there is some kind of math I don't get. I can't get any match regarding the values by doing it manually, and the ones the listener writes.
Anyone an idea? Is there anywhere an angle or distance of how the anchor points are being moved?
var idTrnf = charIDToTypeID( "Trnf" ); var desc48 = new ActionDescriptor(); var idnull = charIDToTypeID( "null" ); var ref21 = new ActionReference(); var idLyr = charIDToTypeID( "Lyr " ); var idOrdn = charIDToTypeID( "Ordn" ); var idTrgt = charIDToTypeID( "Trgt" ); ref21.putEnumerated( idLyr, idOrdn, idTrgt ); desc48.putReference( idnull, ref21 ); var idFTcs = charIDToTypeID( "FTcs" ); var idQCSt = charIDToTypeID( "QCSt" ); var idQcsa = charIDToTypeID( "Qcsa" ); desc48.putEnumerated( idFTcs, idQCSt, idQcsa ); var idOfst = charIDToTypeID( "Ofst" ); var desc49 = new ActionDescriptor(); var idHrzn = charIDToTypeID( "Hrzn" ); var idPxl = charIDToTypeID( "#Pxl" ); desc49.putUnitDouble( idHrzn, idPxl, -16.066570 ); var idVrtc = charIDToTypeID( "Vrtc" ); var idPxl = charIDToTypeID( "#Pxl" ); desc49.putUnitDouble( idVrtc, idPxl, 16.381048 ); var idOfst = charIDToTypeID( "Ofst" ); desc48.putObject( idOfst, idOfst, desc49 ); var idWdth = charIDToTypeID( "Wdth" ); var idPrc = charIDToTypeID( "#Prc" ); desc48.putUnitDouble( idWdth, idPrc, 134.475806 ); var idSkew = charIDToTypeID( "Skew" ); var desc50 = new ActionDescriptor(); var idHrzn = charIDToTypeID( "Hrzn" ); var idAng = charIDToTypeID( "#Ang" ); desc50.putUnitDouble( idHrzn, idAng, 19.127500 ); var idVrtc = charIDToTypeID( "Vrtc" ); var idAng = charIDToTypeID( "#Ang" ); desc50.putUnitDouble( idVrtc, idAng, 0.000000 ); var idPnt = charIDToTypeID( "Pnt " ); desc48.putObject( idSkew, idPnt, desc50 ); var idUsng = charIDToTypeID( "Usng" ); var desc51 = new ActionDescriptor(); var idHrzn = charIDToTypeID( "Hrzn" ); var idPrc = charIDToTypeID( "#Prc" ); desc51.putUnitDouble( idHrzn, idPrc, -0.000000 ); var idVrtc = charIDToTypeID( "Vrtc" ); var idPrc = charIDToTypeID( "#Prc" ); desc51.putUnitDouble( idVrtc, idPrc, 0.655242 ); var idPnt = charIDToTypeID( "Pnt " ); desc48.putObject( idUsng, idPnt, desc51 ); var idIntr = charIDToTypeID( "Intr" ); var idIntp = charIDToTypeID( "Intp" ); var idbicubicAutomatic = stringIDToTypeID( "bicubicAutomatic" ); desc48.putEnumerated( idIntr, idIntp, idbicubicAutomatic ); executeAction( idTrnf, desc48, DialogModes.NO );