How do I shift every other frame one pixel?

Hello!
I have data from a camera that took every other frame shifted over one frame. I was wondering if there was a way for me to shift only every other frame one pixel? Right now our data is presented as Graphs. Any suggestions would be much appreciated. Thank you!
You need to define precisely what you mean by "shift". Suppose your image is I(x,y) so you could have a new image G(x,y)=I(x+1,y+1) or have a shift in one coordinate only.
Thank you for your quick response. I need every other image shifted on the x-axis one pixel to the left. Could the above equation be adapted to work for every other image? Thank you.
We would need a little more info on how your data is organized.

For example it the data is a series of images such as Image001,Image002,Image003,... then you could set the scaling of the odd waves to start at 0,0 and the even waves at -1,-1 for example. You would write a small function to extract the numeric part of the name to determine which scaling it gets.

Do you have the data in an experiment you could share?
In case your frames are in a multidimensional wave
displayhelptopic "Indexing and Subranges"
might give helpful insight.

Right now our data is presented as Graphs:
Does it mean you use a line scan camera resulting in (1 x n) pixel images?

HJ
hbridgewater wrote:
Thank you for your quick response. I need every other image shifted on the x-axis one pixel to the left. Could the above equation be adapted to work for every other image? Thank you.


Obviously the simple (and slow method) is to execute the following:
Duplicate myImage,shiftedImage  // get wave of same dims
shiftedImage[0][]=0  // choose any value you want for this row.
shiftedImage[1,][]=myImage[p-1][q]   // note the shift direction; you may need to reverse it.


A more efficient approach would be to use ImageTransform:
ImageTransform /IOFF={1,0,0} offsetImage myImage  // setting dy=0 and background=0
NewImage M_OffsetImage   // check the result


I hope this helps,

A.G.
WaveMetrics, Inc.

Hello!
Both of these were helpful, but they would shift all of the Images instead of every other frame. Is there a way to do this only to every other frame?
Thank you!

Obviously the simple (and slow method) is to execute the following:
Duplicate myImage,shiftedImage  // get wave of same dims
shiftedImage[0][]=0  // choose any value you want for this row.
shiftedImage[1,][]=myImage[p-1][q]   // note the shift direction; you may need to reverse it.


A more efficient approach would be to use ImageTransform:
ImageTransform /IOFF={1,0,0} offsetImage myImage  // setting dy=0 and background=0
NewImage M_OffsetImage   // check the result



hbridgewater wrote:
Both of these were helpful, but they would shift all of the Images instead of every other frame. Is there a way to do this only to every other frame?
Thank you!



The assumption was that if you know how to shift one image you could shift a stack or every other image in a stack. To illustrate one way of doing that here is a function that you can paste in your procedure window and invoke from the command line:
Function shiftStack(inStack,isEven)
    Wave inStack
    Variable isEven
   
    Variable rows,cols,layers,i,count=0,newLayers
    rows=DimSize(inStack,0)
    cols=DimSize(inStack,1)
    layers=DimSize(inStack,2)
    newLayers=trunc(layers+1)/2
   
    // first make the destination wave:
    Make/O/N=(rows,cols,newLayers) shiftedStack
    // iterate over the rows
    for(i=0;i<layers;i+=1)
        if(isEven)
            if(mod(i,2)!=0)
                continue
            endif
        else
            if(mod(i,2)==0)
                continue
            endif
        endif
   
        ImageTransform/P=(i) getPlane inStack   // extract the layer of interest
        Wave M_ImagePlane          
        ImageTransform/P=(count)/INSI=M_ImagePlane/INSX=(1)/INSY=(0) insertImage shiftedStack
        count+=1
    endfor
End


I hope this helps,

A.G.
WaveMetrics, Inc.
Thank you for the help. I am new to using Igor and I was wondering if there would be a way to use the strategies you gave below with the [1,*;2] strategy for skipping even or odd points. I know that this is per image, but is there a way to modify this to work for a stack of images?
Thank you.

Obviously the simple (and slow method) is to execute the following:
Duplicate myImage,shiftedImage  // get wave of same dims
shiftedImage[0][]=0  // choose any value you want for this row.
shiftedImage[1,][]=myImage[p-1][q]   // note the shift direction; you may need to reverse it.


A more efficient approach would be to use ImageTransform:
ImageTransform /IOFF={1,0,0} offsetImage myImage  // setting dy=0 and background=0
NewImage M_OffsetImage   // check the result


hbridgewater wrote:
I am new to using Igor and I was wondering if there would be a way to use the strategies you gave below with the [1,*;2] strategy for skipping even or odd points. I know that this is per image, but is there a way to modify this to work for a stack of images?


To find out more about wave indexing method you can execute on the command line:
Displayhelptopic "Indexing and Subranges"


In this particular application you would have a third set of brackets indexing the layers. The third index is 'r' so:
shiftedEvenLayers[1,][][]=myImage[p-1][q][2*r]  
shiftedOddLayers[1,][][]=myImage[p-1][q][2*r+1]

where it is assumed that both waves on the left hand side of the equations are allocated with the appropriate number of layers.

While it is always good to learn how to manipulate waves in this manner, the function that I wrote for you in the previous post handles either all the even frames or all the odd frames in the stack in a more efficient way than any execution using wave indexing.

A.G.
WaveMetrics, Inc.
I am sorry that I keep going on about this, but is there a way to do this to a 3D image stack? These strategies worked well for my wave, but I was not able to shift the pixels on the image stack. Am I doing something incorrectly?
Thank you for all of your help!