Beaker notebook - 3D crop?

Tags: #<Tag:0x00007fb8829dc960> #<Tag:0x00007fb8829dc618>


@etarena , @ctrueden, @imagejan or whoever understands ImageJ2 Ops and imgLib2:

I have a question about the example for cropping an image using an Op. It seems as if the image is cropped in 3D, but the image in the example seems to be 2D:

This example shows two ops that crop an image:

import net.imglib2.FinalInterval
region = FinalInterval.createMinSize(75, 27, 0, 40, 28, 3)

eye = ij.op().run("crop", image, region)
eyeView = ij.op().run("intervalView", image, region)

tile([eye, eyeView]) 

When I looked at the Javadocs for createMinSize in the imgLib2 FinalInterval class, I found this:

minsize - a list of 2*n parameters to create a n -dimensional interval.

And since the example given in the notebook was using 6 arguments for createMinSize, I understand that the image was cropped in 3D. Am I right? (it’s cool if the image can be cropped that easily in 3D)



Yes, the image was cropped in 3D, because it has actually 3 dimensions: x, y, and Channel.

You can check the number of dimensions:

println image.numDimensions()

and the size of the thirs dimension (index 2):

println image.dimension(2)

Yes, with ops, you can easily crop whatever dimensions your image has. The syntax will remain the same. Awesome, isn’t it? :slight_smile:


Thanks, Jan - that’s super cool! I’m very interested in using it. How would I know which dimension is which? (I mean, how did you know that the channel is the third dimension?)


Right now, you have to use the unstable ImgPlus API, which allows each dimension to have an associated axis. This will change, however, with the “rich image” work on metadata which is a priority for this year.


Is it possible to threshold my image and segment it in 3D with Ops? If so, how? I think that these tutorials haven’t reached beaker yet. If they exist somewhere else, I will be happy to go over them.


Yes, see the thresholding section of the Ops Beaker tutorial.

Not easily yet, unfortunately. There is a CCA (connected component analysis) op, which returns a labeling. You can find a work-in-progress tutorial which illustrates it here.


Thanks, Curtis :slight_smile: