Implementing frame slider for image volume display in panel

I am trying to create a panel that use a slider to change the frame of an image volume (3D wave). This is very similar to the "Add Slider" in the Image Processing package of Igor. However I notice a very bad lag for the image display to update using my own SliderProc as shown below. On the same project, I use Igor's "Add Slider" on the same image volume displayed in a separate plot (not on a panel) and it gives a very smooth change when I move the slider. Is there anything that I might do wrong with my code?

Thanks a lot!

Function SliderProc_ImgFrame(sa) : SliderControl
    STRUCT WMSliderAction &sa

    switch( sa.eventCode )
        case -1: // control being killed
            break
        default:
            if( sa.eventCode & 1 ) // value set
                Variable curval = sa.curval
               
                modifyimage /W=SLP_ImgXPS_Panel_01#IX_ImgW WF01 plane=(curval)
                   
            endif
            break
    endswitch

    return 0
End


For the slider's limit, I use "Slider Slider_Img limits={0,dimsize(ImgVolW,2),1}"
Hey,

I think, the dimension slide has to go correctly from 0 but to: dimsize(ImgVolW,2)-1

Secondly, you can write the switch and actually use the cases, something like:

switch( sa.eventCode )
        case -1: // control being killed
            break

                case 9: //drag

            modifyimage /W=SLP_ImgXPS_Panel_01#IX_ImgW WF01 plane=(sa.curval)
 
            break
    endswitch


As to slow, what is the dimension of the images?


best,
_sk

Your slider is slow because on each change in the displayed layer, Igor has to recompute the min and max values of the frame in order to scale the color table. You can get around that point by executing a global WaveStats for the 3D wave and then execute:
    ModifyImage imageName ctab= {V_min,V_max,,0}    // missing ctb to leave it unchanced.


Now Igor would use the global min and max values to compute the same scaling for all frames.

I hope this helps,

A.G.
WaveMetrics, Inc.