sniklaus / pytorch-pwc

a reimplementation of PWC-Net in PyTorch that matches the official Caffe version
GNU General Public License v3.0
608 stars 122 forks source link

what is the range of optical flow value in an image? #50

Closed Pixie8888 closed 3 years ago

Pixie8888 commented 3 years ago

Hi, Thanks for this work! I use this pwcnet to estimate optical flow. I have a question regarding the value range of optical flow. Is it range from (-w+1, w-1) (-h+1, h-1)? If I want to normalise optical flow to (-1,1), should I follow this: optical_flow[0,:,:] = optical_flow[0,:,:]/ (w-1) optical_flow[1,:,:] = optical_flow[1,:,:]/ (h-1)? (w and h is the image size. optical_flow_shape = (2, h, w))

sniklaus commented 3 years ago

The neural network is not constrained to any range. If you want the estimated optical flow to be within the range of [-1, 1] you will have to divide by w and h respectively.