//load ImageJ
%classpath config resolver scijava.public https://maven.scijava.org/content/groups/public
%classpath add mvn net.imagej imagej 2.0.0-rc-67
//create ImageJ object
ij = new net.imagej.ImageJ()
Added new repo: scijava.public
net.imagej.ImageJ@3baf5137
This Op
wraps the Views.extendMirrorDouble()
method of ImgLib2, removing the borders of any RandomAccessibleInterval
(which transforms it into a RandomAccessible
) and mirrors the piexels defined within the input RAI
onto the new extended pixels. The Op
mirrors the edge pixels, so that the first pixel value outside the old edge pixel is the old edge pixel itself. If it is not desired for the first pixel value outside the old edge pixel to be the old edge pixel again, extendMirrorSingle
should be used instead. Let's see how it is called:
ij.op().help('extendMirrorDoubleView')
Available operations: (ExtendedRandomAccessibleInterval out) = net.imagej.ops.transform.extendMirrorDoubleView.DefaultExtendMirrorDoubleView( RandomAccessibleInterval in)
Since this Op
can't really vary using parameters because of its strict definition, we only have to pass through an input.
input = ij.scifio().datasetIO().open("http://imagej.net/images/clown.png")
ij.notebook().display(input)
Let's find a more interesting section instead of running the Op
on the whole image:
import net.imglib2.FinalInterval
region = FinalInterval.createMinSize(30, 17, 0, 85, 78, 3)
eye = ij.op().run("crop", input, region)
ij.notebook().display(eye)
Now that we have a smaller section, let's extend the border. We will also use pad
so that we can see the new pixels:
def pad(image, extended, t, r, b, l) {
min = new long[image.numDimensions()]
max = new long[image.numDimensions()]
image.min(min)
image.max(max)
min[0] -= l; min[1] -= t; max[0] += r; max[1] += b
return ij.op().run("intervalView", extended, min, max)
}
extended = ij.op().run("extendMirrorDoubleView", eye)
//let's extend our image out 20 pixels on each side
padLength = 40
padded = pad(eye, extended, padLength, padLength, padLength, padLength)
ij.notebook().display(padded)