These are chat archives for fiji/fiji

19th
Sep 2018
Visha
@vp212_gitlab
Sep 19 2018 04:10
Hello, I am trying to analyze Drosophila NMJ using the Drosophila_NMJ_morphometrics plugin that would be under plugins tab using Fiji. However, after installing the software and restarting Fiji, this plugin is not made readily available under Plugins tab for me (when Protocol S1. Fiji macros ‘Drosophila_NMJ_Morphometrics’ and ‘Drosophila_NMJ_Bouton Morphometrics’ says "after macros installation, Fiji needs to be restarted in order to visualize the newly installed macros in the plugins folder"). I completed these steps but am still not seeing the plugins. I would appreciate your help on this matter so I can move forward with the protocol. Thanks!
Visha
@vp212_gitlab
Sep 19 2018 04:23
If it helps, I installed everything to set up Fiji, restarted it, yet it says that all plug ins are up to date when the "Drosophila_NMJ_morphometrics" plugins is not show under the plugins tab
Jean-Yves Tinevez
@tinevez
Sep 19 2018 07:28
hi @vp212_gitlab I think it is best to discuss this on the forum, invoking the authors of the macro. Here we discuss the development of Fiji core and I do not think they show up often. https://forum.image.sc/
Varun Kapoor
@kapoorlab
Sep 19 2018 09:38
Hi, What utilities are available to draw lines on a randomaccessibleinterval from a double[] start top a double[] end point?
Jean-Yves Tinevez
@tinevez
Sep 19 2018 12:05
@kapoorlab None. I did this a while ago:
(wait I search for it)
copying from Johannes work.
But I was very young. Maybe you could redo it better? Like make it lazy?
Varun Kapoor
@kapoorlab
Sep 19 2018 12:08
I see, thanks, it is the bresenhamline in imglib2-algorithm-gpl repo?
Jean-Yves Tinevez
@tinevez
Sep 19 2018 12:09
yep
Jan Eglinger
@imagejan
Sep 19 2018 12:24

@kapoorlab @tinevez there's imglib2-roi now:

import net.imglib2.roi.geom.GeomMasks
line = GeomMasks.line([2.5, 2.5] as double[], [200, 200] as double[], false)

But I'm not sure how to raster this RealMask in a way that you still see the line on an RAI; maybe some line thickness has to be added for rendering, as a null-width line in real space will not hit all sample points in an integer grid of samples...

You can try something like:
result = Views.interval(Views.raster(line), new FinalInterval(
                        [line.realMin( 0 ), line.realMin( 1 ) ] as long[],
                        [line.realMax( 0 ), line.realMax( 1 ) ] as long[] )
)
Varun Kapoor
@kapoorlab
Sep 19 2018 12:37
' /**
 * 
 * Line Drawing on a Random AccesibleInterval
 * 
 * @param originalimg
 * @param startpoint
 * @param endpoint
 * @param Intensity
 */
public static <T extends RealType<T>> void DrawLines(final RandomAccessibleInterval<T> originalimg,
        final long[] startpoint, final long[] endpoint, final double Intensity) {

    RandomAccess<T> regionranac = originalimg.randomAccess();

    Point pointA = new Point(startpoint);
    Point pointB = new Point(endpoint);


    BresenhamLine<T> newline = new BresenhamLine<T>(regionranac, pointA, pointB);
    Cursor<T> cursor = newline.copyCursor();


    while (cursor.hasNext()) {

        cursor.fwd();

        cursor.get().setReal(Intensity);

    }'
Ah the bresenhamline code gives me more close to what I want to do, with the code above @imagejan @tinevez
If I try the same with Geomasks '
RandomAccess<T> regionranac = originalimg.randomAccess();
    Point pointA = new Point(startpoint);
    Point pointB = new Point(endpoint);

    Line<RealPoint> line = GeomMasks.line(pointA, pointB);


    FinalInterval interval = Intervals.createMinMax( new long[] {(long)line.realMin( 0 ), 
            (long)line.realMin( 1 ) ,(long)line.realMax( 0 ), (long)line.realMax( 1 ) });

    RandomAccessibleInterval< T > region = Views.interval( originalimg, interval );

        Cursor<T> regioncursor = Views.iterable(region).localizingCursor();

         while(regioncursor.hasNext()) {

        regioncursor.fwd();

        regioncursor.get().setReal(Intensity);

    }


}'
With this code, it does not give me the same lines as I get from the code before this one
Varun Kapoor
@kapoorlab
Sep 19 2018 12:50
Ah I see the bresenhamline makes a cursor over the line itself, but the Geom is over the entire region, so I had to constrain it to move over the line, thanks @imagejan @tinevez ' Line<RealPoint> line = GeomMasks.line(pointA, pointB);
    FinalInterval interval = Intervals.createMinMax(new long[] { (long) line.realMin(0), (long) line.realMin(1),
            (long) line.realMax(0), (long) line.realMax(1) });

    RandomAccessibleInterval<T> region = Views.interval(originalimg, interval);

    Cursor<T> regioncursor = Views.iterable(region).localizingCursor();

    double slope = (endpoint[1] - startpoint[1]) / (endpoint[0] - startpoint[0] + slopetolerance);
    double intercept = endpoint[1] - slope * endpoint[0];

    while (regioncursor.hasNext()) {

        regioncursor.fwd();
        if (Math.abs(
                regioncursor.getLongPosition(1) - slope * regioncursor.getLongPosition(0) - intercept) <= tolerance)
            regioncursor.get().setReal(Intensity);

    }'
Jan Eglinger
@imagejan
Sep 19 2018 12:55
@kapoorlab :+1: thanks for sharing
Alison Walter
@awalter17
Sep 19 2018 13:00
@kapoorlab I'm not sure if this is useful but there's also GeomMaths.bresenham( final List< ? extends RealLocalizable > vertices ). This would return a List< Localizable > representing a bresenham rastered line, but you'd still need to paint/draw these points. And this current implementation is only for "closed" structures
Varun Kapoor
@kapoorlab
Sep 19 2018 13:03
@awalter17 'List< Localizable >' would also do the job, but if it is only for closed structures it would make a loop instead of a line, right?
Alison Walter
@awalter17
Sep 19 2018 13:06
Yes. The current implementation could be used for drawing borders of polygons. You'd need ot adapt it to draw lines, and I'm not sure how easy that would be
Jan Eglinger
@imagejan
Sep 19 2018 13:09
For the original question, a straight line from start point to end point, it should work without even creating the Line, just with the two points, no?
Varun Kapoor
@kapoorlab
Sep 19 2018 13:12
@imagejan, yeah If i was creating an ij.gui line as an overlay then yes, but I wanted to draw it on the image and give it an intensity so had to take care of the slope of the line while drawing, so as not to loose too many points on the image when the slope is high and get too many when slope is low.
Jan Eglinger
@imagejan
Sep 19 2018 13:25
what I meant was using GeomMaths.bresenham with a List of [startPoint, endPoint, startPoint], so you actually have a closed polygon.
Varun Kapoor
@kapoorlab
Sep 19 2018 13:40
@imagejan, Actually yeah, just tried, works fantastic '/**
 * 
 * Line Drawing on a Random AccesibleInterval using GeomBresn
 * 
 * @param originalimg
 * @param startpoint
 * @param endpoint
 * @param Intensity
 */
public static <T extends RealType<T>> void DrawGeomBresnLines(final RandomAccessibleInterval<T> originalimg,
        final double[] startpoint, final double[] endpoint, final double Intensity) {


    RealPoint pointA = new RealPoint(startpoint);
    RealPoint pointB = new RealPoint(endpoint);

    RandomAccess<T> regionranac = originalimg.randomAccess();
    List<RealLocalizable> vertexlist = new ArrayList<RealLocalizable>();
    vertexlist.add(pointA);
    vertexlist.add(pointB);
    vertexlist.add(pointA);

    List<Localizable> pointlist = GeomMaths.bresenham(vertexlist);

    Iterator<Localizable> pointiter = pointlist.iterator();

    while(pointiter.hasNext()) {

        Localizable currentpoint = pointiter.next();

        regionranac.setPosition(currentpoint);
        regionranac.get().setReal(Intensity);

    }




}'
So no need to implement any new method as @tinevez originally pointed out as a new bresenham over the older one.
Jan Eglinger
@imagejan
Sep 19 2018 13:42
perfect :) I actually don't know if you have to add the first point explicitly to the end of the list, or if the assumption is that the polygon is closed, so the loop is closed implicitly. @awalter17 can you clarify?
Alison Walter
@awalter17
Sep 19 2018 13:49
Currently it assumes that the first and last point in the List are the same. There's a TODO to make a version that doesn't require this.
Alison Walter
@awalter17
Sep 19 2018 13:59
Whoops no, I'm wrong. It should work with just a List of two points
Visha
@vp212_gitlab
Sep 19 2018 14:06
@tinevez Thank you very much for the guidance!
Jean-Yves Tinevez
@tinevez
Sep 19 2018 14:22
@awalter17 : Any chance of making it return an Iterable or an Iterator instead of a list?
So that we do not have to create 1 gazilion points for long lines?
New stuff looks like by the way.
Alison Walter
@awalter17
Sep 19 2018 14:32
@tinevez it would be super nice if it returned an Iterator or a Cursor! I currently have no plans to modify this method, but if someone wanted to make a version that returns an Iterator they're more than welcome to :wink: