How do I shift every other frame one pixel?
hbridgewater
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!
July 2, 2015 at 08:37 am - Permalink
July 2, 2015 at 09:33 am - Permalink
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?
July 2, 2015 at 10:42 am - Permalink
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
July 2, 2015 at 12:35 pm - Permalink
Obviously the simple (and slow method) is to execute the following:
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:
NewImage M_OffsetImage // check the result
I hope this helps,
A.G.
WaveMetrics, Inc.
July 3, 2015 at 09:44 am - Permalink
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:
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:
NewImage M_OffsetImage // check the result
July 7, 2015 at 08:59 am - Permalink
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:
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.
July 7, 2015 at 09:32 am - Permalink
Thank you.
Obviously the simple (and slow method) is to execute the following:
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:
NewImage M_OffsetImage // check the result
July 8, 2015 at 09:26 am - Permalink
To find out more about wave indexing method you can execute on the command line:
In this particular application you would have a third set of brackets indexing the layers. The third index is 'r' so:
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.
July 8, 2015 at 10:17 am - Permalink
Thank you for all of your help!
July 8, 2015 at 10:42 am - Permalink