-
Notifications
You must be signed in to change notification settings - Fork 42
Real transform #533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Real transform #533
Changes from 1 commit
9185384
b882573
adb01b8
fec3621
58825ba
24454d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| /* | ||
| * #%L | ||
| * ImageJ software for multidimensional image processing and analysis. | ||
| * %% | ||
| * Copyright (C) 2014 - 2018 ImageJ developers. | ||
| * %% | ||
| * Redistribution and use in source and binary forms, with or without | ||
| * modification, are permitted provided that the following conditions are met: | ||
| * | ||
| * 1. Redistributions of source code must retain the above copyright notice, | ||
| * this list of conditions and the following disclaimer. | ||
| * 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| * this list of conditions and the following disclaimer in the documentation | ||
| * and/or other materials provided with the distribution. | ||
| * | ||
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | ||
| * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| * POSSIBILITY OF SUCH DAMAGE. | ||
| * #L% | ||
| */ | ||
|
|
||
| package net.imagej.ops.transform.realTransform; | ||
|
|
||
| import net.imagej.ops.Ops; | ||
| import net.imagej.ops.special.function.AbstractUnaryFunctionOp; | ||
| import net.imglib2.FinalInterval; | ||
| import net.imglib2.Interval; | ||
| import net.imglib2.RandomAccessible; | ||
| import net.imglib2.RandomAccessibleInterval; | ||
| import net.imglib2.interpolation.InterpolatorFactory; | ||
| import net.imglib2.interpolation.randomaccess.LanczosInterpolatorFactory; | ||
| import net.imglib2.outofbounds.OutOfBoundsFactory; | ||
| import net.imglib2.outofbounds.OutOfBoundsMirrorFactory; | ||
| import net.imglib2.realtransform.InvertibleRealTransform; | ||
| import net.imglib2.realtransform.RealViews; | ||
| import net.imglib2.type.numeric.NumericType; | ||
| import net.imglib2.type.numeric.RealType; | ||
| import net.imglib2.view.IntervalView; | ||
| import net.imglib2.view.Views; | ||
|
|
||
| import org.scijava.Priority; | ||
| import org.scijava.plugin.Parameter; | ||
| import org.scijava.plugin.Plugin; | ||
|
|
||
| /** | ||
| * Applies an Affine transform to a {@link RandomAccessibleInterval} | ||
| * | ||
| * @author Brian Northan (True North Intelligent Algorithms) | ||
| * @author Martin Horn (University of Konstanz) | ||
| * @author Stefan Helfrich (University of Konstanz) | ||
| */ | ||
| @Plugin(type = Ops.Transform.RealTransform.class, priority = Priority.HIGH + 1) | ||
| public class DefaultTransformView<T extends NumericType<T> & RealType<T>> | ||
| extends | ||
| AbstractUnaryFunctionOp<RandomAccessibleInterval<T>, RandomAccessibleInterval<T>> | ||
| implements Ops.Transform.RealTransform | ||
| { | ||
|
|
||
| /** | ||
| * The transform to apply | ||
| */ | ||
| @Parameter | ||
| InvertibleRealTransform transform; | ||
|
|
||
| @Parameter(required = false) | ||
| private Interval outputInterval = null; | ||
|
||
|
|
||
| @Parameter(required = false) | ||
| private InterpolatorFactory<T, RandomAccessible<T>> interpolator = null; | ||
|
||
|
|
||
| @Parameter(required = false) | ||
| private OutOfBoundsFactory<T, RandomAccessibleInterval<T>> outOfBoundsFactory = | ||
| new OutOfBoundsMirrorFactory<>(OutOfBoundsMirrorFactory.Boundary.SINGLE); | ||
|
||
|
|
||
| @Override | ||
| public RandomAccessibleInterval<T> calculate( | ||
| final RandomAccessibleInterval<T> input) | ||
| { | ||
|
|
||
| if (outputInterval == null) { | ||
| outputInterval = new FinalInterval(input); | ||
| } | ||
|
|
||
| if (interpolator == null) { | ||
| interpolator = new LanczosInterpolatorFactory<>(); | ||
| } | ||
|
|
||
| final IntervalView<T> interval = Views.interval(Views.raster(RealViews | ||
| .transformReal(Views.interpolate(Views.extendZero(input), interpolator), | ||
| transform)), outputInterval); | ||
|
|
||
| return interval; | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
ops().run(Ops.Transform.RealTransform.class, in, transform). That way, in the future, someone could write an op which is a specialized version of this and it could also be matched.Please change this for all your other
realTransform(...)namespace methods as well.