Я бы не использовал функцию определения края, как вы указали в своем вопросе.
Скорее я бы сосредоточился на уменьшении размеров изображения и анализе «уменьшенного изображения». В следующем коде вы можете увидеть пример сокращения изображения на две репрезентативные линии и анализа линии для обнаружения образца.
% Load the image.
Img = imread('pfi36.png');
% Level to pass for the "edge" detection.
lvl = 50;
% Add a buffer around the edges.
buf = 10;
% Reduce the Image to 1D along the x and y driections respectively.
lrData = mean(Img,1);
tdData = mean(Img,2);
% Find the indices of the edges.
indL = find(lrData>lvl,1,'first');
indR = find(lrData>lvl,1,'last');
indB = find(tdData>lvl,1,'last');
% Show the Cropped image.
newImg = Img(1:(indB+buf),(indL-buf):(indR+buf));
imshow(newImg);