Azzera filtri
Azzera filtri

Reconstruct dewarped image given a few pixel position in real-world coordinate

3 visualizzazioni (ultimi 30 giorni)
I have four images of a calibration plate. Each image shows a different vertical section of the plate. the images are upside down, showing a water level near the bottom of the frame. The images overlap. For each frame, I know the intrinsic coordinates (I, in the code) of the dots and their positions in the real world (W, in the code). imagePoints2 is just a check that the transformation is correct. I'm trying to dewarp the entire image based on the knowledge of the intrisic coordinate of the warped image and the real world coordinate of the true (dewarped) image. The ideal output is a dewarped image that preserves as much resolution as posible. Here's some code and data to visualize the images and dots:
%% Check calibration is porperly aligned
colors = {'r', 'b', 'g', 'k'};
cams = 'ACBD'; %order of cameras from left to right in experiment
figure(1)
for cam = 1:4
scatter(imagePoints2{cam}(:,1),imagePoints2{cam}(:,2),'o','MarkerEdgeColor', colors{cam}, 'LineWidth', 1); hold on
scatter(W{cam}(:,1),W{cam}(:,2),'+','MarkerEdgeColor', colors{cam}, 'LineWidth', 1); hold on
xlabel("x (m)")
ylabel("z (m)")
end
Undefined variable 'imagePoints2'.
hold off
figure(2)
for cam = 1:4
subplot(1,4,cam)
imshow(calImg{cam}); hold on
scatter(I{cam}(:,1),I{cam}(:,2),'o','MarkerEdgeColor', colors{cam}, 'LineWidth', 1); hold on
xlabel("x (px)")
ylabel("z (px)")
end
hold off
The order of the cameras is off, I know. Image of camera C was to big to upload even compressed. I tried this, for example,
% Define your pixel values and their corresponding real-world coordinates
mov_p = I; fix_p = W;
pixelValues = cal(:); % Example pixel values
realWorldCoordinates = fix_p; % Example real-world coordinates
% Create a scatteredInterpolant
F = scatteredInterpolant(realWorldCoordinates(:, 1), realWorldCoordinates(:, 2), double(pixelValues));
% Create a grid of real-world coordinates
[X, Y] = meshgrid(1:size(cal, 2), 1:size(cal, 1));
[Xl, Yl] = meshgrid(locations(:, 1), locations(:, 2));
% Interpolate pixel values onto the real-world grid
remappedImage = interp2(CalD_rect(:,1), CalD_rect(:,2), double(pixelValues), X, Y);
% Display the remapped image
imshow(remappedImage, []);
But it doesn't work. Any help is appretiated.

Risposte (0)

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by