function points = find_linear_warp(ref_points_vec, ref_image_vec, image_width)
% FIND_LINEAR_WARP: Performs a linear warp on the data.
%
% Code written by Katherine Smith, 2003
%
%    GENERAL
%
%      points = find_linear_warp(ref_points_vec, ref_image_vec, image_width)
%
%    INPUT/S
%
%      -ref_points_vec:
%           Referecne points before warp is applied.
%
%      -ref_image_vec:
%           Image vector.
%
%      -image_width:
%           Image width (in 1-D).
%           
%    OUTPUT/S
%
%      -points:
%           The points after warp is applied.
%
%    PENDING WORK
%
%      -
%
%    KNOWN BUG/S
%
%      -None.
%
%    COMMENT/S
%
%      -
%
%    RELATED FUNCTION/S
%
%      LINEAR_WARP
%
%    ABOUT
%
%      -Created:     November 23rd, 2003
%      -Last update: Novermber 26th, 2003
%      -Revision:    0.0.2
%      -Author:      R. S. Schestowitz, University of Manchester
% ==============================================================

% Smith: need to find the right hi, lo, new_hi and new_lo to make correct warp
[params, result] = fminsearch(@eval_msd_linear_warp, [max(ref_points_vec)/4,max(ref_points_vec)*3/4,max(ref_points_vec)/4,max(ref_points_vec)*3/4],optimset('Display','off','TolX',0.001,'TolFun',0.001),ref_points_vec, ref_image_vec);
points = linear_warp(points, params(1),params(2),params(3),params(4));