All,
I ran into the situation desribed below, but don't understand Java well enough to know why what I'm doing is done this way. For what it's worth, I suspect I could do what I want to do easier using Stacks. I have an array of 5 ImageProcessor objects called ip. I want to display each object in turn using a loop. So first I declare an array of ImagePlus objects, called im. This is shown below. But, the array entries ar all null at this point. So, in the in the loop I again use new and an ImagePlus constructor to create an ImagePlus object, im[k], My question is can this be done without using "new" twice and/or is this correct. ImagePlus im[] = new ImagePlus[5]; for(int k = 0; k < 5; k++) { im[k] = new ImagePlus(); im[k].setProcessor("name",ip[k]); im[k].show(); } david Webster |
Hi,
On Thu, 1 Oct 2009, David William Webster wrote: > I ran into the situation desribed below, but don't understand Java well > enough to know why what I'm doing is done this way. For what it's worth, > I suspect I could do what I want to do easier using Stacks. > > I have an array of 5 ImageProcessor objects called ip. I want to display > each object in turn using a loop. So first I declare an array of > ImagePlus objects, called im. This is shown below. But, the array > entries ar all null at this point. So, in the in the loop I again use > new and an ImagePlus constructor to create an ImagePlus object, im[k], > My question is can this be done without using "new" twice and/or is this > correct. > > > ImagePlus im[] = new ImagePlus[5]; > > for(int k = 0; k < 5; k++) > { > im[k] = new ImagePlus(); > > im[k].setProcessor("name",ip[k]); > im[k].show(); > } You have to use the "new" operator twice. Why? Because you are instantiating two _different_ types of classes. One is and array, and one is and ImagePlus. Ciao, Johannes |
In reply to this post by David Webster
Hi,
this is so much easier with an ImageStack! show() will not "un"show other images! Simply create a stack and cycle throught it with setSlice! Mit freundlichen Grüßen / Best regards Joachim Wesner David William Webster <dwwebster00@GMAI An L.COM> [hidden email] Gesendet von: Kopie ImageJ Interest Group Thema <[hidden email]. ImageJ/Java Question GOV> 02.10.2009 04:38 Bitte antworten an ImageJ Interest Group <[hidden email]. GOV> All, I ran into the situation desribed below, but don't understand Java well enough to know why what I'm doing is done this way. For what it's worth, I suspect I could do what I want to do easier using Stacks. I have an array of 5 ImageProcessor objects called ip. I want to display each object in turn using a loop. So first I declare an array of ImagePlus objects, called im. This is shown below. But, the array entries ar all null at this point. So, in the in the loop I again use new and an ImagePlus constructor to create an ImagePlus object, im[k], My question is can this be done without using "new" twice and/or is this correct. ImagePlus im[] = new ImagePlus[5]; for(int k = 0; k < 5; k++) { im[k] = new ImagePlus(); im[k].setProcessor("name",ip[k]); im[k].show(); } david Webster ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
In reply to this post by David Webster
Other suggestion (only to verify basic things):
I assume you want to have a changing content in ONE window! (Even if not using slices), you would only need ONE ImagePlus and typically only ONE attached ImageProcessor. To have a dynamic content, you only need to periodically update the pixel array of the ImageProcessor and call updateAndDraw(), like the Plasma2_ example plugin does. Cheers Mit freundlichen Grüßen / Best regards Joachim Wesner ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ |
Joachim,
I had done my coding with arrays as I couldn't figure the documentation on stacks. But, I fixed that this moring and am now using stacks. I didn't quite understand your second email. What I am doing is writing some code to compute texture feature images ans wanted the array/stack to hold the different feature images. I used arrays at first because I assumed that if I wanted to use the all feature images in other TBD processes, that I had to disalky them so that ImageJ became aware of them outside of my plugin. David Webster On Fri, Oct 2, 2009 at 7:38 AM, Joachim Wesner < [hidden email]> wrote: > Other suggestion (only to verify basic things): > > I assume you want to have a changing content in ONE window! > > (Even if not using slices), you would only need ONE ImagePlus and typically > only ONE attached ImageProcessor. To have a dynamic content, > you only need to periodically update the pixel array of the ImageProcessor > and call updateAndDraw(), like the Plasma2_ example plugin does. > > Cheers > > Mit freundlichen Grüßen / Best regards > > Joachim Wesner > > > > ______________________________________________________________________ > This email has been scanned by the MessageLabs Email Security System. > For more information please visit http://www.messagelabs.com/email > ______________________________________________________________________ > |
Free forum by Nabble | Edit this page |