...等、ハフ変換を用いてアムロのソリューション にそれを養う、またはFFTとそれを分析し、またはブロックを収めることができます。
%# load image, and process it
img = imread('print5.jpg');
img = imfilter(img, fspecial('gaussian',7,1));
BW = imcomplement(im2bw(img));
BW = imclearborder(BW);
BW(150:200,100:150) = 0; %# simulate a missing chunk!
%# detect dots centers
st = regionprops(BW, 'Centroid');
c = vertcat(st.Centroid);
%# hough transform, detect peaks, then get lines segments
[H,T,R] = hough(BW);
P = houghpeaks(H, 25);
L = houghlines(BW, T, R, P);
%# show image with overlayed connected components, their centers + detected lines
I = imoverlay(img, BW, [0.9 0.1 0.1]);
imshow(I, 'InitialMag',200, 'Border','tight'), hold on
line(c(:,1), c(:,2), 'LineStyle','none', 'Marker','+', 'Color','b')
for k = 1:length(L)
xy = [L(k).point1; L(k).point2];
plot(xy(:,1), xy(:,2), 'g-', 'LineWidth',2);
end
hold off
(私はファイル交換からimoverlay
機能を使用しています)
結果:
私たちは、あなたが格子位置や回転角度を推測することができ、それらを持っていたら、
ここでは、検出された行に対応するピークが強調表示されたアキュムレータ行列を示します。
0123ここ
%# filter lines to extract almost vertical ones
%# Note that theta range is (-90:89), angle = theta + 90
LL = L(abs([L.theta]) < 30);
%# compute the mean slope of those lines
slopes = vertcat(LL.point2) - vertcat(LL.point1);
slopes = atan2(slopes(:,2),slopes(:,1));
r = mean(slopes);
%# transform image by applying the inverse of the rotation
tform = maketform('affine', [cos(r) sin(r) 0; -sin(r) cos(r) 0; 0 0 1]);
img_align = imtransform(img, fliptform(tform));
imshow(img_align)
:
今我々は2つの方向(水平位置または垂直型)のいずれかのものに濾過検出された線の平均勾配を計算することによって回転角度を回復することができグリッドをXY軸と整列するように画像バック回転さ:
LOOを試しますキングの広告の周波数の内容: 'fft2'グリッドは非常に規則的です、あなたは周波数領域でピークを見つけることができるはずです。 – Shai
上記のコメントのすべての情報をあなたの質問に編集すると、その情報を再度開くことができるはずです。 –
うわー、これは短い時間で多くのdownvotesを引き付けました。私はそれがなぜ閉鎖されたのか理解していますが、実際には-20のダウンボートが必要ですか? – Amro