이것은 rgb 이미지이므로 회색 영역에는 명백한 색이 표시되지만 흰색 영역에는 분명 색이 없어야합니다. 이것을 사용하여 이미지를 찾으면 경계 상자를 얻을 수 있습니다.
%# get the areas and bounding box of the areas above threshold
%# as an additional criterion, you could also use excentricity
%# or you could simply remove the bottom 100 rows of the scan
stats = regionprops(tto,'BoundingBox','Area');
area = cat(1,stats.Area);
[~,maxAreaIdx] = max(Area);
bb = round(stats(maxAreaIdx).BoundingBox);
%# note that regionprops switches x and y (it's a long story)
croppedImage = img(bb(2):bb(2)+bb(4),bb(1):bb(1)+bb(3),:);
테두리의 비트가있다
%# invert tt so that it's 1 where there is signal
tt = ~tt;
%# clean up some of the smaller artifacts
tto = imopen(~tt,strel('square',100));
img = imread('http://i.stack.imgur.com/dEawA.jpg');
%# instead of "==" you can check for similarity within a tolerance
tt=img(:,:,1)==img(:,:,2) & img(:,:,2) == img(:,:,3);
인해 회전하는 왼쪽. 위의 마스크
tto
을 사용하여 자르기 전에 모든 비 이미지 픽셀을 NaN으로 설정하거나
imrotate
을 사용하여 이미지를 수정할 수 있습니다.
견본 이미지를 업로드 할 수 있습니까? – Jonas