최근 두 개의 스테레오 이미지 쌍에 대한 이미지 정류와 관련하여 흥미로운 기사를 발견했습니다. 매우 컴팩트하고 기사에서 제시 한 것에서 옳은 일을했기 때문에 알고리즘이 마음에 들었습니다. 두 이미지에서 matlab 버전을 구현 한 후에 올바른 수정 이미지를 얻지 못했습니다. 픽셀이있는 왼쪽과 아래쪽 라인에서 핏치 블랙 인 이미지를 얻었습니다. 이미지에는 원본 이미지의 일부 회색 픽셀이 있지만 손이 가득 찼습니다. 나는 matlab 코드와 기사에 대한 링크와 한 이미지에 대한 결과의 예를 게시했다. (다른 이미지의 경우 동일했다)Matlab의 이미지 정류 알고리즘
이것은 A compact algorithm for rectification of stereo pairs 문서에 대한 링크입니다.
초기 이미지와 결과에 스크린 샷이 울부 짖는 소리입니다 :
초기 이미지 다음과 같은 두 개의 (다른 스테레오 쌍에 대한 검색하지 않아도되도록) :
이
function [T1,T2,Pn1,Pn2] = rectify(Po1,Po2)
% RECTIFY: compute rectification matrices
% factorize old PPMs
[A1,R1,t1] = art(Po1);
[A2,R2,t2] = art(Po2);
% optical centers (unchanged)
c1 = - inv(Po1(:,1:3))*Po1(:,4);
c2 = - inv(Po2(:,1:3))*Po2(:,4);
% new x axis (= direction of the baseline)
v1 = (c1-c2);
% new y axes (orthogonal to new x and old z)
v2 = cross(R1(3,:)',v1);
% new z axes (orthogonal to baseline and y)
v3 = cross(v1,v2);
% new extrinsic parameters
R = [v1'/norm(v1)
v2'/norm(v2)
v3'/norm(v3)];
% translation is left unchanged
% new intrinsic parameters (arbitrary)
A = (A1 + A2)./2;
A(1,2)=0; % no skew
A(1,3) = A(1,3) + 160;
% new projection matrices
Pn1 = A * [R -R*c1 ];
Pn2 = A * [R -R*c2 ];
% rectifying image transformation
T1 = Pn1(1:3,1:3)* inv(Po1(1:3,1:3));
T2 = Pn2(1:3,1:3)* inv(Po2(1:3,1:3));
function [A,R,t] = art(P)
% ART: factorize a PPM as P=A*[R;t]
Q = inv(P(1:3, 1:3));
[U,B] = qr(Q);
R = inv(U);
t = B*P(1:3,4);
A = inv(B);
A = A ./A(3,3);
내가 내 해결할 함수를 호출있는 "메인"코드
img1 = imread('D:\imag1.png');
img2 = imread('D:\imag2.png');
im1 = rgb2gray(img1);
im2 = rgb2gray(img2);
im1 = im2double(im1);
im2 = im2double(im2);
figure; imshow(im1, 'border', 'tight')
figure; imshow(im2, 'border', 'tight')
%pair projection matrices obtained after the calibration P01,P02
a = double(9.765*(10^2))
b = double(5.790*(10^-1))
format bank;
Po1 = double([a 5.382*10 -2.398*(10^2) 3.875*(10^5);
9.849*10 9.333*(10^2) 1.574*(10^2) 2.428*(10^5);
b 1.108*(10^(-1)) 8.077*(10^(-1)) 1.118*(10^3)]);
Po2 = [9.767*(10^2) 5.376*10 -2.400*(10^2) 4.003*(10^4);
9.868*10 9.310*(10^2) 1.567*(10^2) 2.517*(10^5);
5.766*(10^(-1)) 1.141*(10^(-1)) 8.089*(10^(-1)) 1.174*(10^3)];
[T1, T2, Pn1, Pn2] = rectify(Po1, Po2);
imnoua = conv2(im1, T1);
imnoua2 = conv2(im2, T2);
fprintf('Imaginea noua e \n');
figure; imshow(imnoua, 'border', 'tight')
figure; imshow(imnoua2, 'border', 'tight')
시간 내 주셔서 감사합니다!
왜 이미지를'T '로'conv'합니까? 기하학적 변환을 사용해서는 안됩니까? – Shai