Combine multiple 2D images from a folder diretory into a 3D environment for visualisation.
Show older comments
Please help with fixing and extending my code, I would like to combine images of different size from different angles or views into a 3D visualisation. The 3D visualisation has to be real not only points.
% Load images from a folder
imageFolder = 'Path';
images = imageDatastore(imageFolder);
% Detect feature points in each image
imagePoints = cell(numel(images.Files), 1);
for i = 1:numel(images.Files)
I = readimage(images, i);
grayImage = rgb2gray(I);
imagePoints{i} = detectSURFFeatures(grayImage);
end
% Extract features and match them across images
features = cell(numel(images.Files), 1);
for i = 1:numel(images.Files)
I = readimage(images, i);
grayImage = rgb2gray(I);
[features{i}, validPoints{i}] = extractFeatures(grayImage, imagePoints{i});
end
%Camera Intrinsics
focalLength = [10697 10770];
principalPoint = [2016 1512];
imageSize = [4042 3024];
intrinsics = cameraIntrinsics(focalLength,principalPoint,imageSize);
% Match features between consecutive images
indexPairs = matchFeatures(features{1}, features{2});
matchedPoints1 = validPoints{1}(indexPairs(:, 1));
matchedPoints2 = validPoints{2}(indexPairs(:, 2));
% Estimate the fundamental matrix
[F, inliers] = estimateFundamentalMatrix(matchedPoints1, matchedPoints2);
% Compute the camera poses
relativePose = relativeCameraPose(F, intrinsics, matchedPoints1(inliers), matchedPoints2(inliers));
% Reconstruct the 3D scene
Points =[];
for i = 1:length(imagePoints)
Points = vertcat(Points,imagePoints{i});
end
tracks = bundleAdjustment(Points , features, relativePose, intrinsics);
% Visualize the 3D model
pcshow(tracks);
xlabel('X');
ylabel('Y');
zlabel('Z');
title('3D Model Reconstruction');
3 Comments
Image Analyst
on 18 Mar 2025
I don't know what your code does but aren't you essentially describing computed tomography (CT)? For that you use filtered back projection. With projections from enough angles you can reconstruct the 3-D object. I'm not familiar with the functions you use so I don't know if they can do a CT-like filtered back projection.
The math for it won the inventors the Nobel Prize: https://www.nobelprize.org/prizes/medicine/1979/summary/#:~:text=Hounsfield-,Prize%20share:%201/2,development%20of%20computer%20assisted%20tomography%22
Chumani
on 19 Mar 2025
Chumani
on 19 Mar 2025
Answers (0)
Categories
Find more on Image Processing and Computer Vision in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!