============================================================== FIND_TARGET_WARP: Finds the warp curve that transforms the input image into the reference space GENERAL points = find_target_warp(reference_image, input_image) INPUT/S -reference_image: The refrence image -input_image: The raw image to be warped to some reference -input_width: The width of the images OUTPUT/S -points: The warp curve points after correct warp has been found PENDING WORK -March 2004: Works for just image width 50 and needs to be extended. --FIXED March 2004 KNOWN BUG/S -None. COMMENT/S -DOES NOT YET WORK WITH OFFSETS. IT ASSUME BUMPS FLAT AT 0. RELATED FUNCTION/S LINEAR_WARP ABOUT -Created: March 7th, 2004 -Last update: March 22nd, 2004 -Revision: 0.0.4 -Author: R. S. Schestowitz, University of Manchester ==============================================================
0001 function points = find_target_warp(reference_image, input_image, image_width) 0002 % ============================================================== 0003 % FIND_TARGET_WARP: Finds the warp curve that transforms the input image 0004 % into the reference space 0005 % 0006 % GENERAL 0007 % 0008 % points = find_target_warp(reference_image, input_image) 0009 % 0010 % INPUT/S 0011 % 0012 % -reference_image: 0013 % The refrence image 0014 % 0015 % -input_image: 0016 % The raw image to be warped to some reference 0017 % 0018 % -input_width: 0019 % The width of the images 0020 % 0021 % OUTPUT/S 0022 % 0023 % -points: 0024 % The warp curve points after correct warp has been found 0025 % 0026 % PENDING WORK 0027 % 0028 % -March 2004: Works for just image width 50 and needs to be extended. 0029 % --FIXED March 2004 0030 % 0031 % KNOWN BUG/S 0032 % 0033 % -None. 0034 % 0035 % COMMENT/S 0036 % 0037 % -DOES NOT YET WORK WITH OFFSETS. IT ASSUME BUMPS FLAT AT 0. 0038 % 0039 % RELATED FUNCTION/S 0040 % 0041 % LINEAR_WARP 0042 % 0043 % ABOUT 0044 % 0045 % -Created: March 7th, 2004 0046 % -Last update: March 22nd, 2004 0047 % -Revision: 0.0.4 0048 % -Author: R. S. Schestowitz, University of Manchester 0049 % ============================================================== 0050 0051 % firstly find the edges. Will fail is smoothing is applied because it is a 0052 % very data-specific term. 0053 0054 for i=1:image_width-1, 0055 if (input_image(i) == 0 & input_image(i + 1) ~= 0) 0056 lo = i; 0057 elseif (input_image(i) ~= 0 & input_image(i + 1) == 0) 0058 hi = i; 0059 end 0060 if (reference_image(i) == 0 & reference_image(i + 1) ~= 0) 0061 ref_lo = i; 0062 elseif (reference_image(i) ~= 0 & reference_image(i + 1) == 0) 0063 ref_hi = i; 0064 end 0065 end 0066 % lo is the lower point where the bump begins (from left to right) and hi 0067 % is the point where the bump goes flat 0068 0069 if ((hi - lo) <= 0) 0070 % RSS: Check for exceptions here 0071 disp('Invalid values of high and low. Low must be lower than high'); 0072 return; % break out of function 0073 end 0074 0075 % Smith: line up the edge points, do linear stretch in between! 0076 0077 % Smith: first section - between 1 and lo 0078 % scale_factor1 = (ref_lo-1)/(lo-1); 0079 0080 points(1:image_width) = 1:image_width; 0081 0082 % set up an initial curve 0083 0084 scale_factor1 = (lo - 1) / (ref_lo - 1); 0085 0086 % factors are the a in f = ax + b 0087 0088 points(1:ref_lo) = (points(1:ref_lo) - 1) * scale_factor1 + 1; 0089 0090 % second section of the curve 0091 0092 scale_factor2 = (hi - lo)/(ref_hi - ref_lo); 0093 points(ref_lo + 1:ref_hi - 1) = (points(ref_lo + 1:ref_hi - 1) - ref_lo) * scale_factor2 + lo; 0094 0095 % scale_factor2 = (ref_hi - ref_lo)/(hi-lo); 0096 % points(:,lo+1:hi-1) = (points(:,lo+1:hi-1) - lo)*scale_factor2 + ref_lo; 0097 0098 % third section of the curve 0099 scale_factor3 = (image_width - hi) / (image_width - ref_hi); 0100 points(ref_hi:image_width) = ... 0101 (points(ref_hi:image_width) - ref_hi) * scale_factor3 + hi; 0102 0103 %scale_factor3 = (image_width-ref_hi)/(image_width-hi); 0104 %points(:,hi:image_width) = ... 0105 % (points(:,hi:image_width) - hi)*scale_factor3 + ref_hi;