1 importClass( Packages.lenscorrection.DistortionCorrectionTask );
2 importClass( Packages.ini.trakem2.display.Display );
3 importClass( Packages.ini.trakem2.display.Patch );
4 importPackage( Packages.mpicbg.trakem2.transform );
6 /** Remove all coordinate transforms from all patches in the layer set */
7 var layers = Display.getFront().getSelection().getLayer().getParent().getLayers();
8 for ( var i = 0; i < layers.size(); ++i )
10 var patches = layers.get( i ).getDisplayables( Patch );
11 for ( var j = 0; j < patches.size(); ++j )
13 var patch = patches.get( j );
14 patch.setCoordinateTransform( null );
15 patch.updateMipmaps();
19 /** Apply a distortion */
20 //var m = new MovingLeastSquaresTransform();
21 //m.init( "rigid 1 100 100 200 200 1150 1150 1050 1050 1150 100 950 100" );
22 //var mi = new MovingLeastSquaresTransform();
23 //mi.init( "rigid 1 200 200 100 100 1050 1050 1150 1150 950 100 1150 100" );
24 //m.init( "rigid 1 100 100 120 120 1150 1150 1130 1130 1150 100 1130 100" );
25 var m = new TranslationModel2D();
27 for ( var i = 0; i < layers.size(); ++i )
29 var patches = layers.get( i ).getDisplayables( Patch );
30 for ( var j = 0; j < patches.size(); ++j )
32 var patch = patches.get( j );
33 patch.setCoordinateTransform( m );
34 patch.updateMipmaps();
41 /** Estimate and apply distortion correction model */
42 DistortionCorrectionTask.correctDistortionFromSelection( Display.getFront().getSelection() );