function ans = findedge(a) % M-file call MUST be in form of findedge(img), NOT findegde img !! sz=size(a); topcols = 100; toprows=62; botcols = sz(2)-100; botrows = sz(1)-62; whitetol = 130; pixels=100; found=0; ans = [0 0 0 0]; for i = 1:toprows; for j = 1:topcols; if (mean( [mean( a(i:i+pixels,j,:) ) , mean( a(i,j:j+pixels,:) ) ] ) < whitetol) ans(1) = i; ans(2) = j; found = 1; break; end; end; if (found == 1) break; end; end; if (found == 0) ans=[999 999]; end; for m = sz(1): -1: botrows; for n = sz(2): -1: botcols; if (mean([ mean( a(m-pixels:m,n,:)) , mean( a(m,n-pixels:n,:)) ])