本文整理汇总了Java中mpicbg.models.AffineModel2D.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java AffineModel2D.toArray方法的具体用法?Java AffineModel2D.toArray怎么用?Java AffineModel2D.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpicbg.models.AffineModel2D
的用法示例。
在下文中一共展示了AffineModel2D.toArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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]));
}
示例2: 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);
}
}
示例3: call
import mpicbg.models.AffineModel2D; //导入方法依赖的package包/类
@Override
public Integer call(final Double z)
throws Exception {
LogUtilities.setupExecutorLog4j(z.toString());
final StackId alignedStackId = tierZeroStack.getAlignedStackId();
final RenderDataClient alignedDataClient =
new RenderDataClient(baseDataUrl,
alignedStackId.getOwner(),
alignedStackId.getProject());
final StackMetaData alignedStackMetaData = alignedDataClient.getStackMetaData(alignedStackId.getStack());
final Bounds alignedStackBounds = alignedStackMetaData.getStats().getStackBounds();
final ResolvedTileSpecCollection tileSpecCollection =
alignedDataClient.getResolvedTiles(alignedStackId.getStack(), z);
if (tileSpecCollection.getTileCount() != 1) {
throw new IllegalArgumentException("layer " + z + " in " + alignedStackId + " has " +
tileSpecCollection.getTileCount() + " tile specs (should only be one)");
}
final TileSpec layerTileSpec = tileSpecCollection.getTileSpecs().iterator().next();
final TransformSpec roughAlignmentTransform;
final TransformSpec lastTransform = layerTileSpec.getLastTransform();
final CoordinateTransform transformInstance = lastTransform.getNewInstance();
if (transformInstance instanceof AffineModel2D) {
final AffineModel2D scaledAffineModel = (AffineModel2D) transformInstance;
final AffineModel2D fullScaleRelativeModel =
tierZeroStack.getFullScaleRelativeModel(scaledAffineModel,
alignedStackBounds.getMinX(),
alignedStackBounds.getMinY());
final double[] affineMatrixElements = new double[6];
fullScaleRelativeModel.toArray(affineMatrixElements);
final mpicbg.trakem2.transform.AffineModel2D specModel = new mpicbg.trakem2.transform.AffineModel2D();
specModel.set(fullScaleRelativeModel);
final String roughTransformId = "z_" + z + "_ROUGH_ALIGN";
roughAlignmentTransform = new LeafTransformSpec(roughTransformId,
null,
specModel.getClass().getName(),
specModel.toDataString());
} else {
throw new IllegalArgumentException("last transform for tileId '" + layerTileSpec.getTileId() +
"' is a " + transformInstance.getClass().getName() + " instance");
}
final StackId montageStackId = tierZeroStack.getParentTierStackId();
final RenderDataClient montageDataClient =
new RenderDataClient(baseDataUrl,
montageStackId.getOwner(),
montageStackId.getProject());
final ResolvedTileSpecCollection tileCollection =
montageDataClient.getResolvedTiles(montageStackId.getStack(), z);
tileCollection.addTransformSpecToCollection(roughAlignmentTransform);
tileCollection.addReferenceTransformToAllTiles(roughAlignmentTransform.getId(), false);
final RenderDataClient roughDataClient =
new RenderDataClient(baseDataUrl,
roughStackId.getOwner(),
roughStackId.getProject());
roughDataClient.saveResolvedTiles(tileCollection, roughStackId.getStack(), z);
return tileCollection.getTileCount();
}