MATLAB codes end % calculate profile endpoints at the image borders if 0
Evaluation of the small angle data % calculate intensity profile part1 = improfile ( matrix, [endpoints(1),position(1)] , ... [endpoints(3),position(2)] ) ; part2 = improfile ( matrix, [position(1),endpoints(2)] , ... [position(2),endpoints(4)] ) ; part2 = part2(2:end) ; % first pixel is already in part1 ! intensity = [part1;part2] ; % calculate error profile part1 = improfile ( errormatrix, [endpoints(1),position(1)] , ... [endpoints(3),position(2)] ) ; part2 = improfile ( errormatrix, [position(1),endpoints(2)] , ... [position(2),endpoints(4)] ) ; part2 = part2(2:end) ; % first pixel is already in part1 ! error = [part1;part2] ; % calculate scale if range > 1 modulo1 = mod ( size(part1,1) - ceil(range/2) , range ) ; modulo2 = mod ( size(part2,1) - floor(range/2) , range ) ; intensity = intensity ( modulo1+1 : size(part1,1)+size(part2,1)-modulo2 ) ; intensity = reshape (intensity, range, []) ; error = error ( modulo1+1 : size(part1,1)+size(part2,1)-modulo2 ) ; error = reshape (error, range, []) ; weight = 1 ./ error.^2 ; weighted_intensity = intensity .* weight ; intensity = sum (weighted_intensity, 1) ./ sum (weight, 1) ; intensity = intensity’ ; error = 1 / sqrt(range) .* 1 ./ sqrt ( sum (weight, 1) ) ; error = error’ ; else modulo1 = 0 ; end length = sqrt ( ( x_end - x_start )^2 + ( y_end - y_start )^2 ) ; number = size ( intensity , 1 ) ; pixels = 1 : length/number : length ; pixels = pixels - pixels( ceil ( ( size(part1,1) - modulo1 ) / range ) ) ; pixels = pixels’ ; end 91