Dear imagers,
Please excuse a very basic question, but is there a way to select an image without activating it, like the command ChoosePic in NIH Image? I have a lot of NIHI macros that I really ought to convert to ImageJ (since Apple is no longer supporting the Classic environment), and many of these involve frequently switching between several open images. All I know how to do in ImageJ is SelectImage, which activates the image. Using this, even a very modest macro that simply switches between two open images and back again for each pixel in turn, takes an impossibly long time (hours) to run, whereas I can run it in seconds in NIH Image, so I feel I must be doing something stupid or missing something obvious. AutoUpdate(false) doesn't make any difference... Any statements of the obvious (to you) would be appreciated by me! Gareth Dr W G Rees Scott Polar Research Institute University of Cambridge Lensfield Road Cambridge CB2 1ER United Kingdom T. +44 1223 336540/336575 F. +44 1223 336549 |
Hi Gareth,
Did you try setBatchMode(true) at the start of your macro? -Curtis On 12/15/06, Dr Gareth Rees <[hidden email]> wrote: > Dear imagers, > > Please excuse a very basic question, but is there a way to select an > image without activating it, like the command ChoosePic in NIH Image? > I have a lot of NIHI macros that I really ought to convert to ImageJ > (since Apple is no longer supporting the Classic environment), and > many of these involve frequently switching between several open > images. All I know how to do in ImageJ is SelectImage, which > activates the image. Using this, even a very modest macro that simply > switches between two open images and back again for each pixel in > turn, takes an impossibly long time (hours) to run, whereas I can run > it in seconds in NIH Image, so I feel I must be doing something > stupid or missing something obvious. AutoUpdate(false) doesn't make > any difference... > > Any statements of the obvious (to you) would be appreciated by me! > > Gareth > > > > > Dr W G Rees > Scott Polar Research Institute > University of Cambridge > Lensfield Road > Cambridge CB2 1ER > United Kingdom > T. +44 1223 336540/336575 F. +44 1223 336549 > |
Thank you Curtis!
That was definitely the magic spell I was looking for - the same (admittedly pointless) task now runs in less than 0.5 s. I shall now spend a happy weekend recoding macros from NIH Image to Image J, and feel more relaxed about the demise of the Apple Classic environment. Gareth On Dec 15 2006, Curtis Rueden wrote: >Hi Gareth, > >Did you try setBatchMode(true) at the start of your macro? > >-Curtis > >On 12/15/06, Dr Gareth Rees <[hidden email]> wrote: >> Dear imagers, >> >> Please excuse a very basic question, but is there a way to select an >> image without activating it, like the command ChoosePic in NIH Image? >> I have a lot of NIHI macros that I really ought to convert to ImageJ >> (since Apple is no longer supporting the Classic environment), and >> many of these involve frequently switching between several open >> images. All I know how to do in ImageJ is SelectImage, which >> activates the image. Using this, even a very modest macro that simply >> switches between two open images and back again for each pixel in >> turn, takes an impossibly long time (hours) to run, whereas I can run >> it in seconds in NIH Image, so I feel I must be doing something >> stupid or missing something obvious. AutoUpdate(false) doesn't make >> any difference... >> >> Any statements of the obvious (to you) would be appreciated by me! >> >> Gareth >> >> >> >> >> Dr W G Rees >> Scott Polar Research Institute >> University of Cambridge >> Lensfield Road >> Cambridge CB2 1ER >> United Kingdom >> T. +44 1223 336540/336575 F. +44 1223 336549 >> > -- Dr W Gareth Rees Polar Landscape and Remote Sensing Group Scott Polar Research Institute, University of Cambridge T. (+44) 1223 336540/336575 F. (+44) 1223 336549 |
On Friday 15 December 2006 20:07, Dr W.G. Rees wrote:
> All I know how to do in ImageJ is SelectImage, which > activates the image. Using this, even a very modest macro that simply > switches between two open images and back again for each pixel in > turn, takes an impossibly long time (hours) to run, A further suggestion to the batch mode flag: There is obviously an overhead in switching to an image and accessing a pixel from it, so if you do this for every pixel, it becomes quite time consuming. What you can do instead is to read the entire images into arrays and then work from the arrays, so you access only the target image (to put the result) and save all the overhead processing of the switching. For this, plugins are better than macros. The macro language (unlike plugins) does not support 2D arrays, so one has to store the image as a 1D array. 1D arrays in plugins are also faster to process than 2D arrays. I hope it helps, Gabriel |
This looks like a good suggestion too, but a bit daunting because it means
I have to learn Java first! (For me, the most natural and comfortable progamming language is Fortran, which probably shows my age.) It'll be a battle between inertia and frustration as usual - I'll teach myself Java when I can't bear the delays implicit in not knowing it any more. Thanks for the extra input Gareth On Dec 16 2006, Gabriel Landini wrote: >On Friday 15 December 2006 20:07, Dr W.G. Rees wrote: >> All I know how to do in ImageJ is SelectImage, which >> activates the image. Using this, even a very modest macro that simply >> switches between two open images and back again for each pixel in >> turn, takes an impossibly long time (hours) to run, > > A further suggestion to the batch mode flag: There is obviously an > overhead in switching to an image and accessing a pixel from it, so if > you do this for every pixel, it becomes quite time consuming. What you > can do instead is to read the entire images into arrays and then work > from the arrays, so you access only the target image (to put the result) > and save all the overhead processing of the switching. For this, plugins > are better than macros. The macro language (unlike plugins) does not > support 2D arrays, so one has to store the image as a 1D array. 1D arrays > in plugins are also faster to process than 2D arrays. > >I hope it helps, > >Gabriel > -- Dr W Gareth Rees Polar Landscape and Remote Sensing Group Scott Polar Research Institute, University of Cambridge T. (+44) 1223 336540/336575 F. (+44) 1223 336549 |
Free forum by Nabble | Edit this page |