//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@50987afc
This Op
wraps the Views.extendPeriodic()
method of ImgLib2, removing the borders of any RandomAccessibleInterval
(which transforms it into a RandomAccessible
). This Op
creates a sort of mosaic from the image, where the first pixel value outside any edge value is the pixel value of the opposite edge (i.e. directly across from it). You can think of extendPeriodic
as as laying copies of an image on all side of the original, expanding out to infinity. Let's see how it is called:
ij.op().help('extendPeriodicView')
Available operations: (ExtendedRandomAccessibleInterval out) = net.imagej.ops.transform.extendPeriodicView.DefaultExtendPeriodicView( 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("extendPeriodicView", 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)