Macro question: test if a point is within selection/ROI

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

Macro question: test if a point is within selection/ROI

Jonathan Jackson-2
Dear All,

Is it possible, in a macro, to find out if a given point lies within the
current selection / ROI.  I'm writing a macro to alter the intensity of
pixels within the selection, but can't figure out how to do this!  

I've looked at getSelectionBounds and getSelectionCoordinates but so far as
I can't see a simple way to go from these to the coordinates of pixels
within the region.

thanks,
Jon
Reply | Threaded
Open this post in threaded view
|

Antwort: Macro question: test if a point is within selection/ROI

Joachim Wesner
Hi Jon,

in plugin (Java) programming there is a a function contains() that exactly
does what you are looking for, but it really seems to be missing in the
macro language(True ????)
and should be added!?

One way to do this with the current macro capabilities could be to convert
the selection to a binary image and read this into an array. All this could
be put in an subroutine
(including saving and restoring the initial image) for easy access.

Mit freundlichen Grüßen / Best regards

Joachim Wesner



                                                                           
             Jonathan Jackson                                              
             <[hidden email]                                            
             .UK>                                                       An
             Gesendet von:              [hidden email]                
             ImageJ Interest                                         Kopie
             Group                                                        
             <[hidden email].                                       Thema
             GOV>                       Macro question: test if a point is
                                        within selection/ROI              
                                                                           
             11.03.2008 20:32                                              
                                                                           
                                                                           
              Bitte antworten                                              
                    an                                                    
              ImageJ Interest                                              
                   Group                                                  
             <[hidden email].                                            
                   GOV>                                                    
                                                                           
                                                                           




Dear All,

Is it possible, in a macro, to find out if a given point lies within the
current selection / ROI.  I'm writing a macro to alter the intensity of
pixels within the selection, but can't figure out how to do this!

I've looked at getSelectionBounds and getSelectionCoordinates but so far as
I can't see a simple way to go from these to the coordinates of pixels
within the region.

thanks,
Jon



______________________________________________________________________
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
|

particle recognition & tracking problem

Franklin Shaffer-2
In reply to this post by Jonathan Jackson-2
I'm using a high speed camera and an endoscope to track particle motion in an energy process.  The particle images resemble spherical cells under a microscope, so I've found ImageJ to be a fantastic tool for this application (and for general image processing).
 
I'm a fluid dynamics engineer, so I'm new to cell recognition and tracking.  Since many experts are on this discussion list, I thought I would make some of my particle images available for anyone to view.  I've posted some of my high speed videos of particle motion at:
 ftp://ftp.netl.doe.gov/pub/Shaffer/
 
If anyone has any suggestions on how to recognize and track these particles with ImageJ, I would really appreciate your advice.
 
Thank you,
Frank
 
 
Franklin Shaffer, Senior Engineer
USDOE National Energy Technology Laboratory
Office of Research & Development
Computational Science Division
Mail Stop 84-202
626 Cochrans Mill Road
Pittsburgh, PA  15236
[hidden email]
Office: 412-386-5964
Cell: 412-833-3849

Franklin Shaffer.vcf (409 bytes) Download Attachment
Ruy
Reply | Threaded
Open this post in threaded view
|

Re: particle recognition & tracking problem

Ruy
Franklin

You should try these two plugins:

1) MTrackJ

http://www.imagescience.org/meijering/software/mtrackj/


2) Particle tracker

http://weeman.inf.ethz.ch/particletracker/


Good luck

Ruy Jaeger
Department of Cell Biology
Institute of Biomedical Sciences
University of Sao Paulo
Sao Paulo SP
Brazil


Citando Franklin Shaffer <[hidden email]>:

> I'm using a high speed camera and an endoscope to track particle  
> motion in an energy process.  The particle images resemble spherical  
>  cells under a microscope, so I've found ImageJ to be a fantastic  
> tool for this application (and for general image processing).
>
> I'm a fluid dynamics engineer, so I'm new to cell recognition and  
> tracking.  Since many experts are on this discussion list, I thought  
>  I would make some of my particle images available for anyone to  
> view.  I've posted some of my high speed videos of particle motion at:
>  ftp://ftp.netl.doe.gov/pub/Shaffer/
>
> If anyone has any suggestions on how to recognize and track these  
> particles with ImageJ, I would really appreciate your advice.
>
> Thank you,
> Frank
>
>
> Franklin Shaffer, Senior Engineer
> USDOE National Energy Technology Laboratory
> Office of Research & Development
> Computational Science Division
> Mail Stop 84-202
> 626 Cochrans Mill Road
> Pittsburgh, PA  15236
> [hidden email]
> Office: 412-386-5964
> Cell: 412-833-3849
>
Reply | Threaded
Open this post in threaded view
|

Re: Macro question: test if a point is within selection/ROI

Wayne Rasband
In reply to this post by Jonathan Jackson-2
> Is it possible, in a macro, to find out if a given point lies
> within the current selection / ROI.  I'm writing a macro to
> alter the intensity of pixels within the selection, but can't
> figure out how to do this!
>
> I've looked at getSelectionBounds and getSelectionCoordinates
> but so far as I can't see a simple way to go from these to the
> coordinates of pixels within the region.

You can add a value to all the pixels in the selection using

     run("Add...", "value="+value);

or multiply using

     run("Multiply...", "value="+value);

Use

     setColor(value);
     fill;

to set the pixels in the selection to a specified value.

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

Re: Macro question: test if a point is within selection/ROI

Jonathan Jackson-2
In reply to this post by Jonathan Jackson-2
On Wed, 12 Mar 2008 00:24:22 -0400, Rasband Wayne <[hidden email]> wrote:

>> Is it possible, in a macro, to find out if a given point lies
>> within the current selection / ROI.  I'm writing a macro to
>> alter the intensity of pixels within the selection, but can't
>> figure out how to do this!
>>
>> I've looked at getSelectionBounds and getSelectionCoordinates
>> but so far as I can't see a simple way to go from these to the
>> coordinates of pixels within the region.
>
>You can add a value to all the pixels in the selection using
>
>     run("Add...", "value="+value);
>
>or multiply using
>
>     run("Multiply...", "value="+value);
>
>Use
>
>     setColor(value);
>     fill;
>
>to set the pixels in the selection to a specified value.
>
>-wayne
>=========================================================================

Thanks for the reply. The operation I had in mind was to set the pixels
within a selection to values with a given mean and standard deviation. This
could be done using existing macro commands and a run() call, as you
suggest, but it's important to have the option to 'undo' this macro (see
"Macro feature request: prevent calls to run() creating undo snapshots" ) so
I was trying to modify pixels in the selection directly from the macro.  The
option to identify if a pixel is within the selection could potentially be
useful in other macro applications as well.  I could write a plugin to
operate on the selection, but it would be nice to do it all in the macro
tool code.

thanks again,

Jon
Reply | Threaded
Open this post in threaded view
|

batch analysis in ImageJ

chen li
In reply to this post by Wayne Rasband
Hi all,

I am pretty new to ImageJ.

Now I use WCIF ImageJ to do the nucleus counting after
taking pictures from the cells under microscope. It
works great. But I have a question: Since I am going
to process many pictures in one experiment is it
possible to do bacth analysis for all of them, instead
of opening one picture at a time?


Thanks,

Li


      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 
Reply | Threaded
Open this post in threaded view
|

Re: batch analysis in ImageJ

Eric BADEL
Hi,
Batch is clearly possible with ImageJ. You just need to write a macro
that load all the image in a directory and perform your image
processing. Here is a simple stupid example that just load each image
image, resize it and then save the resulting image.
Good luck
Eric

macro "Batch resize" {
dir = getDirectory("Choose a Directory ");
resizeDir = dir+"resized"+File.separator;
File.makeDirectory(resizeDir);
  if (!File.exists(resizeDir))
      exit("Unable to create resized directory");
list = getFileList(dir);
setBatchMode(true);
for (i=0; i<list.length; i++) {
path = dir+list[i];
showProgress(i, list.length);
if (!endsWith(path,"/")) open(path);
if (nImages>=1) {
x=getWidth();
y=getHeight();

if(x>y){
run("Size...", "width=400 height=300 constrain interpolate");
}
if(y>x){
run("Size...", "width=300 height=400 constrain interpolate");
}

saveAs("jpeg", resizeDir+getTitle());
close();
}
}
}
/// end Batch resize.
///





chen li a écrit :

> Hi all,
>
> I am pretty new to ImageJ.
>
> Now I use WCIF ImageJ to do the nucleus counting after
> taking pictures from the cells under microscope. It
> works great. But I have a question: Since I am going
> to process many pictures in one experiment is it
> possible to do bacth analysis for all of them, instead
> of opening one picture at a time?
>
>
> Thanks,
>
> L
Reply | Threaded
Open this post in threaded view
|

Re: batch analysis in ImageJ

chen li
Hi Eric,

Thank you for your script.

I also find a macro  which fits my need after "google"
the internet. I copy it and add some functions by
recording macro for my specific case. The problem is
that I get the following exception after I run it. I
wonder if you or others can help me fix it.

Thank all for the help,

Li

/*the macro I am using*/

// prompt user for source directory
dir1 = getDirectory("Choose Source Directory ");

// prompt user for dsetination directory
dir2 = getDirectory("Choose Destination Directory ");

// read in file listing from source directory
      list = getFileList(dir1);


// loop over the files in the source directory
      setBatchMode(true);
      for (i=0; i<list.length; i++) {
          showProgress(i+1, list.length);
          open(dir1+list[i]);
         
          run("Nucleus Counter", "smallest=1000
largest=2147483647 threshold=Otsu smooth=[Mean 3x3]
subtract watershed show");
          setThreshold(39, 255);
           imageCalculator("Subtract",
"Analysis","boundaries");
          imageCalculator("Add create",
"Analysis","boundaries");
          saveAs("Measurements",
dir2+list[i]+"."+"txt");
         
      }

/* The exception after running the macro
*/


/*
java.lang.NullPointerException
 at Nucleus_Counter.run(Nucleus_Counter.java:184)
 at ij.IJ.runUserPlugIn(IJ.java:273)
 at ij.IJ.runPlugIn(IJ.java:117)
 at ij.Executer.runPlugIn(Executer.java:171)
 at ij.Executer.runCommand(Executer.java:133)
 at ij.Executer.run(Executer.java:63)
 at ij.IJ.run(IJ.java:335)
 at ij.macro.Functions.doRun(Functions.java:510)
 at ij.macro.Functions.doFunction(Functions.java:62)
 at
ij.macro.Interpreter.doStatement(Interpreter.java:197)

 at ij.macro.Interpreter.doBlock(Interpreter.java:505)

 at
ij.macro.Interpreter.doStatement(Interpreter.java:233)

 at ij.macro.Interpreter.doFor(Interpreter.java:451)
 at
ij.macro.Interpreter.doStatement(Interpreter.java:215)

 at
ij.macro.Interpreter.doStatements(Interpreter.java:187)

 at
ij.macro.Interpreter.runMacro(Interpreter.java:110)
 at ij.macro.MacroRunner.run(MacroRunner.java:67)
 at java.lang.Thread.run(Unknown Source)


*/





--- Eric BADEL <[hidden email]> wrote:

> Hi,
> Batch is clearly possible with ImageJ. You just need
> to write a macro
> that load all the image in a directory and perform
> your image
> processing. Here is a simple stupid example that
> just load each image
> image, resize it and then save the resulting image.
> Good luck
> Eric
>
> macro "Batch resize" {
> dir = getDirectory("Choose a Directory ");
> resizeDir = dir+"resized"+File.separator;
> File.makeDirectory(resizeDir);
>   if (!File.exists(resizeDir))
>       exit("Unable to create resized directory");
> list = getFileList(dir);
> setBatchMode(true);
> for (i=0; i<list.length; i++) {
> path = dir+list[i];
> showProgress(i, list.length);
> if (!endsWith(path,"/")) open(path);
> if (nImages>=1) {
> x=getWidth();
> y=getHeight();
>
> if(x>y){
> run("Size...", "width=400 height=300 constrain
> interpolate");
> }
> if(y>x){
> run("Size...", "width=300 height=400 constrain
> interpolate");
> }
>
> saveAs("jpeg", resizeDir+getTitle());
> close();
> }
> }
> }
> /// end Batch resize.
> ///
>
>
>
>
>
> chen li a écrit :
> > Hi all,
> >
> > I am pretty new to ImageJ.
> >
> > Now I use WCIF ImageJ to do the nucleus counting
> after
> > taking pictures from the cells under microscope.
> It
> > works great. But I have a question: Since I am
> going
> > to process many pictures in one experiment is it
> > possible to do bacth analysis for all of them,
> instead
> > of opening one picture at a time?
> >
> >
> > Thanks,
> >
> > L
>



      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping