//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@5e5bc1b4
This Op
wraps the Views.extendZero()
method of ImgLib2, removing the borders of any RandomAccessibleInterval
(which transforms it into a RandomAccessible
) and filling in all the new pixels with 0
. Let's see how it is called:
ij.op().help('extendZeroView')
Available operations: (ExtendedRandomAccessibleInterval out) = net.imagej.ops.transform.extendZeroView.DefaultExtendZeroView( 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("extendZeroView", 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)