Combine multiple 2D images from a folder diretory into a 3D environment for visualisation.
Ältere Kommentare anzeigen
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 Kommentare
Image Analyst
am 18 Mär. 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
am 19 Mär. 2025
Chumani
am 19 Mär. 2025
Antworten (0)
Kategorien
Mehr zu Image Processing and Computer Vision finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!