Camera Coordinate Fitting
Exploring image coordinate manipulation, construction of a 3D world coordinate system, and projection analysis using camera matrices.
Overview
A. Clicking and Indexing Points
We begin by working with an image (tent.jpg
) to understand how MATLAB interprets coordinates. While image coordinates are in (X, Y) format (with X growing left-to-right and Y top-to-bottom), MATLAB matrix access uses (row, column), i.e., (Y, X).
To illustrate this, a pixel at (100, 445) is accessed as tent(445, 100, :)
and modified to pure red (255, 0, 0)
. This confirms the mapping between image coordinates and array indexing.
B. Making a World Coordinate System
A 3D world coordinate system was constructed using 15 manually-clicked blue points on a provided image (from HW03). Each point is assigned a labeled (X, Y, Z) coordinate.
The following resources are included:
world coords.txt
– contains the 3D world coordinates.image coords.txt
– contains corresponding 2D image coordinates from manual clicking.
These coordinates serve as the basis for evaluating camera projections in Part C.
C. Analyzing 3D to 2D Camera Projection
Using the previously created 3D points, we analyze how two camera matrices project them into 2D space.
A visual comparison is created in MATLAB:
- Red points: Ground truth (clicked world coordinates)
- Green points: Camera 1 projections
- Blue points: Camera 2 projections
Coordinate flipping is applied for consistency, following insights from Part A.
Re-projection Errors (RMSE):
- Camera 1: 23.9
- Camera 2: 40.7
Camera 1 outperforms Camera 2 both quantitatively and visually. The green points align more closely with the red ground truth.
Conclusion
This project demonstrates the practical handling of image and world coordinates in MATLAB, proper indexing techniques, and evaluation of camera matrices through RMSE. Camera 1 shows superior accuracy in 3D to 2D point projection.