Please help! I have an image similar to the one attached (a gradient from dark to light moving south to north with a horizontal white line which is of interest) I am trying to look along each vector in the y axis starting from the bottom of the image and locate the bottom of the white line. I could use a sobel-like edge detector but there are dark spots south of the white line..so going into a spot will give my detector a large negative value which I can ignore but as it leaves the dark spot and returns to the gradient I get a large positive value from my detector which I cannot distinguish from the edge where the bottom of the white line is. The code I tried to put together simultaneously grabs the sobel value and intensity at each point and adds to two distinct vectors (the vector with sobel values I use later to locate the max of each y axis vector/bottom edge of white line)..if there's a large negative sobel value (i.e. entering a dark spot) I hold on to the last intensity point prior to start of the spot and use a 'while' to pad the sobel vector with zeros, moving upward until the kernel is safely out of the dark spot (intensity values are greater than prior to entering the dark spot) at which point I start collecting the actual sobel values again. I'm loading an image of height 715 but my sobel vectors are ending up considerably larger than that...not sure what I'm doing wrong:
for n=1:1:width
sobVec=[];
intVec=[];
for k=height-5:-1:5
if (-4*double(J((k+4),n))-3*double(J((k+3),n))-2*double(J((k+2),n))-1*double(J((k+1),n))+0*double(J((k),n))+1*double(J((k-1),n))+2*double(J((k-2),n))+3*double(J((k-3),n))+4*double(J((k-4),n)))>-150
sobVec(end+1)=-4*double(J((k+4),n))-3*double(J((k+3),n))-2*double(J((k+2),n))-1*double(J((k+1),n))+0*double(J((k),n))+1*double(J((k-1),n))+2*double(J((k-2),n))+3*double(J((k-3),n))+4*double(J((k-4),n));
intVec(end+1)=J(k,n);
else
if isempty(intVec)
intVec=[1];
end
while J((k-1),n)<intVec(end)
k=k-1;
sobVec(end+1)=0;
end
if J((k-1),n)>intVec(end)*1.1
for i=1:1:5
k=k-1;
sobVec(end+1)=0;
end
end
end
end
end