can i draw cylinders!

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

can i draw cylinders!

sridevi polavaram
Dear ImageJ,
 I want to know if I can draw cylindrical lines in 2D in imageJ.  I don't
see any such tool avaiable  on the main window. But is there any plugin that
provides this facility?
If not, what is the solution!? I hope atleast one of you might have needed
this! please let me know.
-Thanks
Sri
Reply | Threaded
Open this post in threaded view
|

Re: can i draw cylinders!

Robert Baer
 I want to know if I can draw cylindrical lines in 2D in imageJ
- A cylinder is a 3-dimensional object, not a 2D object
- A line is a 1-dimensional object (although sometimes given width for
visualization purposes), not a 2D object.
- What, therefore, do you mean by a cylindrical line on a 2D image?  And, do
you mean a stack of 2D images?

Help us if you want us to help you.


----- Original Message -----
From: "sridevi polavaram" <[hidden email]>
To: <[hidden email]>
Sent: Monday, October 23, 2006 12:40 PM
Subject: can i draw cylinders!


> Dear ImageJ,
> I want to know if I can draw cylindrical lines in 2D in imageJ.  I don't
> see any such tool avaiable  on the main window. But is there any plugin
> that
> provides this facility?
> If not, what is the solution!? I hope atleast one of you might have needed
> this! please let me know.
> -Thanks
> Sri
>
Reply | Threaded
Open this post in threaded view
|

Re: can i draw cylinders!

lechristophe
I think he may refer to a line with a finite width : adjust the line
width by double clicking the line tool.

As regards segmented or freehand lines with a fixed width, it is not yet
implemented. I desperately need it to do measurements on thick neurites
and I've spent hours trying to figure out how to write such a tool with
a macro. The only output of my efforts so far have been massive headache...

What I understood was that line objects (such as segmented or freehand
lines) are very different from surface objects (rectangles etc...),
because they are not measured in the same way (length vs area). So
having a straight line with a finite width is relatively straighforward,
because length and area are linked very simply, but for segmented lines
with a finite width (which i call "kinky snakes"), or even worst for
freehand "snakes", the relationship is much more complicated.

What would be needed is a way to draw a line (wathever the type) and
having some kind of "expand" command to generate a thick snake from that
line, that would then be considered as a surface ROI, not a linear one.

Alternatively, one could think about manually generate a rectangle from
the extremities of a straight line, and process segmented lines by
iteration (segment by segment). For that, I need a way to specifiy a
rectangular ROI (not horizontal or vertical, but with any inclination)
from the segment extremities. These extremities corresponds to the
middle points of the two opposite (parallel) sides of the rectangle.
Using these points and and the lenght of the corresponding side defines
a unique rectangle, but there is no way to define a rectangular ROI
using this parameters in ImageJ.

Knowing the straight lins coordinates and the width of the rectangle, it
could be done by calculating the rectangle four corners coordinates, but
I somehow got lost in the calculus somewhere among angles, arctan and
triangle sides ratios...


Jeez this is where posting a drawing could help explain what I'm saying.
If someone is able to figure out a quick hack to be able to draw a
segmented line, expand it to a "kinky snake" and process that as a
surface ROI (not a linear one), all of this wrapped into a easy-to-use
single tool, it would be christmas in advance.



Christophe



--
Christophe Leterrier

Postdoc
INSERM UMR641 Neurobiology of ionic channels
IFR Jean Roche - Mediterranee University
Marseille, France


Robert Baer wrote:

> I want to know if I can draw cylindrical lines in 2D in imageJ
> - A cylinder is a 3-dimensional object, not a 2D object
> - A line is a 1-dimensional object (although sometimes given width for
> visualization purposes), not a 2D object.
> - What, therefore, do you mean by a cylindrical line on a 2D image?  
> And, do you mean a stack of 2D images?
>
> Help us if you want us to help you.
>
>
> ----- Original Message ----- From: "sridevi polavaram" <[hidden email]>
> To: <[hidden email]>
> Sent: Monday, October 23, 2006 12:40 PM
> Subject: can i draw cylinders!
>
>
>> Dear ImageJ,
>> I want to know if I can draw cylindrical lines in 2D in imageJ.  I don't
>> see any such tool avaiable  on the main window. But is there any
>> plugin that
>> provides this facility?
>> If not, what is the solution!? I hope atleast one of you might have
>> needed
>> this! please let me know.
>> -Thanks
>> Sri
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: can i draw cylinders!

Gabriel Landini
On Tuesday 24 October 2006 09:58, Christophe Leterrier wrote:
> What would be needed is a way to draw a line (wathever the type) and
> having some kind of "expand" command to generate a thick snake from that
>line, that would then be considered as a surface ROI, not a linear one.

You can generate a thick line from a set of coordinates by painting filled
disks with centre at each coordinate of your freehand line.
This is almost the same as doing morphological dilation of the line with
circular kernels.

You can also obtain a similar result by drawing the line on the image and then
calculating the Euclidean distance transform of the background. The
transformed image can then be thresholded to obtain the thickened line by
so-many pixels.

The problem you will face is that the length of the thickened line (if it is
irregular) becomes shorter with the increased thickening (i.e. with
increasing thickness the small detail is erased at a rate related to the
fractal dimension of the line). This is a known effect and typical of
irregular/fractal objects, but you need to know the fractal dimension
beforehand to do the correction (!). An iterative solution has been described
in:

Flook AG. The use of the dilation logic on the quantimet to achieve fractal
dimension characterisation of textured and structured profiles. Powder
Technology 1978;21:295-298.

Flook AG. Fractal dimensions: their evaluation and their significance in
stereological measurements. Acta Stereol, Proc 3rd Eur Symp Stereol 2nd Part
1982;:/79-87.

I hope it helps.

Gabriel
Reply | Threaded
Open this post in threaded view
|

snake ROIs (was: can i draw cylinders!)

lechristophe
Thank you for your advices, but maybe I wasn't clear enough :
I don't want to paint on my image, I want to define ROIs.

First of all, I know of the elliptical brush tool trick to define
simili-freehand snakes ROIs but it's much more time-consuming than
tracing a freehand line (or even better a segmented line) and have it
expanded to a "snake".

For freehand lines I agree you can define circle at each point of the
line, but what about segmented lines ? What a waste of processing time
to interpolate all the coordinates between the extremities of each
segment and draw a circle centered on each point ! Much better would be
to incrementally define a ROI by adding elements : circle at the first
point followed by rectangle along first segment, followed circle at the
second point, repeat for each angle point  of the segmented line until
you reach the last point.

The problem is that I can't get to calculate the coordinates of the
rectangle along each segment. I tought it should be easy to calculate !
Besides, I don't know how to incrementally add elements to a
macro-defined ROI (i.e. doing in a macro what you do with shift-key when
you do it manually).


Christophe


Gabriel Landini wrote:

> On Tuesday 24 October 2006 09:58, Christophe Leterrier wrote:
>> What would be needed is a way to draw a line (wathever the type) and
>> having some kind of "expand" command to generate a thick snake from that
>> line, that would then be considered as a surface ROI, not a linear one.
>
> You can generate a thick line from a set of coordinates by painting filled
> disks with centre at each coordinate of your freehand line.
> This is almost the same as doing morphological dilation of the line with
> circular kernels.
>
> You can also obtain a similar result by drawing the line on the image and then
> calculating the Euclidean distance transform of the background. The
> transformed image can then be thresholded to obtain the thickened line by
> so-many pixels.
>
> The problem you will face is that the length of the thickened line (if it is
> irregular) becomes shorter with the increased thickening (i.e. with
> increasing thickness the small detail is erased at a rate related to the
> fractal dimension of the line). This is a known effect and typical of
> irregular/fractal objects, but you need to know the fractal dimension
> beforehand to do the correction (!). An iterative solution has been described
> in:
>
> Flook AG. The use of the dilation logic on the quantimet to achieve fractal
> dimension characterisation of textured and structured profiles. Powder
> Technology 1978;21:295-298.
>
> Flook AG. Fractal dimensions: their evaluation and their significance in
> stereological measurements. Acta Stereol, Proc 3rd Eur Symp Stereol 2nd Part
> 1982;:/79-87.
>
> I hope it helps.
>
> Gabriel
>
Reply | Threaded
Open this post in threaded view
|

Re: can i draw cylinders!

jmutterer
In reply to this post by lechristophe
Christophe,
you can do this with with the following macro that converts a line
selection with a certain line width to an area selection.
Run this macro with any line selection. The original selection is
available from the roiManager.


Jerome


// macro convert line with width to area selection
setLineWidth(10);
t=getTitle();
getSelectionCoordinates(x,y);
roiManager("Add");
segline=roiManager("Count");
print (segline);
run("Duplicate...", "title=mask");
run("Select All");
run("Clear");
selectWindow("mask");
roiManager("Select", segline-1);
run("Draw");
doWand(x[0],y[0]);
roiManager("Add");
close();
selectWindow(t);
roiManager("Select", segline);



On 10/24/06, Christophe Leterrier <[hidden email]> wrote:

> I think he may refer to a line with a finite width : adjust the line
> width by double clicking the line tool.
>
> As regards segmented or freehand lines with a fixed width, it is not yet
> implemented. I desperately need it to do measurements on thick neurites
> and I've spent hours trying to figure out how to write such a tool with
> a macro. The only output of my efforts so far have been massive headache...
>
> What I understood was that line objects (such as segmented or freehand
> lines) are very different from surface objects (rectangles etc...),
> because they are not measured in the same way (length vs area). So
> having a straight line with a finite width is relatively straighforward,
> because length and area are linked very simply, but for segmented lines
> with a finite width (which i call "kinky snakes"), or even worst for
> freehand "snakes", the relationship is much more complicated.
>
> What would be needed is a way to draw a line (wathever the type) and
> having some kind of "expand" command to generate a thick snake from that
> line, that would then be considered as a surface ROI, not a linear one.
>
> Alternatively, one could think about manually generate a rectangle from
> the extremities of a straight line, and process segmented lines by
> iteration (segment by segment). For that, I need a way to specifiy a
> rectangular ROI (not horizontal or vertical, but with any inclination)
> from the segment extremities. These extremities corresponds to the
> middle points of the two opposite (parallel) sides of the rectangle.
> Using these points and and the lenght of the corresponding side defines
> a unique rectangle, but there is no way to define a rectangular ROI
> using this parameters in ImageJ.
>
> Knowing the straight lins coordinates and the width of the rectangle, it
> could be done by calculating the rectangle four corners coordinates, but
> I somehow got lost in the calculus somewhere among angles, arctan and
> triangle sides ratios...
>
>
> Jeez this is where posting a drawing could help explain what I'm saying.
> If someone is able to figure out a quick hack to be able to draw a
> segmented line, expand it to a "kinky snake" and process that as a
> surface ROI (not a linear one), all of this wrapped into a easy-to-use
> single tool, it would be christmas in advance.
>
>
>
> Christophe
>
>
>
> --
> Christophe Leterrier
>
> Postdoc
> INSERM UMR641 Neurobiology of ionic channels
> IFR Jean Roche - Mediterranee University
> Marseille, France
>
>
> Robert Baer wrote:
> > I want to know if I can draw cylindrical lines in 2D in imageJ
> > - A cylinder is a 3-dimensional object, not a 2D object
> > - A line is a 1-dimensional object (although sometimes given width for
> > visualization purposes), not a 2D object.
> > - What, therefore, do you mean by a cylindrical line on a 2D image?
> > And, do you mean a stack of 2D images?
> >
> > Help us if you want us to help you.
> >
> >
> > ----- Original Message ----- From: "sridevi polavaram" <[hidden email]>
> > To: <[hidden email]>
> > Sent: Monday, October 23, 2006 12:40 PM
> > Subject: can i draw cylinders!
> >
> >
> >> Dear ImageJ,
> >> I want to know if I can draw cylindrical lines in 2D in imageJ.  I don't
> >> see any such tool avaiable  on the main window. But is there any
> >> plugin that
> >> provides this facility?
> >> If not, what is the solution!? I hope atleast one of you might have
> >> needed
> >> this! please let me know.
> >> -Thanks
> >> Sri
> >>
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: snake ROIs (was: can i draw cylinders!)

Gabriel Landini
In reply to this post by lechristophe
On Tuesday 24 October 2006 10:51, Christophe Leterrier wrote:
> Thank you for your advices, but maybe I wasn't clear enough :
> I don't want to paint on my image, I want to define ROIs.

I think that the difference is trivial. The painted image can be a new
duplicated one and the ROI extracted from it. You can run that in batch mode,
so it is transparent (see macro below).

> For freehand lines I agree you can define circle at each point of the
> line, but what about segmented lines ? What a waste of processing time
> to interpolate all the coordinates between the extremities of each
> segment and draw a circle centered on each point

Once you know the start and end of the line segment, the interpolation (this
is Bresenham's algorithm) is extremely quick. You could do that in a macro
and still would be fast. I think that the circular ROI drawing would be the
slow steo.

BTW, the distance transform to get the desired thickened line is fine for not
so large images (about than 1000x1000), but gets slower with larger ones. The
macro below  expects the line or area selection already drawn (yes, it works
with areas, too):

a=getTitle();
setBatchMode(true);
run("Add to Manager ");
run("Select None");
mine=roiManager("Count");
run("Duplicate...", "title=test-1");
roiManager("Select", mine-1);
run("Fill");
run("Select None");
run("Invert");
run("Distance Map");
setThreshold(0, 15); // sets radius of line
run("Convert to Mask");
run("Create Selection");
roiManager("Add");
selectImage(a);
roiManager("Select", mine);
setBatchMode(false);

I am using white foreground with black background, I haven't tested with those
inverted. Let me know if that does not work.

> Much better would be
> to incrementally define a ROI by adding elements : circle at the first
> point followed by rectangle along first segment, followed circle at the
> second point, repeat for each angle point  of the segmented line until
> you reach the last point.

That only works for segmented lines, not freehand ones, I think.

Cheers,

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: snake ROIs

lechristophe
I tested your macro, and it worked with minor modifications (concerning
inverting luts and images). Thanks a lot for the idea of the distance
map, which is brilliant.

Here's the final macro for those who are interested :

a=getTitle();
setBatchMode(true);
run("Add to Manager ");
run("Select None");
mine=roiManager("Count");
run("Duplicate...", "title=test-1");
setBackgroundColor(0,0,0);
setForegroundColor(255,255,255);
run("Select All");
run("Clear");
run("Select None");
roiManager("Select", mine-1);
run("Fill");
run("Select None");
run("Invert");
run("Invert LUT");
run("Distance Map");
setThreshold(0, 15); // sets radius of line
run("Convert to Mask");
run("Create Selection");
roiManager("Add");
close();
selectImage(a);
roiManager("Select", mine);
// roiManager("Select", mine-1);
// roiManager("Delete");
setBatchMode(false);


The two commented-out lines at the end are used to optionnally remove
the original line selection if needed.

What would be nice is to have that wrapped as a tool, but instant update
of the tracings would be very ressource-consuming I think.

Christophe

Gabriel Landini wrote:

> On Tuesday 24 October 2006 10:51, Christophe Leterrier wrote:
>> Thank you for your advices, but maybe I wasn't clear enough :
>> I don't want to paint on my image, I want to define ROIs.
>
> I think that the difference is trivial. The painted image can be a new
> duplicated one and the ROI extracted from it. You can run that in batch mode,
> so it is transparent (see macro below).
>
>> For freehand lines I agree you can define circle at each point of the
>> line, but what about segmented lines ? What a waste of processing time
>> to interpolate all the coordinates between the extremities of each
>> segment and draw a circle centered on each point
>
> Once you know the start and end of the line segment, the interpolation (this
> is Bresenham's algorithm) is extremely quick. You could do that in a macro
> and still would be fast. I think that the circular ROI drawing would be the
> slow steo.
>
> BTW, the distance transform to get the desired thickened line is fine for not
> so large images (about than 1000x1000), but gets slower with larger ones. The
> macro below  expects the line or area selection already drawn (yes, it works
> with areas, too):
>
> a=getTitle();
> setBatchMode(true);
> run("Add to Manager ");
> run("Select None");
> mine=roiManager("Count");
> run("Duplicate...", "title=test-1");
> roiManager("Select", mine-1);
> run("Fill");
> run("Select None");
> run("Invert");
> run("Distance Map");
> setThreshold(0, 15); // sets radius of line
> run("Convert to Mask");
> run("Create Selection");
> roiManager("Add");
> selectImage(a);
> roiManager("Select", mine);
> setBatchMode(false);
>
> I am using white foreground with black background, I haven't tested with those
> inverted. Let me know if that does not work.
>
>> Much better would be
>> to incrementally define a ROI by adding elements : circle at the first
>> point followed by rectangle along first segment, followed circle at the
>> second point, repeat for each angle point  of the segmented line until
>> you reach the last point.
>
> That only works for segmented lines, not freehand ones, I think.
>
> Cheers,
>
> Gabriel
>
Reply | Threaded
Open this post in threaded view
|

Setting "Data changed flag" from plugin/macro?

Joachim Wesner
Hi list,

How can I force Imagej to consider data processed by a macro or plugin to
be considered "changed" and in need of saving when one tries to close the
resp. window/stack ?

I would like  the "Save changes to xxx, Yes/No/Cancel" dialog to appear
before processed data are lost if the close button is pressed "by
accident"!

Sincerely

Joachim Wesner


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: Setting "Data changed flag" from plugin/macro?

Gabriel Landini
On Tuesday 24 October 2006 14:53, Joachim Wesner wrote:
> How can I force Imagej to consider data processed by a macro or plugin to
> be considered "changed" and in need of saving when one tries to close the
> resp. window/stack ?

Would this work?

imp.chages=true;

so, when trying to close you get the dialog?

Cheers,

G.
Reply | Threaded
Open this post in threaded view
|

Re: Setting "Data changed flag" from plugin/macro?

Gabriel Landini
On Tuesday 24 October 2006 16:03, you wrote:
> On Tuesday 24 October 2006 14:53, Joachim Wesner wrote:
> > How can I force Imagej to consider data processed by a macro or plugin to
> > be considered "changed" and in need of saving when one tries to close the
> > resp. window/stack ?
>
> Would this work?
>
> imp.chages=true;

Actually it is :
 imp.changes=true;

Sorry for the typo.

G.
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: Setting "Data changed flag" from plugin/macro?

Joachim Wesner
Hi,

YEP, that seems to be one. Thanx a lot! I will give it a try!

Sometimes things can be very easy! This field somehow missed my attention,
it also seems not to be mentioned in the plugin tutorial.
There is the NO_CHANGES mask, but I need to also force newly created
ImagePlus and Stacks to be saved!

Is there a way to access this flag from a macro, too??

Joachim




|---------+--------------------------->
|         |           Gabriel Landini |
|         |           <G.Landini@BHAM.|
|         |           AC.UK>          |
|         |           Gesendet von:   |
|         |           ImageJ Interest |
|         |           Group           |
|         |           <[hidden email]|
|         |           .GOV>           |
|         |                           |
|         |                           |
|         |           24.10.2006 17:18|
|         |           Bitte antworten |
|         |           an ImageJ       |
|         |           Interest Group  |
|---------+--------------------------->
  >-------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                               |
  |        An:      [hidden email]                                                                                           |
  |        Kopie:   (Blindkopie: Joachim Wesner/DEWET/LMSCentral/Leica)                                                           |
  |        Thema:   Re: Setting "Data changed flag" from plugin/macro?                                                            |
  >-------------------------------------------------------------------------------------------------------------------------------|




On Tuesday 24 October 2006 16:03, you wrote:
> On Tuesday 24 October 2006 14:53, Joachim Wesner wrote:
> > How can I force Imagej to consider data processed by a macro or plugin
to
> > be considered "changed" and in need of saving when one tries to close
the
> > resp. window/stack ?
>
> Would this work?
>
> imp.chages=true;

Actually it is :
 imp.changes=true;

Sorry for the typo.

G.



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: Setting "Data changed flag" from plugin/macro?

Wayne Rasband
> Hi,
>
> YEP, that seems to be one. Thanx a lot! I will give it a try!
>
> Sometimes things can be very easy! This field somehow missed my
> attention, it also seems not to be mentioned in the plugin tutorial.
> There is the NO_CHANGES mask, but I need to also force newly
> created ImagePlus and Stacks to be saved!
>
> Is there a way to access this flag from a macro, too??

Run a command that sets it. Here is code that sets the changes flag but
leaves the image unchanged:

    makeRectangle(0, 0, 1, 1);
    run("Invert");
    run("Invert");

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Setting "Data changed flag" from plugin/macro?

Albert Cardona
In reply to this post by Joachim Wesner
Joachim,

Using the call() macro function you can call a static method somewhere in your
plugins that sets the current ImagePlus to changes = true

Albert
Reply | Threaded
Open this post in threaded view
|

Re: Setting "Data changed flag" from plugin/macro?

Wayne Rasband
> Using the call() macro function you can call a static method somewhere
> in your plugins that sets the current ImagePlus to changes = true

In ImageJ 1.38a or later you can use the setOption() macro function.

      setOption("changes", true);

-wayne