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

Accuracy of rotating images in Photoshop

New Here ,
Dec 02, 2019 Dec 02, 2019

Hello,

I'm using Photoshop in my thesis and therefore I need to know how accurate Photoshop rotates images. For example if I tell Photoshop rotate my image 10 degrees, to which decimal place are the 10 degrees exact.

Thank you for your help!

 

{Thread renamed by moderator}

2.7K
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

correct answers 2 Correct answers

People's Champ , Dec 02, 2019 Dec 02, 2019
Why do you need such accuracy?
You want to rotate the rotated smart object back to 0 degrees? Manually doing this in most cases is impossible, especially if, in addition to rotation, there were also displacements.

P.S. Remove the ScriptListener plugin, otherwise the log will grow to infinity and slow down the program.
 
Translate
Community Expert , Dec 05, 2019 Dec 05, 2019

Okay, taking r-bin's suggestion to use a vector point rather than a pixel bounds point, I redid the script. Set up is pretty much as before, except no groups. just a straight line shape layer (2 points only), named "Orig." Duplicate that layer and leave the name as "Orig copy" then rotate that layer and run the script. It's much more accurate!

 

 

#target photoshop
var doc = activeDocument;

var origLay = doc.layers.getByName('Orig');
var moveLay = doc.layers.getByName('Orig copy');

doc.activeL
...
Translate
Adobe
Adobe Employee ,
Dec 02, 2019 Dec 02, 2019

Hi Kim,

 

You can insert the degree on the options bar on the top, make sure that you have the image in Transform mod by hitting Ctrl (Win)/ CMD (macOS) + T on the keyboard.

Screenshot_7.jpg

 

Let us know how it goes.
Regards,
Sahil

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
New Here ,
Dec 02, 2019 Dec 02, 2019

Thank you for your answer. Unfortunately that doesn't help me, because I know how to rotate images. What I need to know is if I tipe in 10 degrees where you just described. To which decimal place the 10 degrees are accurate. For example if it's 10,0001 or 10,0000001 or if there is any other error.

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
Community Expert ,
Dec 02, 2019 Dec 02, 2019

How good the rotation will be I believe would be more  a matter of how many pixels you for your for the image lots of pixels foe a high resolution print and the interpretation method you use for the image's content. In the transform you can move the rotation point and the angle you enter can be to several decimals places.  Your rotating square pixels and the resulting image will have square pixels that are squared to the canvas the images has to be interpolated. Image content will rotate off  canvas and some  areas of the canvas will not have image content.  

JJMack
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
New Here ,
Dec 02, 2019 Dec 02, 2019

My image has 2448x2050 pixels and is a bmp file. I used the bicubic interpolation.

Yes I noticed that the image has some white areas once I've turned it, but for my case it doesn't matter, because I am looking at fibre angles which are shown in the image and my other software puts a grid on the image to measure the fibre angles and that grid is small enough that it won't cover any white areas.

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
People's Champ ,
Dec 02, 2019 Dec 02, 2019

ScriptListener plugin records your rotation

example

d.putUnitDouble(stringIDToTypeID("angle"), stringIDToTypeID("angleUnit"), 7.25380180288289);

 

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
New Here ,
Dec 02, 2019 Dec 02, 2019

That could work. I downloaded the plug-in and now I've got two .log files on my desktop. How excacly can I read the angle of of them, because they don't seem to chance when I turn images in Photoshop.

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
Community Expert ,
Dec 02, 2019 Dec 02, 2019

One log file is for javascript, the other is visual basic. Using the javascript one, you have to have the scriptListener plugin activated and recording. You have to commit to the rotation, then you have to reopen the log file to read what angle was recorded: looking for code that matched what r-bin posted in his response. 

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
Community Expert ,
Dec 02, 2019 Dec 02, 2019

That is quite a few places.  Interpolation play a big part.  Nearest neighbor is crude so it will demonstrate well. Here I created  small image and zoomed in then rotate 4 degrees them added . with every decimal value I entered the image interpolation changed Photoshop precision is good. The interpretation method used does not try to anti-alas or smooth in any way.

Capture.jpg 

JJMack
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
New Here ,
Dec 02, 2019 Dec 02, 2019

Do you know how accurate the bicubic method works.

That's what I did and know want to know if Photoshop turned my picture exactly

img.PNGimg2.PNG

 
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
People's Champ ,
Dec 02, 2019 Dec 02, 2019
Why do you need such accuracy?
You want to rotate the rotated smart object back to 0 degrees? Manually doing this in most cases is impossible, especially if, in addition to rotation, there were also displacements.

P.S. Remove the ScriptListener plugin, otherwise the log will grow to infinity and slow down the program.
 
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
New Here ,
Dec 02, 2019 Dec 02, 2019

The other software is the software I want to vaildate the absolute accuracy of. That software measures the fibre angles and calculates an average. I let the software evaluate on picture then I turn the image with Photoshop 10 degrees and let the other software evaluate it again. Now the other software should detect a 10 degrees difference in the fibre angle. But because it not alsway detects an exacly 10 degrees difference, so I need to know how big the error of Photoshop is to determine how big the error of my other software is.

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
Community Expert ,
Dec 03, 2019 Dec 03, 2019

The thing if you rotate an images the layers  pixels have been interpolated and if it not a smart object layer its a destructive process you have a new interpolated image not the original image. If its a smart object layer the original image is still in the object.  Evert time you transform a smart object layer you are editing the smart object layer associated layer transform which transform the smart object for the layers pixels. So if you rotate the layer  back to  0 degrees or to   full 360 you will wind up with the original layer's image pixels.  At any other rotation you have a different Picture.  If its not an smart object layer rotation is a destructive process. Every time you rotate the layer you will lose some additional image quality the image quality will degrade with each rotation.,

JJMack
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
Community Expert ,
Dec 02, 2019 Dec 02, 2019

Here is an example of using ScriptListener to read the rotation angle. I used Transform to capture the info. The angle measurement is the 4th line from the bottom.

// =======================================================
var idTrnf = charIDToTypeID( "Trnf" );
    var desc9 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idPath = charIDToTypeID( "Path" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref1.putEnumerated( idPath, idOrdn, idTrgt );
    desc9.putReference( idnull, ref1 );
    var idFTcs = charIDToTypeID( "FTcs" );
    var idQCSt = charIDToTypeID( "QCSt" );
    var idQcsa = charIDToTypeID( "Qcsa" );
    desc9.putEnumerated( idFTcs, idQCSt, idQcsa );
    var idOfst = charIDToTypeID( "Ofst" );
        var desc10 = new ActionDescriptor();
        var idHrzn = charIDToTypeID( "Hrzn" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc10.putUnitDouble( idHrzn, idPxl, 0.000000 );
        var idVrtc = charIDToTypeID( "Vrtc" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc10.putUnitDouble( idVrtc, idPxl, 0.000000 );
    var idOfst = charIDToTypeID( "Ofst" );
    desc9.putObject( idOfst, idOfst, desc10 );
    var idAngl = charIDToTypeID( "Angl" );
    var idAng = charIDToTypeID( "#Ang" );
    desc9.putUnitDouble( idAngl, idAng, 23.008041 );
    var idLnkd = charIDToTypeID( "Lnkd" );
    desc9.putBoolean( idLnkd, true );
executeAction( idTrnf, desc9, DialogModes.NO );
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
People's Champ ,
Dec 02, 2019 Dec 02, 2019
If you take two identical layers and rotate the first one with this script by 10.000000 degrees, and the second by 10.000001.

 

desc9.putUnitDouble (idAngl, idAng, 10.000001)

then you will see that the result is different (use the difference mode enhanced by leves to see the result).

So it turns quite accurately.
A third-party program may rotate according to a different algorithm, therefore, it believes that the original image is rotated to a slightly different angle.

 

 
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
LEGEND ,
Dec 02, 2019 Dec 02, 2019

It depends on the size of the image. Rotate a 4x4 pixel image 10 degrees and let me know how that works out for you.

 

If you know how to do geometry and trig, you can easily calculate how far a given pixel moves for a specific rotation. I bet Mathematica could give you an accuracy level based on image size. Also remember that you don't have to use square pixels.

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
Community Expert ,
Dec 02, 2019 Dec 02, 2019

That's right. The accuracy obviously depends on the resolution. The more pixels, the more accurate, as Lumigraphics' 4x4 example clearly demonstrates.

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
New Here ,
Dec 02, 2019 Dec 02, 2019

Do you think I could say it only depends on the pixel size or do you know if the bicubic interpolation also influences that accuracy I get out of the pixels?

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
Community Expert ,
Dec 03, 2019 Dec 03, 2019

Here's something that might be fun. I modified a script that I use to place shapes. it measures the angle between two reference dots. So to use this script, you need to create a group with the name "Orig" - capitalize the "O." in this group, create two round shape layers - best to draw one then copy it. Shape layers won't degrade if you keep changing image size. Move one of the shape dots while holding the shift key, just to keep them aligned. if you want, you can draw a line between the two dots, just for ease of viewing, but the line has to be on the bottom of the layer stack in the group. Now duplicate the group, and leave the name as "Orig copy." Rotate the copy group with transform, then run the script. It should alert you to how much the one group was moved. The results do vary depending on the size of the file, and are slightly off from what scriptlistener says the rotation was. Here's a screen shot of my setup:

rotate measurement.jpg

 

Here's the script:

 

#target photoshop
var doc = activeDocument;

var origGp = doc.layers.getByName('Orig');
var moveGp = doc.layers.getByName('Orig copy');
var origPt1 = getRefPoints(origGp.layers[0]);
var origPt2 = getRefPoints(origGp.layers[1]);
var movePt1 = getRefPoints(moveGp.layers[0]);
var movePt2 = getRefPoints(moveGp.layers[1]);

var ang1 = getAng (movePt1[0], movePt1[1], movePt2[0], movePt2[1])+270
var ang2 = getAng (origPt1[0], origPt1[1], origPt2[0], origPt2[1])+270
alert (ang2-ang1)


function getRefPoints(ref){
    var x = (ref.bounds[0].value + ref.bounds[2].value)/2
    var y = (ref.bounds[1].value + ref.bounds[3].value)/2
    var pt = new Array(x,y)
    return pt
    }

 function getAng(x1,y1,x2,y2){
     
     var deltaX = x2-x1
     var deltaY = y2-y1
     //var theta = Math.atan2 (deltaY, deltaX)
     var angGA = (Math.atan2 (deltaY, deltaX))*-180 /Math.PI

     return angGA
     }

 

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
LEGEND ,
Dec 05, 2019 Dec 05, 2019

I bet a Postscript file could be created to do the same thing, and that would likely be the most accurate in terms of resolution.

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
People's Champ ,
Dec 05, 2019 Dec 05, 2019
Try changing your script using the coordinates of the vector points rather than the bounds of the layer to calculate the angle, because bounds is always an integer and multiply rounded by an integer number of pixels.
 
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
Community Expert ,
Dec 05, 2019 Dec 05, 2019

Good idea, r-bin.

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
Community Expert ,
Dec 05, 2019 Dec 05, 2019

Okay, taking r-bin's suggestion to use a vector point rather than a pixel bounds point, I redid the script. Set up is pretty much as before, except no groups. just a straight line shape layer (2 points only), named "Orig." Duplicate that layer and leave the name as "Orig copy" then rotate that layer and run the script. It's much more accurate!

 

 

#target photoshop
var doc = activeDocument;

var origLay = doc.layers.getByName('Orig');
var moveLay = doc.layers.getByName('Orig copy');

doc.activeLayer = origLay;
var origPath = doc.pathItems[0].subPathItems[0];
var origPt = getNodes(origPath);

doc.activeLayer = moveLay;
var movePath = doc.pathItems[0].subPathItems[0];
var movePt = getNodes(movePath);

var ang1 = getAng (movePt[0][0], movePt[0][1], movePt[1][0], movePt[1][1])+270
var ang2 = getAng (origPt[0][0], origPt[0][1], origPt[1][0], origPt[1][1])+270
alert (ang2-ang1)


 function getAng(x1,y1,x2,y2,deg){
     
     var deltaX = x2-x1
     var deltaY = y2-y1
     var angGA = (Math.atan2 (deltaY, deltaX))*-180 /Math.PI

     return angGA
     }
 
 function getNodes(pth){
     var array = [];
    for(var i=0;i<pth.pathPoints.length;i++){
        array[i]=pth.pathPoints[i].anchor
        }  
    return array;
    }

 

 

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
Community Expert ,
Dec 05, 2019 Dec 05, 2019
LATEST

Rotating Shape Layer, Rotating Smart Object Layer, and Rotating Raster Layer would see different results.  Rotating  Shapes would work best results would be excellent. 

Capture.jpg

 

JJMack
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