A method of encoding a pixel block in a frame of an image or a video sequence, said method comprising the steps of: estimating, based on pixel values of said pixel block, a displacement vector identifying a reference pixel block in a reference frame of said image or said video sequence; defining a template comprising multiple pixels and being positioned adjacent to said pixel block in said frame, and prior to pixels of the pixel block in an encoding order; identifying a corresponding reference template comprising multiple pixels and being positioned adjacent to said reference pixel block in said reference frame; determining a prediction template based on said reference template and at least one interpolation filter; determining a difference template based on pixel values of said multiple pixels of said template and pixel values of multiple pixels of said prediction template; determining at least one filter parameter of an adaptive filter, the determining comprising determining a tuning template by filtering pixel values of said multiple pixels of said reference template with said adaptive filter, and determining said at least one filter parameter of said adaptive filter by minimizing a least squares error between said difference template and said tuning template; determining filtered pixel values based on pixel values of said reference pixel block and said adaptive filter; determining an encoded representation of said pixel block based on said pixel values of said pixel block and said filtered pixel values, wherein said encoded representation comprises an encoded representation of said displacement vector; and determining a prediction pixel block based on said reference pixel block and said at least one interpolation filter, wherein said step of determining said encoded representation comprises determining said encoded representation based on said pixel values of said pixel block, said filtered pixel values, and pixel values of multiple pixels of said prediction pixel block. estimating, based on pixel values of said pixel block, a displacement vector identifying a reference pixel block in a reference frame of said image or said video sequence; defining a template comprising multiple pixels and being positioned adjacent to said pixel block in said frame, and prior to pixels of the pixel block in an encoding order; identifying a corresponding reference template comprising multiple pixels and being positioned adjacent to said reference pixel block in said reference frame; determining a prediction template based on said reference template and at least one interpolation filter; determining a difference template based on pixel values of said multiple pixels of said template and pixel values of multiple pixels of said prediction template; determining at least one filter parameter of an adaptive filter, the determining comprising determining a tuning template by filtering pixel values of said multiple pixels of said reference template with said adaptive filter, and determining said at least one filter parameter of said adaptive filter by minimizing a least squares error between said difference template and said tuning template; determining filtered pixel values based on pixel values of said reference pixel block and said adaptive filter; determining an encoded representation of said pixel block based on said pixel values of said pixel block and said filtered pixel values, wherein said encoded representation comprises an encoded representation of said displacement vector; and determining a prediction pixel block based on said reference pixel block and said at least one interpolation filter, wherein said step of determining said encoded representation comprises determining said encoded representation based on said pixel values of said pixel block, said filtered pixel values, and pixel values of multiple pixels of said prediction pixel block.