a procedure to find the best motion vector for a reference block is to find the candidate motion vector that minimizes some error function f ( v ). in a normal window search , the set of candidates used for evaluation could be chosen as all vectors in a search window or a sub - set of these . in a possible subsequent refining extra test phase , the set of vectors can be chosen from results ( vectors ) in the local neighbourhood or through global analysis ( e . g . a global peak vector representing the most common motion ). f ( v ) is the error value corresponding to a vector v describing the motion between two frames ( parts thereof ). block matching is one such commonly used procedure known to those skilled in the arts , and this procedure will be used as reference for the description of the invention . in the general case , f ( v ) is a sum of the absolute differences per pixel raised to a power x , where the sum of squared differences ( x = 2 ) and sum of absolute differences ( x = 1 ) are two common examples . the invention uses a combined measure which in essence evaluates a linear motion over three frames , going from p to n , through c . this means that for a given candidate vector v , there are three reference points which are used in the evaluation , i . e . the current block in c , a relative offset in p according to vector v and a relative offset in n according to vector − v , see fig3 . using these reference points an error function is created consisting of three evaluation terms corresponding to the matches between c and p , c and n as well as n and p . in mathematical terms , the best vector is found according to the following expression : selected vector = min [ a *( f cp ( v )+ f cn ( v ))+ b * f np ( v )] vε { candidate vectors } f cp ( v ) is the error value corresponding to motion from c to offset v in p ; f cn ( v ) is the error value corresponding to motion from c to offset − v in n ; f np ( v ) is the error value corresponding to motion from offset − v in n to offset v in p ; a and b are adjustable weighting factors for balancing between error terms which include and does not include the current frame . the invention is especially useful for finding suitable motion used for reconstruction of damaged areas whether they are small or large . through the use of the term f np ( v ) it is less likely to find incorrect motion where , for instance , damages to some degree are improperly matched to actual content . by including the terms f cp ( v ) and f cn ( v ) it is also possible to properly consider the undamaged pixels in the current frame for improving the motion prediction of any neighboring damaged pixels . it also follows that any instability and ambiguity inherent with using only the term f np ( v ) is effectively reduced by this method . the weights a and b , are used to create a balance between the error terms which include and does not include the current frame . an optimal setting will depend on the image material and type of damages , so this will usually be a user setting . it is also possible to consider a and b to be adaptive per block with regard to known damages in the block , although a below discussed improvement is better than such a method . more information on how adaptation of a and b could be implemented is described below . with reference to block matching , the standard error function f ( v ) can be described as a sum of scaled differences over a window of a certain size corresponding to a block in the source frame , as follows : s ( x , y ) is a pixel in the source frame block ; r ( x + v x , y + v y ) is a pixel in the eference frame offset according to the vector v =( v x , v y ); g ( e ) is a “ scaling ” function , e . g . abs ( e ) or e 2 . using the terminology of current , previous and next frames , the current frame corresponds to the source frame which is partitioned into blocks of a certain width and height , where each block is assigned a motion vector . the reference frame would be either the previous or the next frame , which is used to determine the motion offset ( with pixel or sub - pixel precision ) for a block in the source frame . this description is useful for describing f cp ( v ) and f cn ( v ), and more precisely , the error functions f cp ( v ) and f cn ( v ) are calculated according to c ( x , y ) is a pixel in the current / source frame block ; r ( x + v ′ x , y + v ′ y ) is a pixel in the reference frame offset according to the vector v ′=( v ′ x , v ′ y ), where r and v ′ corresponds to p and + v for f cp ( v ), and n and − v for f cn ( v ); g ( e ) is a “ scaling ” function , e . g . abs ( e ) or e 2 . as the error function f np ( v ) is defined for a virtual source frame which is not included in the actual computation , that function is described slightly different as follows : p ( x + v x , y + v y ) is a pixel in the previous reference frame offset according to the vector v =( v x , v y ); n ( x − v x , y − v y ) is a pixel in the next reference frame offset according to the vector − v =(− v x ,− v y ). taking the standard error function used to initially describe f cp ( v ) and f cn ( v ), the invention can be further improved by introducing prior knowledge about the damage in the current frame , in a way that damaged pixels are excluded completely or to some degree in the error functions f cp ( v ) and f cn ( v ). the error functions f cp ( v ) and f cn ( v ) will then be modified to have the form w ( x , y ) is a weighting factor for the individual pixels in the source / current frame the weights applied to different pixels are in the range 0 to 1 and could be defined through user interaction or automated detection . using actual knowledge about damaged pixels , a user can point out these damages and also tell if damaged pixels should be disregarded completely when fully damaged or only to some degree when damaged pixels contain some information which could be relevant in the motion search . an automated detection could range from simple to very complex detection procedures . a simple automation procedure for determining w ( x , y ) is to use a confidence profile table or function related to the intensity of pixels in the source frame . heavy damages often show up as whitened or blacked out areas . an automation procedure could utilize this fact , by letting the weights decrease for increased brightness / blackness relative a normative central range of intensities with high confidence in non - damages . more complex damage detection procedures , could involve analysis over several frames , also including other types of motion estimation methods . apart from algorithmic detection procedures using visual domain data , automated detection could also involve scanning procedures analyzing infrared properties of the film to acquire knowledge about damages . the benefit of having infrared information , is that physical damages on a film are more easily detected in the infrared spectrum compared to the visible spectrum . using the modified error functions f cp ( v ) and f cn ( v ) the motion estimator can be balanced to gradually shift priority towards the f np ( v ) part in relation to a known or hypothesized amount of damage appearing in the current frame ( at the current block in question ). when “ fewer ” ( w ( x , y )& lt ; 1 ) pixels are included from the current frame due to the detected damages , the importance of f np ( v ) in the final expression will increase relative f cp ( v ) and f cn ( v ). the invention enables improved restoration of single frame damages . both variations of the invention ( initial and improved ) can be used in manual and automated procedures for damage repair . in manual restoration , a user selects which parts of an image should be restored , and thus which areas the described three - frame motion estimator primarily should be applied to . in automated restoration , an automated detection procedure selects which areas should be repaired using the methods of the invention . the invention can further be used for repair of heavily destructed single frames ( within a sequence ), for instance if the major part of an image need to be restored . it is possible to consider the methods of the invention to repair damages which are persistent over a few frames , e . g . a blotch appearing in two consecutive frames . in this case , p and n should reference the closest previous and next undamaged frames for the particular damage and c should correspond to one of the damaged frames , with vector offsets computed according to the distances between the frames p , c and n . one of many possible scenarios is one where an end - user manually determines which areas in a frame that should be restored . by manual selection , the user will create a mask representing the pixels that are undamaged or damaged ( or variably damaged ). to create the mask , the user could use something similar to a paint brush ( of certain shape / size / intensity ) or an area selection tool . the user &# 39 ; s tool for selection could also have an adaptive nature , for instance coupled to a damage confidence profile related to pixel intensity . in the scenario , for each brush stroke or selection the user applies in order to modify to the damage mask , the motion estimator will be invoked to compute / update a motion vector field in the local region of the current modifications . starting from a zero vector field , a motion vector map will be continuously computed / updated according to the areas the user selects for repair . usually a local neighborhood is also included in the motion search in order to provide stability . using the methods described in the invention , a hierarchical motion estimator , know to those skilled in the arts , will be able to provide a very accurate motion vector field which will enable an exemplary motion compensated reconstruction of the damaged areas . the damage mask created by the user could be used to represent the discussed pixel weighting w ( x , y ), if that part of the invention is used . for w ( x , y ), values between 0 and 1 would be used to represent pixels in a range from completely damaged to completely undamaged . in the reconstruction phase , the damaged pixels ( w ( x , y )!= 1 ) are replaced using the motion compensated pixels from the previous and next frames . the actual replacement can be performed in a number of ways , known to those skilled in the arts , but the easiest way is to replace a damaged pixel in c using the average of the corresponding pixels in p and n respectively ( using motion compensation ). the actual value of w ( x , y ) could also be included in this replacement procedure , for example similar to an alpha mix between the damaged source pixel and the reconstruction pixels in p and n .