SlideShare a Scribd company logo
1 of 13
Download to read offline
Lab 9
figure
figure อย่างเดียว จะไม่มีรูปขึ้น จะเป็นหน้าต่างสีเทา
การทาภาพให้เป็นสีเทา
ภาพที่ได้ออกมา
2 ภาพเมื่อเปรียบเทียบกัน
figure,imhist(gray) เรียกดูค่าการรังสีเชิงคลื่น
การแปลงเป็นขาว-ดา im2bw ( Black_White = im2bw(I))
figure,imshow(Black_White)
figure,imhist(Black_White)
ตารางเมตริก
เมื่อพิมพ์ colorbar จะมีแถบสีขึ้นด้านข้าง
เปิดภาพ กด seract แล้วกด crop
แล้วกด ctrl z เพื่อกลับมาทาข้างขวาอีกรอบ
ใช้ new script คือการเขียนคาสั่งทีเดียว
คาสั่งเปลี่ยนภาพสีเป็นเทา
L1 = rgb2gray(imread('left.jpg'));
L2 = rgb2gray(imread('right.jpg'));
เปลี่ยนภาพเทา เป็น แดง-ฟ้ าอ่อน
ตรงไตเติล จะพิมพ์ตัวเล็กหรือตัวพิมพ์ใหญ่ก็ได้
hold on;
ให้ภาพอยู่ในเฟลมเดียวกัน
%read image and transform gray
L1 = rgb2gray(imread('left.jpg'));
L2 = rgb2gray(imread('right.jpg'));
%part is showpair between left and right
imshowpair(L1,L2,'montage');
title('L1(left);L2(right)');
figure;
imshowpair(L1,L2,'ColorChannel','red-cyan');
title('Composite Image (Red - Left Image, Cyan - Right Image)');
blobs1 = detectSURFFeatures(L1,'MetricThreshold',2000);
blobs2 = detectSURFFeatures(L2,'MetricThreshold',2000);
figure;
imshow(L1);
hold on;
plot(selectStrongest(blobs1, 30));
title('Thirty strongest SURE features in L1');
figure;
imshow(L2);
hold on;
plot(selectStrongest(blobs2, 30));
title('Thirty strongest SURE features in L2');
[features1, validBlobs1] = extractFeatures(L1, blobs1);
[features1, validBlobs2] = extractFeatures(L2, blobs2);
indexPairs = matchFeatures(features1, features2, 'Metric',
'SAD','MatchThreshold', 5)
matchedPoints1 = validBlobs1(indexPairs(:,1),:);
matchedPoints2 = validBlobs2(indexPairs(:,2),:);
figure;
showMatchedFeatures(L1, L2, matchedPoints2);
legend('Putatively matched points in L1', 'Putatively matched points in L2');
[fMatrix, epipolarInliers, status] =
estimateFundamentalMatrix(matchedPoints1, matchedPoints2,'Method',
'RANSAC','NumTrials', 10000, 'DistanceThreshold', 0.1, 'Confidence', 99.99);
if status ~= 0 || is EpipoleInImage(fMatrix', size(L1))|| is
EpipoleInImage(fMatrix', size(L2))
erro(['Either not enought matching points were found']);
end
inlierPoints1 = matchedPoints1(epipolarInliers, :);
inlierPoints2 = matchedPoints2(epipolarInliers, :);
figure;
showMatchedFeatures(L1, L2, inlierPoints1, inlierPoints2);
legend('Inlier points in L1', 'Inlier points in L2');
[t1, t2] = estimateUncalibratedRectification(fMatrix, ...
inlierPoints1.Location, inlierPoints2.Location, size(L2));
tform1 = projective2d(t1);
tform2 = projective2d(t2);
I1Rect = imwarp(L1, tform1, 'OutputView', imref2d(size(L1)));
I2Rect = imwarp(L2, tform2, 'OutputView', imref2d(size(L2)));
% transform the points to visualize them together with the rectified images
pts1Rect = transformPointsForward(tform1, inlierPoints1.Location);
pts2Rect = transformPointsForward(tform2, inlierPoints2.Location);
figure;
showMatchedFeatures(L1Rect, L2Rect, pts1Rect, pts2Rect);
legend('Inlier points in rectified L1', 'Inlier points in rectified L2');
Irectified = cvexTransformImagePair(L1, tform1, L2, tform2);
figure;
imshow(Irectified);
title('Rectified Stereo Images (Red - Left Image, Cyan - Right Image)');
cvexRectifyImages('left.jpg', 'right.jpg');
I1 = rgb2gray(imread('Lion1.jpg'));
I2 = rgb2gray(imread('Lion2.jpg'));
imshowpair(I1, I2,'montage');
title('I1 (left); I2 (right)');
figure;
imshowpair(I1,I2,'ColorChannels','red-cyan');
title('Composite Image (Red - Left Image, Cyan - Right Image)');
blobs1 = detectSURFFeatures(I1, 'MetricThreshold', 2000);
blobs2 = detectSURFFeatures(I2, 'MetricThreshold', 2000);
figure;
imshow(I1);
hold on;
plot(selectStrongest(blobs1, 30));
title('Thirty strongest SURF features in I1');
figure;
imshow(I2);
hold on;
plot(selectStrongest(blobs2, 30));
title('Thirty strongest SURF features in I2');
[features1, validBlobs1] = extractFeatures(I1, blobs1);
[features2, validBlobs2] = extractFeatures(I2, blobs2);
indexPairs = matchFeatures(features1, features2, 'Metric', 'SAD', ...
'MatchThreshold', 5);
matchedPoints1 = validBlobs1(indexPairs(:,1),:);
matchedPoints2 = validBlobs2(indexPairs(:,2),:);
figure;
showMatchedFeatures(I1, I2, matchedPoints1, matchedPoints2);
legend('Putatively matched points in I1', 'Putatively matched points in I2');
[fMatrix, epipolarInliers, status] = estimateFundamentalMatrix(...
matchedPoints1, matchedPoints2, 'Method', 'RANSAC', ...
'NumTrials', 10000, 'DistanceThreshold', 0.1, 'Confidence', 99.99);
if status ~= 0 || isEpipoleInImage(fMatrix, size(I1)) ...
|| isEpipoleInImage(fMatrix', size(I2))
error(['Either not enough matching points were found or '...
'the epipoles are inside the images. You may need to '...
'inspect and improve the quality of detected features ',...
'and/or improve the quality of your images.']);
end
inlierPoints1 = matchedPoints1(epipolarInliers, :);
inlierPoints2 = matchedPoints2(epipolarInliers, :);
figure;
showMatchedFeatures(I1, I2, inlierPoints1, inlierPoints2);
legend('Inlier points in I1', 'Inlier points in I2');
[t1, t2] = estimateUncalibratedRectification(fMatrix, ...
inlierPoints1.Location, inlierPoints2.Location, size(I2));
tform1 = projective2d(t1);
tform2 = projective2d(t2);
I1Rect = imwarp(I1, tform1, 'OutputView', imref2d(size(I1)));
I2Rect = imwarp(I2, tform2, 'OutputView', imref2d(size(I2)));
% transform the points to visualize them together with the rectified images
pts1Rect = transformPointsForward(tform1, inlierPoints1.Location);
pts2Rect = transformPointsForward(tform2, inlierPoints2.Location);
figure;
showMatchedFeatures(I1Rect, I2Rect, pts1Rect, pts2Rect);
legend('Inlier points in rectified I1', 'Inlier points in rectified I2');
Irectified = cvexTransformImagePair(I1, tform1, I2, tform2);
figure;
imshow(Irectified);
title('Rectified Stereo Images (Red - Left Image, Cyan - Right Image)');
cvexRectifyImages('left.jpg', 'right.jpg');

More Related Content

More from putthita

Math กราฟ
Math กราฟMath กราฟ
Math กราฟputthita
 
Math กราฟ
Math กราฟMath กราฟ
Math กราฟputthita
 
Math กราฟ
Math กราฟMath กราฟ
Math กราฟputthita
 
Math กราฟ
Math กราฟMath กราฟ
Math กราฟputthita
 
ภาษา C เบื้องต้น
ภาษา C เบื้องต้นภาษา C เบื้องต้น
ภาษา C เบื้องต้นputthita
 

More from putthita (7)

Photoshop
PhotoshopPhotoshop
Photoshop
 
Math กราฟ
Math กราฟMath กราฟ
Math กราฟ
 
Mathlab
MathlabMathlab
Mathlab
 
Math กราฟ
Math กราฟMath กราฟ
Math กราฟ
 
Math กราฟ
Math กราฟMath กราฟ
Math กราฟ
 
Math กราฟ
Math กราฟMath กราฟ
Math กราฟ
 
ภาษา C เบื้องต้น
ภาษา C เบื้องต้นภาษา C เบื้องต้น
ภาษา C เบื้องต้น
 

Recently uploaded

Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 

Recently uploaded (20)

Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 

Mathlab

  • 2. figure อย่างเดียว จะไม่มีรูปขึ้น จะเป็นหน้าต่างสีเทา การทาภาพให้เป็นสีเทา
  • 7. เปิดภาพ กด seract แล้วกด crop แล้วกด ctrl z เพื่อกลับมาทาข้างขวาอีกรอบ ใช้ new script คือการเขียนคาสั่งทีเดียว
  • 8. คาสั่งเปลี่ยนภาพสีเป็นเทา L1 = rgb2gray(imread('left.jpg')); L2 = rgb2gray(imread('right.jpg')); เปลี่ยนภาพเทา เป็น แดง-ฟ้ าอ่อน ตรงไตเติล จะพิมพ์ตัวเล็กหรือตัวพิมพ์ใหญ่ก็ได้ hold on; ให้ภาพอยู่ในเฟลมเดียวกัน
  • 9. %read image and transform gray L1 = rgb2gray(imread('left.jpg')); L2 = rgb2gray(imread('right.jpg')); %part is showpair between left and right imshowpair(L1,L2,'montage'); title('L1(left);L2(right)'); figure;
  • 10. imshowpair(L1,L2,'ColorChannel','red-cyan'); title('Composite Image (Red - Left Image, Cyan - Right Image)'); blobs1 = detectSURFFeatures(L1,'MetricThreshold',2000); blobs2 = detectSURFFeatures(L2,'MetricThreshold',2000); figure; imshow(L1); hold on; plot(selectStrongest(blobs1, 30)); title('Thirty strongest SURE features in L1'); figure; imshow(L2); hold on; plot(selectStrongest(blobs2, 30)); title('Thirty strongest SURE features in L2'); [features1, validBlobs1] = extractFeatures(L1, blobs1); [features1, validBlobs2] = extractFeatures(L2, blobs2); indexPairs = matchFeatures(features1, features2, 'Metric', 'SAD','MatchThreshold', 5) matchedPoints1 = validBlobs1(indexPairs(:,1),:); matchedPoints2 = validBlobs2(indexPairs(:,2),:); figure; showMatchedFeatures(L1, L2, matchedPoints2); legend('Putatively matched points in L1', 'Putatively matched points in L2'); [fMatrix, epipolarInliers, status] = estimateFundamentalMatrix(matchedPoints1, matchedPoints2,'Method', 'RANSAC','NumTrials', 10000, 'DistanceThreshold', 0.1, 'Confidence', 99.99); if status ~= 0 || is EpipoleInImage(fMatrix', size(L1))|| is EpipoleInImage(fMatrix', size(L2)) erro(['Either not enought matching points were found']); end inlierPoints1 = matchedPoints1(epipolarInliers, :); inlierPoints2 = matchedPoints2(epipolarInliers, :); figure; showMatchedFeatures(L1, L2, inlierPoints1, inlierPoints2); legend('Inlier points in L1', 'Inlier points in L2'); [t1, t2] = estimateUncalibratedRectification(fMatrix, ... inlierPoints1.Location, inlierPoints2.Location, size(L2)); tform1 = projective2d(t1); tform2 = projective2d(t2); I1Rect = imwarp(L1, tform1, 'OutputView', imref2d(size(L1))); I2Rect = imwarp(L2, tform2, 'OutputView', imref2d(size(L2))); % transform the points to visualize them together with the rectified images pts1Rect = transformPointsForward(tform1, inlierPoints1.Location); pts2Rect = transformPointsForward(tform2, inlierPoints2.Location); figure; showMatchedFeatures(L1Rect, L2Rect, pts1Rect, pts2Rect); legend('Inlier points in rectified L1', 'Inlier points in rectified L2'); Irectified = cvexTransformImagePair(L1, tform1, L2, tform2);
  • 11. figure; imshow(Irectified); title('Rectified Stereo Images (Red - Left Image, Cyan - Right Image)'); cvexRectifyImages('left.jpg', 'right.jpg'); I1 = rgb2gray(imread('Lion1.jpg')); I2 = rgb2gray(imread('Lion2.jpg'));
  • 12. imshowpair(I1, I2,'montage'); title('I1 (left); I2 (right)'); figure; imshowpair(I1,I2,'ColorChannels','red-cyan'); title('Composite Image (Red - Left Image, Cyan - Right Image)'); blobs1 = detectSURFFeatures(I1, 'MetricThreshold', 2000); blobs2 = detectSURFFeatures(I2, 'MetricThreshold', 2000); figure; imshow(I1); hold on; plot(selectStrongest(blobs1, 30)); title('Thirty strongest SURF features in I1'); figure; imshow(I2); hold on; plot(selectStrongest(blobs2, 30)); title('Thirty strongest SURF features in I2'); [features1, validBlobs1] = extractFeatures(I1, blobs1); [features2, validBlobs2] = extractFeatures(I2, blobs2); indexPairs = matchFeatures(features1, features2, 'Metric', 'SAD', ... 'MatchThreshold', 5); matchedPoints1 = validBlobs1(indexPairs(:,1),:); matchedPoints2 = validBlobs2(indexPairs(:,2),:); figure; showMatchedFeatures(I1, I2, matchedPoints1, matchedPoints2); legend('Putatively matched points in I1', 'Putatively matched points in I2'); [fMatrix, epipolarInliers, status] = estimateFundamentalMatrix(... matchedPoints1, matchedPoints2, 'Method', 'RANSAC', ... 'NumTrials', 10000, 'DistanceThreshold', 0.1, 'Confidence', 99.99); if status ~= 0 || isEpipoleInImage(fMatrix, size(I1)) ... || isEpipoleInImage(fMatrix', size(I2)) error(['Either not enough matching points were found or '... 'the epipoles are inside the images. You may need to '... 'inspect and improve the quality of detected features ',... 'and/or improve the quality of your images.']); end inlierPoints1 = matchedPoints1(epipolarInliers, :); inlierPoints2 = matchedPoints2(epipolarInliers, :); figure; showMatchedFeatures(I1, I2, inlierPoints1, inlierPoints2); legend('Inlier points in I1', 'Inlier points in I2'); [t1, t2] = estimateUncalibratedRectification(fMatrix, ... inlierPoints1.Location, inlierPoints2.Location, size(I2)); tform1 = projective2d(t1); tform2 = projective2d(t2); I1Rect = imwarp(I1, tform1, 'OutputView', imref2d(size(I1))); I2Rect = imwarp(I2, tform2, 'OutputView', imref2d(size(I2))); % transform the points to visualize them together with the rectified images pts1Rect = transformPointsForward(tform1, inlierPoints1.Location); pts2Rect = transformPointsForward(tform2, inlierPoints2.Location);
  • 13. figure; showMatchedFeatures(I1Rect, I2Rect, pts1Rect, pts2Rect); legend('Inlier points in rectified I1', 'Inlier points in rectified I2'); Irectified = cvexTransformImagePair(I1, tform1, I2, tform2); figure; imshow(Irectified); title('Rectified Stereo Images (Red - Left Image, Cyan - Right Image)'); cvexRectifyImages('left.jpg', 'right.jpg');