function [max_length] = max_run_length_phi(I, ii,jj, phi) % % An auxillary function that computes the run length in the direction phi of an % image I starting at the pixel (ii,jj). That is how many pixels in the direction phi % match the current pixel value. % % Note ii,jj are indexed starting from 1. % % max_length = 0 if next pixel is NOT equal to this one (pixel is by % = 1 if we have two of the same pixels in a run % = 2 if we have three of the same pixels in a run % % Written by: % -- % John L. Weatherwax 2005-08-04 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % % Epage % %----- [di,dj] = phi_to_xy_increment(phi); [M,N] = size(I); d = 1; ij_value = I(ii,jj); max_length = 0; while( 1 ) % try to step in the direction phi: ii_new = ii+di*d; in_I_Range = (ii_new > 0) && (ii_new < M+1); if( ~in_I_Range ) break; end jj_new = jj+dj*d; in_J_Range = (jj_new > 0) && (jj_new < N+1); if( ~in_J_Range ) break; end if( I(ii_new,jj_new)~=ij_value ) break; end max_length = max_length + 1; d = d+1; % try to step more in the same direction end