Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes ImageJ Animator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "ImageJ Animator" Watch "ImageJ Animator" New topic
Author

ImageJ Animator

Chris Tjoumas
Greenhorn

Joined: Dec 17, 2003
Posts: 11
Hello. I have a program that reads in multiple stacks of images from a file. Currently, I am using a GridLayout to display a table of these stacks - Basically, a separate container class is used to display one image at a time of a stack. So, I have a table of these containers. I have a button to advance to the next slice in each stack - this all works fine.
My ultimate goal is to animate each stack. I have figured out how to animate a stack, however, the stack animates on a Frame (this is how ImageJ does it). Therefore, I cannot add the animated stacks (the frames) to my containers because:
java.lang.IllegalArgumentException: adding a window to a container
Is there any way around this? I could always keep the containers displaying the images of the stacks and allow the user to click on any stack in order to popup an animator for that stack, but the goal is to have all of these stacks animate at the same time - all next to eachother.
Hopefully I explained this good enough and didn't confuse anyone!
Thanks,
Chris
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi Chris,
Welcome to JavaRanch!
I'm not familiar with ImageJ, but if you've got the soruce I'm sure it'd be trivial to get the animations to appear in a JPanel instead of a JFrame. If you don't have the source, check the documentation. If ImageJ really, truly can't do this, then ditch it -- there are a zillion image-animation tools out there. There are several animation applets in the demos/applets/ subdirectory of your JDK installation -- any one of these should be trivial to adapt for your purposes.


[Jess in Action][AskingGoodQuestions]
Chris Tjoumas
Greenhorn

Joined: Dec 17, 2003
Posts: 11
I guess then that there is no way to add a frame to a panel. I was wondering if that could be done, and now that I guess it can't I'll look into getting the animator to be displayed on a frame - and ya, it *shouldn't* be too difficult.
Thanks!
Daniel Puryear
Greenhorn

Joined: Jun 02, 2002
Posts: 22
Chris,
If you truely mean Frame, it can't be added to any other lower level container because its under pinnings (aka Peer class) is a true native Window on the host's operating system (Windows, Solaris, AIS, etc...).
It has very special "helper" classes that enable it to interface with the OS (Window location, size, etc.) It looks like you already have the hard part of your problem solved. As was pointed out, there are a baZIllion samples out there to "flash" through a deck of images. Come back again if you don't find one appropriate for your needs.
Chris Tjoumas
Greenhorn

Joined: Dec 17, 2003
Posts: 11
Well, it doesn't seem so simple to change this animator from being displayed on a frame to a panel - there are many many subclasses that it uses and if one is changed it throws all of the other ones off.
What other packages can I use to play a stack of images? Anothing thing that would be useful is playing an avi movie... My program uses ImageJ to convert each stack to an AVI file, so an avi player would be nice. I know there is JMF, but it doesn't seem too helpful. I had tried it a couple weeks ago and it was complaining about my AVI file not being of the right format.
The goal of all of this is to allow the user to play a stack and be able to change the brightness/contrast of the movie and save it back. I have code in place to use the mouse to drag on the image and change the b&c, and if worse comes to worse (i.e. - there is no avi player that can mimic this and resave a b&c adjusted movie), I suppose I can always allow the user to drag on the image to change b&c, which would change the entire stack, and re-save the avi movie.
Thanks!
Chris
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

OK... I took a look at ImageJ (nice public-domain open source image processing tool written in Java by the NIH), and I don't think you're going to be able to do what you want at the GUI level. You're going to have to make some sort of plugin that 'merges' multiple stacks into a new stack. You're going to have to worry about things like :

  • layout - if you have 8 image stacks do you want them arranged in a 4x2 grid and 2x4 grid or a 3x3 grid with an empty space inserted somewhere? Should all stacks be of equal size (i.e. size of largest) or the size they originally are?
  • length - what if one stack is 10 slices long, one is 15, one is 2, etc.? Should blank frames be inserted at the start of the stack? end of the stack? Should frames be copied multiple times (for 'slow motion' effect)?
  • formats - what if the images in the stack are of different formats?


  • Once you are able to make this 'merge' plugin you should be able to use your current program to manipulate the brightness and contrast and generate an AVI from the new merged stack.


    -Nate
    Write once, run anywhere, because there's nowhere to hide! - /. A.C.
    Chris Tjoumas
    Greenhorn

    Joined: Dec 17, 2003
    Posts: 11
    I don't really need to save it out as an avi. My program will already have parsed out the raw files and archived them all with the corresponding jpg/avi files. What I would like to do is just be able to add each stack of images to my programs frame (which I am doing, and displaying them one image at a time - all stacks represented in a table structure) and be able to click a "play button" to animate them.
    A crude way of doing it would to just have a for loop to loop through each image of the stack and display each successive image - but that just sounds like a nasty hack. A nice simple, flexible animator would do the trick. I would like to not only start/stop animation, but change fps and use the mouse to drag on the animation (stopped though) in order to change brightness/contrast of the image. All of my logic is in place and ready to go, I just need to find a suitable animator.
    Any ideas?
    Chris Tjoumas
    Greenhorn

    Joined: Dec 17, 2003
    Posts: 11
    Well, it looks like I am just going to be writing my own animator. So far it looks good, but the only problem is that it seems the stacks are not animating synchronously. Each stack is stored in a class that uses a thread to loop through each image in the stack. Each of these classes is created in a for loop through all of the stacks - so as each class thread is created, they start animating. The problem is that they all start animating at different times. Is there any way to start them all at the same time?
    Thanks,
    Chris
    Chris Tjoumas
    Greenhorn

    Joined: Dec 17, 2003
    Posts: 11
    Oops! Nevermind... I had a bug in constructing my stacks - i fixed that and now the stacks are correct and the animation looks synchronized. I had this bug all along but I never noticed because I was never animating!
    Chris
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: ImageJ Animator
     
    Similar Threads
    Canvas HELP!!!
    ImageJ
    memento design pattern
    3d images
    why won't it work?