本文整理汇总了Java中mpicbg.models.AffineModel2D类的典型用法代码示例。如果您正苦于以下问题:Java AffineModel2D类的具体用法?Java AffineModel2D怎么用?Java AffineModel2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AffineModel2D类属于mpicbg.models包,在下文中一共展示了AffineModel2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRenderScaleAndOffset
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
/**
* Modifies the specified full scale transform list for the current render context by
* adding a transform for bounding box offset, scale, and an area offset (for scaled mipmaps).
*
* @param renderTransformList list of transforms for full scale (and un-clipped) canvas.
* @param levelZeroScale scale factor for transformed components at mipmap level 0.
* @param actualMipmapScale scale factor for transformed components at desired mipmap level.
* @param x target image left coordinate.
* @param y target image top coordinate.
*/
public static CoordinateTransformList<CoordinateTransform> addRenderScaleAndOffset(
final CoordinateTransformList<CoordinateTransform> renderTransformList,
final double levelZeroScale,
final double actualMipmapScale,
final double x,
final double y) {
final AffineModel2D scaleAndOffset = new AffineModel2D();
// always calculate areaOffset for mipmaps
final double areaOffset = (1 - (actualMipmapScale / levelZeroScale)) * 0.5;
scaleAndOffset.set(actualMipmapScale,
0,
0,
actualMipmapScale,
-(x * actualMipmapScale + areaOffset),
-(y * actualMipmapScale + areaOffset));
renderTransformList.add(scaleAndOffset);
return renderTransformList;
}
示例2: addTriangle
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
final static protected void addTriangle(
final ArrayList< Pair< AffineModel2D, double[][] > > av,
final double[][] pq,
final int i1,
final int i2,
final int i3) {
final double[][] pqTriangle = new double[][]{
{pq[0][i1], pq[0][i2], pq[0][i3]},
{pq[1][i1], pq[1][i2], pq[1][i3]},
{pq[2][i1], pq[2][i2], pq[2][i3]},
{pq[3][i1], pq[3][i2], pq[3][i3]}
};
av.add(new Pair<AffineModel2D, double[][]>(new AffineModel2D(), pqTriangle));
}
示例3: MovingLeastSquaresBuilder
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
/**
* Derives center point matches between the two specified tile lists using tileId to correlate the tiles.
* The {@link #call} method can then be used to derive a moving least squares transform instance
* from the point matches.
*
* @param montageTiles collection of tiles from a montage stack.
* @param alignTiles collection of tiles from an align stack.
* @param alpha transform alpha (optional, default is 1.0)
*/
public MovingLeastSquaresBuilder(final Collection<TileSpec> montageTiles,
final Collection<TileSpec> alignTiles,
final Double alpha) {
readTileSpecs(montageTiles, alignTiles);
if (w.length == 1) {
modelClass = TranslationModel2D.class;
} else if (w.length == 2) {
modelClass = SimilarityModel2D.class;
} else {
modelClass = AffineModel2D.class;
}
this.alpha = alpha;
}
示例4: sampleAverageScale
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
/**
* Sample the average scaling of a given {@link CoordinateTransform} by transferring a set of point samples using
* the {@link CoordinateTransform} and then least-squares fitting a {@link SimilarityModel2D} to it.
*
* @param width of the samples set
* @param height of the samples set
* @param dx spacing between samples
*
* @return average scale factor
*/
public static double sampleAverageScale(final CoordinateTransform ct,
final int width,
final int height,
final double dx) {
final ArrayList<PointMatch> samples = new ArrayList<>();
for (double y = 0; y < height; y += dx) {
for (double x = 0; x < width; x += dx) {
final Point p = new Point(new double[]{x, y});
p.apply(ct);
samples.add(new PointMatch(p, p));
}
}
final AffineModel2D model = new AffineModel2D();
try {
model.fit(samples);
} catch (final NotEnoughDataPointsException | IllDefinedDataPointsException e) {
LOG.warn("failed to fit samples, returning scale factor of 1", e);
return 1;
}
final double[] data = new double[6];
model.toArray(data);
// return 1;
return Math.sqrt(Math.max(data[0] * data[0] + data[1] * data[1], data[2] * data[2] + data[3] * data[3]));
}
示例5: testRANSACFilterWithMinValue
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
private void testRANSACFilterWithMinValue(final List<PointMatch> candidates,
final int minNumInliers,
final int expectedInliersSizeAfterFilter)
throws NotEnoughDataPointsException {
final List<PointMatch> inliers = new ArrayList<>();
final int iterations = 1000;
final float maxEpsilon = 20f;
final float minInlierRatio = 0.0f;
final float maxTrust = 3.0f;
final AffineModel2D model = new AffineModel2D();
model.filterRansac(candidates,
inliers,
iterations,
maxEpsilon,
minInlierRatio,
minNumInliers,
maxTrust);
Assert.assertEquals("invalid number of inliers found with min " + minNumInliers,
expectedInliersSizeAfterFilter, inliers.size());
}
示例6: initModel
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
@SuppressWarnings( "rawtypes" )
@Override
protected void initModel()
{
final AffineTransform a = patch.getAffineTransform();
if ( AffineModel2D.class.isInstance( model ) )
( ( AffineModel2D )( Object )model ).set( a );
else if ( SimilarityModel2D.class.isInstance( model ) )
( ( SimilarityModel2D )( Object )model ).set( a.getScaleX(), a.getShearY(), a.getTranslateX(), a.getTranslateY() );
else if ( RigidModel2D.class.isInstance( model ) )
( ( RigidModel2D )( Object )model ).set( a.getScaleX(), a.getShearY(), a.getTranslateX(), a.getTranslateY() );
else if ( TranslationModel2D.class.isInstance( model ) )
( ( TranslationModel2D )( Object )model ).set( a.getTranslateX(), a.getTranslateY() );
else if ( InterpolatedAffineModel2D.class.isInstance( model ) )
( ( InterpolatedAffineModel2D )( Object )model ).set( a );
}
示例7: createMLST
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
/**
* Temporary helper method that creates
* @param matches
* @param alpha
* @return
* @throws Exception
*/
final static public MovingLeastSquaresTransform2 createMLST( final Collection< PointMatch > matches, final double alpha ) throws Exception
{
final MovingLeastSquaresTransform2 mlst = new MovingLeastSquaresTransform2();
mlst.setAlpha( alpha );
Class< ? extends AbstractAffineModel2D< ? > > c = AffineModel2D.class;
switch ( matches.size() )
{
case 1:
c = TranslationModel2D.class;
break;
case 2:
c = SimilarityModel2D.class;
break;
default:
break;
}
mlst.setModel( c );
mlst.setMatches( matches );
return mlst;
}
示例8: setupWarpMagBaselineOptions
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
protected void setupWarpMagBaselineOptions( final CoordinateTransform[] xfm, final int ndim )
{
if ( ndim == 2 )
{
xfm[ 0 ] = new AffineModel2D();
xfm[ 1 ] = new SimilarityModel2D();
xfm[ 2 ] = new RigidModel2D();
}
else
{
xfm[ 0 ] = new AffineModel3D();
xfm[ 1 ] = new SimilarityModel3D();
xfm[ 2 ] = new RigidModel3D();
}
}
示例9: getFullScaleRelativeModel
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
/**
* Uses this stack's scale and the specified aligned stack bounds to convert the specified affine to a
* full scale version that can be used in an {@link org.janelia.alignment.transform.AffineWarpFieldTransform}.
*
* @param alignedLayerTransformModel scaled aligned model to convert.
* @param alignedStackMinX minimum X value for the (scaled) aligned stack.
* @param alignedStackMinY minimum Y value for the (scaled) aligned stack.
*
* @return full scale relative version of the specified model.
*/
@JsonIgnore
public AffineModel2D getFullScaleRelativeModel(final AffineModel2D alignedLayerTransformModel,
final double alignedStackMinX,
final double alignedStackMinY) {
final AffineTransform affine = new AffineTransform();
affine.scale(1 / scale, 1 / scale);
affine.translate(-alignedStackMinX, -alignedStackMinY);
affine.concatenate(alignedLayerTransformModel.createAffine());
affine.scale(scale, scale);
final AffineModel2D model = new AffineModel2D();
model.set(affine);
return model;
}
示例10: scaleTarget
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
/**
* Scale all vertex coordinates in target space
*
* @param scale
*/
public void scaleTarget(final double scale) {
for (final Pair<AffineModel2D, double[][]> apq : av)
for (int j = 0; j < apq.b[2].length; ++j) {
apq.b[2][j] *= scale;
apq.b[3][j] *= scale;
}
}
示例11: translate
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
/**
* Translate all vertex coordinates
*
* @param scale
*/
public void translate(final double x, final double y) {
for (final Pair<AffineModel2D, double[][]> apq : av)
for (int j = 0; j < apq.b[2].length; ++j) {
apq.b[0][j] += x;
apq.b[1][j] += y;
apq.b[2][j] += x;
apq.b[3][j] += y;
}
}
示例12: translateTarget
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
/**
* Scale all vertex coordinates
*
* @param scale
*/
public void translateTarget(final double x, final double y) {
for (final Pair<AffineModel2D, double[][]> apq : av)
for (int j = 0; j < apq.b[2].length; ++j) {
apq.b[2][j] += x;
apq.b[3][j] += y;
}
}
示例13: MapTriangleThread
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
MapTriangleThread(final AtomicInteger i,
final List<Pair<AffineModel2D, double[][]>> triangles,
final PixelMapper pixelMapper) {
this.i = i;
this.triangles = triangles;
this.pixelMapper = pixelMapper;
}
示例14: createScaleLevelTransform
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
/**
* Create an affine transformation that compensates for both scale and pixel shift of a mipmap level that was
* generated by top-left pixel averaging.
*/
public static AffineModel2D createScaleLevelTransform(final int scaleLevel) {
final AffineModel2D a = new AffineModel2D();
final int scale = 1 << scaleLevel;
final double t = (scale - 1) * 0.5;
a.set(scale, 0, 0, scale, t, t);
return a;
}
示例15: testGetFullScaleRelativeModel
import mpicbg.models.AffineModel2D; //导入依赖的package包/类
@Test
public void testGetFullScaleRelativeModel() throws Exception {
final int tier = 1;
final Integer tierRow = 0;
final Integer tierColumn = 1;
final Integer totalTierRowCount = 3;
final Integer totalTierColumnCount = 3;
final Double scale = 0.33133797120207087;
final Bounds fullScaleBounds = new Bounds(59816.0, 64495.0, 1.0, 64678.0, 70676.0, 3.0);
final StackId roughTilesStackId = new StackId("testOwner", "tilesProject", "roughTiles");
final HierarchicalStack tier1Stack =
new HierarchicalStack(roughTilesStackId,
tier,
tierRow,
tierColumn,
totalTierRowCount,
totalTierColumnCount,
scale,
fullScaleBounds);
final AffineModel2D model = getModel(1.000018855057, -0.000005117870,
-0.000003681924, 1.000001492098,
26.995723857002, 6.610488526292);
final double[] expectedArray = new double[6];
model.toArray(expectedArray);
expectedArray[4] = expectedArray[4] / scale;
expectedArray[5] = expectedArray[5] / scale;
final AffineModel2D relativeModel = tier1Stack.getFullScaleRelativeModel(model, 0, 0);
final double[] array = new double[6];
relativeModel.toArray(array);
for (int i = 0; i < expectedArray.length; i++) {
Assert.assertEquals("invalid value for index " + i, expectedArray[i], array[i], 0.0001);
}
}