Help with macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with macro

AAM71
Dear Listers,

I just wonder will it be possible by means of ImageJ macro language do
the following:

in the stack of images to create arbitrary (random angles) 2 parallel
lines that go through several slices. I would like projection of these
lines to be drawn on slices. In general it should not be too hard but I
cannot get my head around how to calculate these projections if you have
random (but known) angles in all 3 axes (X,Y,Z).

Sincerely,

Alex

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Help with macro

Kenton Arkill
Hi
The way I would do it is by rotation the stack by the angle of the profile
line... so the profile is now along the x axis.
I'd then rotate (transformJ) 90 around the x axis.
Best
Kenton

On Fri, 30 Nov 2018, 14:02 Aleksandr Mironov <
[hidden email] wrote:

> Dear Listers,
>
> I just wonder will it be possible by means of ImageJ macro language do
> the following:
>
> in the stack of images to create arbitrary (random angles) 2 parallel
> lines that go through several slices. I would like projection of these
> lines to be drawn on slices. In general it should not be too hard but I
> cannot get my head around how to calculate these projections if you have
> random (but known) angles in all 3 axes (X,Y,Z).
>
> Sincerely,
>
> Alex
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Help with macro

AAM71
Thanks Kenton,

But wouldn't it be computationally expensive if you need to reorient the
whole stack for that purpose? Another consideration is that some
features needs preferable orientation of cutting to be recognizable.

Sincerely,

Alex


On 30/11/2018 14:14, Kenton Arkill wrote:

> Hi
> The way I would do it is by rotation the stack by the angle of the profile
> line... so the profile is now along the x axis.
> I'd then rotate (transformJ) 90 around the x axis.
> Best
> Kenton
>
> On Fri, 30 Nov 2018, 14:02 Aleksandr Mironov <
> [hidden email] wrote:
>
>> Dear Listers,
>>
>> I just wonder will it be possible by means of ImageJ macro language do
>> the following:
>>
>> in the stack of images to create arbitrary (random angles) 2 parallel
>> lines that go through several slices. I would like projection of these
>> lines to be drawn on slices. In general it should not be too hard but I
>> cannot get my head around how to calculate these projections if you have
>> random (but known) angles in all 3 axes (X,Y,Z).
>>
>> Sincerely,
>>
>> Alex
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Help with macro

Kenton Arkill
Ah... sorry just saw the projection.
Resizing z to one slice (not that long computaionally) and then drawing
your lines?
Kenton

On Fri, 30 Nov 2018, 14:25 Aleksandr Mironov <
[hidden email] wrote:

> Thanks Kenton,
>
> But wouldn't it be computationally expensive if you need to reorient the
> whole stack for that purpose? Another consideration is that some
> features needs preferable orientation of cutting to be recognizable.
>
> Sincerely,
>
> Alex
>
>
> On 30/11/2018 14:14, Kenton Arkill wrote:
> > Hi
> > The way I would do it is by rotation the stack by the angle of the
> profile
> > line... so the profile is now along the x axis.
> > I'd then rotate (transformJ) 90 around the x axis.
> > Best
> > Kenton
> >
> > On Fri, 30 Nov 2018, 14:02 Aleksandr Mironov <
> > [hidden email] wrote:
> >
> >> Dear Listers,
> >>
> >> I just wonder will it be possible by means of ImageJ macro language do
> >> the following:
> >>
> >> in the stack of images to create arbitrary (random angles) 2 parallel
> >> lines that go through several slices. I would like projection of these
> >> lines to be drawn on slices. In general it should not be too hard but I
> >> cannot get my head around how to calculate these projections if you have
> >> random (but known) angles in all 3 axes (X,Y,Z).
> >>
> >> Sincerely,
> >>
> >> Alex
> >>
> >> --
> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Help with macro

AAM71
I need the stack still to be full stack, so it will be possible to go
through all the slices. This problem is just a subset of bigger task -
to have 3 sets of parallel lines (sets oriented ortogonally to each
other in 3D: X,Y,Z) in a stack. So, the stack should be preserved.

Sincerely,
Alex


On 30/11/2018 14:31, Kenton Arkill wrote:

> Ah... sorry just saw the projection.
> Resizing z to one slice (not that long computaionally) and then drawing
> your lines?
> Kenton
>
> On Fri, 30 Nov 2018, 14:25 Aleksandr Mironov <
> [hidden email] wrote:
>
>> Thanks Kenton,
>>
>> But wouldn't it be computationally expensive if you need to reorient the
>> whole stack for that purpose? Another consideration is that some
>> features needs preferable orientation of cutting to be recognizable.
>>
>> Sincerely,
>>
>> Alex
>>
>>
>> On 30/11/2018 14:14, Kenton Arkill wrote:
>>> Hi
>>> The way I would do it is by rotation the stack by the angle of the
>> profile
>>> line... so the profile is now along the x axis.
>>> I'd then rotate (transformJ) 90 around the x axis.
>>> Best
>>> Kenton
>>>
>>> On Fri, 30 Nov 2018, 14:02 Aleksandr Mironov <
>>> [hidden email] wrote:
>>>
>>>> Dear Listers,
>>>>
>>>> I just wonder will it be possible by means of ImageJ macro language do
>>>> the following:
>>>>
>>>> in the stack of images to create arbitrary (random angles) 2 parallel
>>>> lines that go through several slices. I would like projection of these
>>>> lines to be drawn on slices. In general it should not be too hard but I
>>>> cannot get my head around how to calculate these projections if you have
>>>> random (but known) angles in all 3 axes (X,Y,Z).
>>>>
>>>> Sincerely,
>>>>
>>>> Alex
>>>>
>>>> --
>>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>> --
>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Help with macro

Kenton Arkill
Nothing I can think of is quick. So there is definitely a better way.

When you have your lines you can duplicate (so just the volume of interest).
Rotation so the line is along x does mean the other orthogonal lines are
along axes which might be helpful.

Sorry

On Fri, 30 Nov 2018, 14:43 Aleksandr Mironov <
[hidden email] wrote:

> I need the stack still to be full stack, so it will be possible to go
> through all the slices. This problem is just a subset of bigger task -
> to have 3 sets of parallel lines (sets oriented ortogonally to each
> other in 3D: X,Y,Z) in a stack. So, the stack should be preserved.
>
> Sincerely,
> Alex
>
>
> On 30/11/2018 14:31, Kenton Arkill wrote:
> > Ah... sorry just saw the projection.
> > Resizing z to one slice (not that long computaionally) and then drawing
> > your lines?
> > Kenton
> >
> > On Fri, 30 Nov 2018, 14:25 Aleksandr Mironov <
> > [hidden email] wrote:
> >
> >> Thanks Kenton,
> >>
> >> But wouldn't it be computationally expensive if you need to reorient the
> >> whole stack for that purpose? Another consideration is that some
> >> features needs preferable orientation of cutting to be recognizable.
> >>
> >> Sincerely,
> >>
> >> Alex
> >>
> >>
> >> On 30/11/2018 14:14, Kenton Arkill wrote:
> >>> Hi
> >>> The way I would do it is by rotation the stack by the angle of the
> >> profile
> >>> line... so the profile is now along the x axis.
> >>> I'd then rotate (transformJ) 90 around the x axis.
> >>> Best
> >>> Kenton
> >>>
> >>> On Fri, 30 Nov 2018, 14:02 Aleksandr Mironov <
> >>> [hidden email] wrote:
> >>>
> >>>> Dear Listers,
> >>>>
> >>>> I just wonder will it be possible by means of ImageJ macro language do
> >>>> the following:
> >>>>
> >>>> in the stack of images to create arbitrary (random angles) 2 parallel
> >>>> lines that go through several slices. I would like projection of these
> >>>> lines to be drawn on slices. In general it should not be too hard but
> I
> >>>> cannot get my head around how to calculate these projections if you
> have
> >>>> random (but known) angles in all 3 axes (X,Y,Z).
> >>>>
> >>>> Sincerely,
> >>>>
> >>>> Alex
> >>>>
> >>>> --
> >>>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>>>
> >>> --
> >>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >> --
> >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >>
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Help with macro

Kenneth Sloan-2
In reply to this post by AAM71
Angles are not enough to define a line.  I don't know what information you are using to define
the lines - but my favorite form is:
         p = u*p1 + (u-1)*p0
where p, p1, p2 are points with x,y,z coordinates and u is a real number.

Once in this form - if you know z (the plane of a slice) you can solve for u.

Givn u, you can compute x and y.

The only special case is when z=constant (the line lies in a plane - which may, or may not, correspond
to one of the slices).  In that case, the line appears in NO slice - or it lies completely in 1 slice.  
In the last case, you can just draw the line in that slice.  For all the other cases, the line
appears as a point in each slice.

Unless, of course, you treat each slice as a SLAB, with a top and bottom z=constant boundary.  Then,
you need to solve for u at both the top and bottom boundary, solve for x,y, and connect the two x,y points
with a line segment.

I you don't have the line in parametric form, it's a good idea to first find the parametric representation and
go from there.  Other representations have too many pitfalls.

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.





> On 30 Nov 2018, at 15:00 , Aleksandr Mironov <[hidden email]> wrote:
>
> Dear Listers,
>
> I just wonder will it be possible by means of ImageJ macro language do the following:
>
> in the stack of images to create arbitrary (random angles) 2 parallel lines that go through several slices. I would like projection of these lines to be drawn on slices. In general it should not be too hard but I cannot get my head around how to calculate these projections if you have random (but known) angles in all 3 axes (X,Y,Z).
>
> Sincerely,
>
> Alex
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Help with macro

Michael Schmid
In reply to this post by AAM71
Hi Alex,

it is unclear to me what you refer to with "projection of these lines":

(a) Projection of the lines onto the xy plane?
This is trivial:
If you have a line between the points (x1,y1,z1) and (x2,y2,z2), the
projection on the xy plane is simply a line between (x1,y1) and (x2,y2).
Use makeLine(x1, y1, x2, y2).

(b) Line profile (of pixel values) along the lines?
ImageJ has no 3D line selections (line ROIs are 2D), so I fear that you
have to do this point by point:
   (x,y,z) = (x1,y1,z1) + (i/(n-1))*((x2,y2,z2) - (x1,y1,z1))
where i is the index of the point (running from 0 to n-1) and n is the
number of points (e.g. set it to the length of the line).
For each of the points, set the slice number according to z and use
getPixel(x,y).
getPixel does interpolation in x and y, but selecting one slice for each
point means you have no interpolation in z direction.

(c) Intersection points of the lines with the slices? Again, I fear you
have to do the math.

(d) Something else?

Michael
________________________________________________________________


On 30.11.18 15:00, Aleksandr Mironov wrote:

> Dear Listers,
>
> I just wonder will it be possible by means of ImageJ macro language do
> the following:
>
> in the stack of images to create arbitrary (random angles) 2 parallel
> lines that go through several slices. I would like projection of these
> lines to be drawn on slices. In general it should not be too hard but I
> cannot get my head around how to calculate these projections if you have
> random (but known) angles in all 3 axes (X,Y,Z).
>
> Sincerely,
>
> Alex

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Help with macro

AAM71
Thank you Michael!
I think it is the first option - projections of lines (parallel lines randomly oriented in 3D)  on original slices of a stack.

Sincerely,
Alex
________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of Michael Schmid [[hidden email]]
Sent: 03 December 2018 18:22
To: [hidden email]
Subject: Re: Help with macro

Hi Alex,

it is unclear to me what you refer to with "projection of these lines":

(a) Projection of the lines onto the xy plane?
This is trivial:
If you have a line between the points (x1,y1,z1) and (x2,y2,z2), the
projection on the xy plane is simply a line between (x1,y1) and (x2,y2).
Use makeLine(x1, y1, x2, y2).

(b) Line profile (of pixel values) along the lines?
ImageJ has no 3D line selections (line ROIs are 2D), so I fear that you
have to do this point by point:
   (x,y,z) = (x1,y1,z1) + (i/(n-1))*((x2,y2,z2) - (x1,y1,z1))
where i is the index of the point (running from 0 to n-1) and n is the
number of points (e.g. set it to the length of the line).
For each of the points, set the slice number according to z and use
getPixel(x,y).
getPixel does interpolation in x and y, but selecting one slice for each
point means you have no interpolation in z direction.

(c) Intersection points of the lines with the slices? Again, I fear you
have to do the math.

(d) Something else?

Michael
________________________________________________________________


On 30.11.18 15:00, Aleksandr Mironov wrote:

> Dear Listers,
>
> I just wonder will it be possible by means of ImageJ macro language do
> the following:
>
> in the stack of images to create arbitrary (random angles) 2 parallel
> lines that go through several slices. I would like projection of these
> lines to be drawn on slices. In general it should not be too hard but I
> cannot get my head around how to calculate these projections if you have
> random (but known) angles in all 3 axes (X,Y,Z).
>
> Sincerely,
>
> Alex

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html