[Solved] how to find the black region in near the edge
color_img = imread(‘0k4Kh.jpg’); img = rgb2gray(color_img); [x, y] = size(img); for i = 1:x if length(find(img(i, :))) ~= 0 lastmarginalrow = i-1; break; end end for ii = y:-1:1 if length(find(img(:, ii))) ~= 0 lastmarginalcol = ii-1; break; end end figure; fig = imshow(color_img); h = impoly(gca, [0,x; lastmarginalcol,x; lastmarginalcol,lastmarginalrow; 0,lastmarginalrow]); api = iptgetapi(h); api.setColor(‘red’); … Read more