rectifyStereoImages - Error using imref2d - Expected ImageSize to be positive.

1 vue (au cours des 30 derniers jours)
Krithika Balaji
Krithika Balaji le 13 Fév 2021
Hello,
I have a pair of stereo images that I am trying to rectify. I used these functions in MATLAB R2019a to do so:
I1 = imread("IMG_1.jpg");
I2 = imread("IMG_2.jpg");
I1 = imrotate(I1, -90);
I2 = imrotate(I2, -90);
load("f.mat");
data = xlsread("keypoints", "Stereo_Images");
inliers1 = data(:, 1:2);
inliers2 = data(:, 3:4);
[t1, t2] = estimateUncalibratedRectification(f, inliers1, inliers2, size(I2));
[I1rect, I2rect] = rectifyStereoImages(I1,I2,t1,t2);
where size(I2) = [4032 3024 3]. I1 is the same size as I2. The estimateUncalibratedRectification function works fine and gives the following:
t1:
0.723608082608398 0.413928084852519 0.000195673701093778
-1.04138341841754 0.220928003587292 0.000104437948810851
3118.45167713170 2115.39968089010 1
t2:
0.141528790443488 9.91393350589689 -0.000221135398080506
-3.08031416824115 10.1812457508437 0.00481291825975873
21683.1995762877 -14612.6238125421 1
I am getting errors with the rectifyStereoImages function, however. This is the error I get:
Error using imref2d
Expected ImageSize to be positive.
Error in imref2d (line 195)
validateattributes(imageSize, ...
Error in rectifyStereoImages>rectifyUncalibrated (line 235)
outputViewRef = imref2d([height, width], xLim, yLim);
Error in rectifyStereoImages (line 119)
[rectifiedImage1, rectifiedImage2] = rectifyUncalibrated(I1, I2, ...
Error in task5a (line 17)
[I1rect, I2rect] = rectifyStereoImages(I1,I2,t1,t2);
I am not sure what the problem is... I tried going into imref2d and rectifyUncalibrated but it didn't let me even print height and width on there. Any help would be greatly appreciated!

Réponses (1)

Aishwarya
Aishwarya le 13 Oct 2023
Hi Krithika,
After reviewing the information provided, I would suggest checking fundamental matrix “f” and the image match points (“inliners1” and “inliners2”) in the code.
Projective transformation matrix “t1” and “t2” generated by “estimateUncalibratedRectification” function needs be an invertible matrix. The projective transformation matrix “t1 in the code seems to be a singular matrix.
The singularity of the matrix can be checked using “rcond” or “cond” function.
cond(t1)
ans =
1.6299e+19
cond(t2)
ans =
6.5467e+06
The condition number of “t1” matrix is very large hence is singular matrix.
Below are some suggestions to estimate fundamental matrix and coordinates of corresponding points:
  • The “inliners1” and “inliners2” must contain points that do not lie on single planar surface and are putatively matched by using a function such as matchFeatures”.
  • To estimate fundamental matrix use “estimateFundamentalMatrix” function.
Please refer to below links for more information: 
Hope this helps!
Regards
Aishwarya

Catégories

En savoir plus sur Feature Detection and Extraction dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by