by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    tpietzsch
    @tpietzsch
    for (iii) I don't know if anything is there
    Christian "Tischi" Tischer
    @tischi
    @imagejan Thanks, I got the message :) But I want to also learn how to use imglib2!
    @tpietzsch thanks a lot!
    Christian "Tischi" Tischer
    @tischi
    ...and I am having already another question :-)
    I would like to do down-scaling of images in imglib2 in such a way that the pixels in the down-scaled images are averages values of pixels in the original image. Basically what in IJ1 would be [ Image > Scale...]. Simplest application would be "average 2x2x2 binning", which would correspond to scaling of 0.5 x 0.5 x 0.5. Is below code the right thing to do?
    // input rai from somewhere
    AffineTransform3D scalingTransform3D = new AffineTransform3D();
    scalingTransform3D.scale( 0.5 );
    RealRandomAccessible rra = Views.interpolate(  Views.extendZero( rai ), new NLinearInterpolatorFactory() );
    rra = RealViews.transform( rra, scalingTransform3D );
    RandomAccessible binnedRA = Views.raster( rra );
    tpietzsch
    @tpietzsch
    almost right
    imglib2 puts integer samples coordinates in "pixel centers"
    so bilinear downscaled pixel (0,0,0) lands at (0,0,0) of original image and will not see any other pixel
    you should also translate by 0.5 so that downscaled (0,0,0) lands at (.5,.5,.5) of original image
    then bilinear interpolation will give you original voxels (0,0,0), (1,0,0), ..., (1,1,1) in equal proportions
    which gives you what you want
    there is also some explicit averaging of voxel blocks somewhere in bigdataviewer-core (for exporting mipmap levels)
    Curtis Rueden
    @ctrueden
    @tischi Why not simply transform.scaleView op? Am I missing something?
    Christian "Tischi" Tischer
    @tischi
    @tpietzsch:
    (i) where shall I add the translation: into the scalingTransform3D?
    (ii) does this also work for other factors than 0.5, e.g. 0.25 where it would have to average over 4 pixels in each dimension? Or does it always only see the nearest neighbors?
    Christian "Tischi" Tischer
    @tischi
    @ctrueden: Thanks for the hint! But I'd really like to learnathon imglib2!
    Christian "Tischi" Tischer
    @tischi
    @ctrueden, @tpietzsch I had a look at the code for the scaleView op and, to me, it looks pretty much like my code: https://github.com/imagej/imagej-ops/blob/master/src/main/java/net/imagej/ops/transform/scaleView/DefaultScaleView.java#L84
    In particular, the shifting away from integer pixel coordinates is also missing. Does that mean that the scaleView op in its current implementation would maybe a also rather do sub-sampling than averaging?
    Curtis Rueden
    @ctrueden
    @tischi Sure. But why not read the source code of transform.scaleView to see how it does it using ImgLib2?
    Oh, right, that's what you just said above. OK, great.
    I defer to @tpietzsch on whether he would recommend changes to the op along the lines of those discussed above.
    @tischi Have you had a chance to try the revamped single instance listener CLI flags yet?
    Vladimír Ulman
    @xulman
    @tischi, regarding iii), you can have a look into ops/geom/geom3d...
    one would need to convert your binary mask into a mesh (with MarchingCubes) and then query its geom. parameters... the folder essentially list available options
    tpietzsch
    @tpietzsch
    @tischi @ctrueden it only works for averaging over 2 pixels in each dimension
    it is simply bilinear interpolation
    shifting by 0.25 in each dim would mix neighbors by factor 0.25 and 0.75 respectively
    Whether the op should change depends on what it is supposed to do
    As it is, it would with scale factor 0.5 and Nlinear interpolator factor just pick every second pixel (i.e., no bilinear interpolation happening really)
    tpietzsch
    @tpietzsch
    However, I would not shift by 0.5 here.
    This only works for factor 0.5, by accident so to say.
    in the op you could pick scale 1.3 etc
    Curtis Rueden
    @ctrueden
    @tpietzsch Thanks, that makes sense. As for what the op is supposed to do: I don't think it is thoroughly formalized (yet). My weak preference is to keep it simple here and not do any translation. But we ought to document what will happen to the min/offset of the input image.
    tpietzsch
    @tpietzsch
    The way to improve the quality of the results would be implementing a better InterpolatorFactory
    Curtis Rueden
    @ctrueden
    *nod*
    Christian "Tischi" Tischer
    @tischi
    @ctrueden Regarding the single instance listeners: should it work after updating Fiji? I have an up-to-date Fiji and it throws: [WARNING] Ignoring invalid argument: --force-single-instance
    Curtis Rueden
    @ctrueden
    @tischi Did you put it to the right of a -- separator argument, as I described?
    The launcher is unfortunately a bit stupid about which arguments belong to the JVM itself vs. main methods.
    Christian "Tischi" Tischer
    @tischi

    ...just to make sure I have the latest Fiji:
    /Applications/Fiji.app/Contents/MacOS/ImageJ-macosx --update update
    ...and I just copy and pasted your code:
    /Applications/Fiji.app/Contents/MacOS/ImageJ-macosx -Dscijava.log.level:net.imagej.legacy=debug --force-single-instance -port2 --ij2 --open /Users/tischer/Desktop/blobs.tif

    [WARNING] Ignoring invalid argument: -Dscijava.log.level:net.imagej.legacy=debug [WARNING] Ignoring invalid argument: --force-single-instance [ERROR] Skipping unsupported option -port2

    btw: what does the port* do?
    Curtis Rueden
    @ctrueden
    Agh, did I leave it off? Shoot.
    Contents/Home/ImageJ-macosx -Dscijava.log.level:net.imagej.legacy=debug -- --force-single-instance -port2 --ij2 --open ~/Desktop/General_EduRes_Heart_BloodVessels_0.jpg
    Note the -- standalone argument after the debug arg.
    Your line above does not have that -- standalone argument, which is what causes your trouble.
    The -- says "everything before this is for the JVM, and everything after it is for the Java main method."
    Think of the "port" as a channel... my understanding is that if you launch ImageJ with, say, port2, then launch another ImageJ also with port2, it will find the running ImageJ on that same "port" and hand off the args.
    Christian "Tischi" Tischer
    @tischi

    /Applications/Fiji.app/Contents/MacOS/ImageJ-macosx -Dscijava.log.level:net.imagej.legacy=debug -- --force-single-instance -port2 --ij2 --open /Users/tischer/Desktop/blobs.tif

    [DEBUG] Found 952 legacy plugins. [WARNING] Ignoring invalid argument: --force-single-instance [ERROR] Skipping unsupported option -port2

    Curtis Rueden
    @ctrueden
    In this way, you can have multiple "single instance" ImageJ instances running simultaneously, and hand to whichever you wish, via the correct "port".
    But they cannot literally be web ports, because 2, 3, 4, 5, 6, 7 are not valid.
    Christian "Tischi" Tischer
    @tischi
    ok. I did not spot the first -- but it still does not seem to work. I also can't see the options when I do ImageJ-macosx --help
    Do I maybe have to download a new Fiji rather than update it?
    Curtis Rueden
    @ctrueden
    OK, you need imagej-legacy-0.32.0.jar
    I released that on Friday, June 15, and did not yet upload it to the core update site.
    It will be uploaded later this week. In the meantime, you can download it directly.
    Curtis Rueden
    @ctrueden
    Sorry for the confusion about the port, BTW—I recommend just leaving it off. The default is 7.