SoftwarePractice.org: Home | Courseware | Wiki | Archive

Rotate bc.m Code

From SoftwarePractice.org

% rotate_bc.m
% This function flips the bar code if the bar code upside down 
% returns the flip image(array) and and flag to be use to 
% to inform user weather the original image flips
% Use [rotateUI,flag]= rotate_bc(I)
% If the flag =1 image upside down, if not (flag =0) image upright

function [rotateUI,flag]= rotate_bc(bc4)
%Rotate barcode if barcode upside down, retrun original if image correct
if (mod(sum(bc4(1:7)==1),2)==0 && mod(sum(bc4(48:54)==1),2)==1)
   flag=1; % set the flag value to 1
   rotateUI=fliplr(bc4);
else
   flag=0; %set the flag value to 0
   rotateUI=bc4;
end

To return back to the angular rotation page: Angular Rotation

Personal tools