How to rapidly cycle through multiple 2-D grayscale images

I have several hundred images and would like to be able to display them in a single window as simple grayscale images and to selectively move from one frame to the next with a slider or other control.  I've tried appending multiple images to a single window but I can't figure out how to cycle from one image to the next. Or maybe there's a better way of doing this.  Thanks for any help !

In its current iteration, the Image Tools should be able to import a folder of existing grayscale images into its internal database structure. The movement through the image stack is with a set variable control or with a play as movie button.

Take a test drive at the link below.

https://www.wavemetrics.com/node/21002

I have an update in progress to improve how it loads grayscale TIFF images among other things. I'd be glad to take other recommendations, especially before the next release.

Otherwise, if you are rolling your own code, the ReplaceWave operation with the image flag should do what you need. Couple it to a set variable or slider call to increment through your images. I recommend that you work with an image stack. The selection is so much easier to make when the set variable or slider is simply the number of the plane (layer) in the image stack than when it has to be decoded to a list position of waves in a data folder. To promote my own development again, this approach is all handled automatically in the Image Tools package. I do not scroll through individual files, I scroll through image stacks.

If you only want to display greyscale:

Concatenate all 2D greyscale waves into a 3D image cube, here some fake data:

make/O/N=(100,100,512) cube = enoise(1)
MatrixOP/O wImage = Sumbeams(cube)
NewImage/N=image wImage
variable /g layer = 0

then use a hook function and the mouse wheel to scroll through the cube,

Function myHook(s)
    STRUCT WMWinHookStruct &s
   
    // need some globals
    NVAR n = layer 
    wave w = root:cube
    wave Image = root:Image
    variable maxLayer = DimSize(w,2)-1
   
    switch(s.eventCode)
       
        case 22:        // handle mousewheel
            if (s.wheelDy < 0)             
                n = n == MaxLayer ? maxlayer : n+1
                printf "increase layer number, %g\r", n
            else                               
                n = n == 0 ? 0 : n-1
                printf "decrease layer number, %g\r", n
            endif  
           
            // update image
            MatrixOP/O Image = layer(w,n)
           
            break
    endswitch
   
    return 0
End

 

and apply the hook:

SetWindow Image,hook(s)=myHook  

 

 

 

 

In reply to by rjhamers

Since you have Image Tools in the User Procedures folder, enter this at the top of your experiment's Procedure window:

#include "Image Tools Main"

then compile, and look in the new Packages menu on your updated menu bar.

Here is another approach:

 

In IP8 you can load all your images into a single 3D wave.  You may want to check the /AINF flag in ImageLoad.

Once you have a 3D wave display it as an image, e.g.,

NewImage/K=0 ddd

Click on the new image window and you will see and Image menu in the menu bar.  Select "Add Slider" and you will get a slider on top of your image which allows you to quickly go through the images.

 

 

AG has posted the simplest solution, especially if you only want to scroll through images. For that, the Image Tools package is overkill (although it does avoid you having to write code to load the images as a stack).

I'm curious otherwise if you find the package useful, and we are all likely curious what you finally end up doing. Let us know.

Thanks to all- I did the simple approach you mention, and it worked great.  I also did get the image tools package to load just fine, and will take some time to explore it. But for my immediate need the single 3D image with slider is working great.  Thanks much!