... | ... | @@ -111,4 +111,203 @@ We consider a pinhole camera model that allows us to transform an object with co |
|
|
```math
|
|
|
i=\frac{a_1 \cdot X+a_2 \cdot Y+a_3 \cdot Z+a_4}{a_9 \cdot X+a_{10} \cdot Y+a_{11} \cdot Z+1} \quad j=\frac{a_5 \cdot X+a_6 \cdot Y+a_7 \cdot Z+a_8}{a_9 \cdot X+a_{10} \cdot Y+a_{11} \cdot Z+1}
|
|
|
```
|
|
|
The coefficients $a_i$ have no physical meaning but are combinations of the intrinsic and extrinsic parameters of the capture. The previous system can be written in matrix form:
|
|
|
|
|
|
```math
|
|
|
\begin{aligned}
|
|
|
& {\left[\begin{array}{lllllllllll}
|
|
|
X & Y & Z & 1 & 0 & 0 & 0 & 0 & -i X & -i Y & -i Z \\
|
|
|
0 & 0 & 0 & 0 & X & Y & Z & 1 & -j X & -j Y & -j Z
|
|
|
\end{array}\right]}\cdot\left[\begin{array}{l}
|
|
|
a_1 \\ a_2 \\ a_3 \\ a_4 \\ a_5 \\ a_6 \\ a_7 \\ a_8 \\ a_9 \\ a_{10} \\ a_{11}
|
|
|
\end{array}\right]=\left[\begin{array}{l}
|
|
|
i \\
|
|
|
j
|
|
|
\end{array}\right] \\
|
|
|
&
|
|
|
\end{aligned}
|
|
|
```
|
|
|
It is possible to solve the equation system above if reference points with known coordinates in both the real (X,Y,Z) and image (i,j) frames are available. These points are visible in the images, and their real-world coordinates have been measured in the field.
|
|
|
|
|
|
The equation system above has 11 unknowns (the coefficients $a_i$), and each reference point provides an i and j coordinate. Therefore, a minimum of 6 reference points is required to solve this system (which will then be overdetermined). Given the uncertainties in real coordinate measurements and image coordinate identification, it is recommended to use 20 to 40 reference points. For a number of reference points $N \geq 6$, we define the following matrices:
|
|
|
|
|
|
```math
|
|
|
\begin{aligned}
|
|
|
& T=[2 N \times 11]=\left[\begin{array}{ccccccccccc}
|
|
|
X_1 & Y_1 & Z_1 & 1 & 0 & 0 & 0 & 0 & -i_1 X_1 & -i_1 Y_1 & -i_1 Z_1 \\
|
|
|
X_2 & Y_2 & Z_2 & 1 & 0 & 0 & 0 & 0 & -i_2 X_2 & -i_2 Y_2 & -i_2 Z_2 \\
|
|
|
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\
|
|
|
X_N & Y_N & Z_N & 1 & 0 & 0 & 0 & 0 & -i_N X_N & -i_N Y_N & -i_1 Z_N \\
|
|
|
0 & 0 & 0 & 0 & X_1 & Y_1 & Z_1 & 1 & -j_1 X_1 & -j_1 Y_1 & -j_1 Z_1 \\
|
|
|
0 & 0 & 0 & 0 & X_2 & Y_2 & Z_2 & 1 & -j_2 X_2 & -j_2 Y_2 & -j_2 Z_2 \\
|
|
|
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\
|
|
|
0 & 0 & 0 & 0 & X_N & Y_N & Z_N & 1 & -j_N X_N & -j_N Y_N & -j_1 Z_N
|
|
|
\end{array}\right] \\
|
|
|
& A=[11 \times 1]=\left[\begin{array}{lllllllllll}
|
|
|
a_1 & a_2 & a_3 & a_4 & a_5 & a_6 & a_7 & a_8 & a_9 & a_{10} & a_{11}
|
|
|
\end{array}\right]^T \\
|
|
|
& Z=[2 N \times 1]=\left[\begin{array}{llllllll}
|
|
|
i_1 & i_2 & \ldots & i_N & j_1 & j_2 & \ldots & j_N
|
|
|
\end{array}\right]^T \\
|
|
|
&
|
|
|
\end{aligned}
|
|
|
```
|
|
|
|
|
|
And the pinhole model is written as :
|
|
|
|
|
|
```math
|
|
|
TA = Z`
|
|
|
```
|
|
|
|
|
|
Since the system is overdetermined, the elements of $A$ are calculated using a least squares regression. We seek the solutions for $A$ that minimize the squared error: $| TA - Z |^{2}$, which is equivalent to finding a solution to
|
|
|
|
|
|
```math
|
|
|
\frac{\partial\|T A-Z\|^2}{\partial A}=0 \rightarrow 2 T^T(T A-Z)=0 \rightarrow T^T T A-T^T Z=0
|
|
|
```
|
|
|
|
|
|
We finally get the following solution for matrix $A$:
|
|
|
|
|
|
```math
|
|
|
A = \left( T^{T}T \right)^{- 1}T^{T}Z
|
|
|
```
|
|
|
## :mag: The Pinhole Model and Its Solution: 2D Case
|
|
|
|
|
|
If we aim to represent a 2D scene in the real world, a simplified model can be derived from the complete model. If we assume that the flow we want to measure is a plane, that all reference points belong to the river plane, and that this plane has a coordinate $Z=0$, then the equation system (1) becomes:
|
|
|
|
|
|
```math
|
|
|
i=\frac{a_1 \cdot X+a_2 \cdot Y+a_4}{a_9 \cdot X+a_{10} \cdot Y+1} \quad j=\frac{a_5 \cdot X+a_6 \cdot Y+a_8}{a_9 \cdot X+a_{10} \cdot Y+1}
|
|
|
```
|
|
|
Thus, we have a solution with 8 coefficients $a_i$, and the system can be solved with a minimum of 4 reference points.
|
|
|
|
|
|
## :mag: Creation of Orthoimages
|
|
|
|
|
|
An orthoimage represents a view corrected for perspective effects and scaled to the real-world dimensions for a given plane. In the case of LSPIV analyses, we aim to orthorectify the flow surface plane (thus assuming that our flow is planar).
|
|
|
|
|
|
This plane can be expressed in terms of $X$ and $Y$ such that $Z = b_{1}X + b_{2}Y + b_{3}$. By assuming that the longitudinal and transverse slopes are negligible on the scale of the image or that the real-world coordinate system is expressed relative to the river plane (XY plane parallel to the river plane), we reduce the plane equation to $Z = b_{3}$, where $b_3$ is the free surface height in the real-world frame, $h$.
|
|
|
|
|
|
The equation system (1) is then reduced, in the flow plane, to:
|
|
|
|
|
|
```math
|
|
|
i=\frac{a_1 \cdot X+a_2 \cdot Y+a_3 \cdot h+a_4}{a_9 \cdot X+a_{10} \cdot Y+a_{11} \cdot h+1} \quad j=\frac{a_5 \cdot X+a_6 \cdot Y+a_7 \cdot h+a_8}{a_9 \cdot X+a_{10} \cdot Y+a_{11} \cdot h+1}
|
|
|
```
|
|
|
The coefficients $a_i$ have been calculated as presented in the previous sections.
|
|
|
|
|
|
The method for constructing orthoimages is as follows:
|
|
|
|
|
|
- Define the area to be imaged in the real-world coordinate system, that is, provide the (X,Y) coordinates of the 4 corners of the orthoimage (done in the [Orthorectification](User-Manual/Orthorectification-of-Images#transformation-parameters) menu).
|
|
|
- Sample this area with a given resolution to create a grid, where each node of this grid will be the center of a pixel in the orthorectified image.
|
|
|
- For each grid node, with coordinates $(X_i,Y_i)$, calculate the corresponding coordinates in the source image $(i_i,j_i)$ using equation (2). The coordinates $(i_i,j_i)$ calculated this way are real numbers rather than integers.
|
|
|
- Assign to each pixel centered at $(X_i,Y_i)$ a grayscale intensity corresponding to the pixel $(i_i,j_i)$ in the source image. Since the coordinates $(i_i,j_i)$ are real numbers, interpolation on neighboring pixels is used to determine the grayscale intensity, with cubic convolution:
|
|
|
|
|
|
```math
|
|
|
f\left(i_i, j_i\right)=\sum_{k=-3}^3 \sum_{l=-3}^3\left[f\left(i_{i+k}, j_{i+l}\right) C\left(i_{i+k}-i_i\right) C\left(j_{i+l}-j_i\right)\right]
|
|
|
```
|
|
|
Where $f(i_{i + k},j_{i + l})$ is the intensity of the pixel $(i_{i + k},j_{i + l})$ in the source image, and $C$ takes the form:
|
|
|
|
|
|
```math
|
|
|
C= \left\{\begin{matrix} 1 - 2|s|^{2} + |s|^{3} & si\quad 0 \leq |s| \leq 1 \\ 4 - 8|s| + |s|^{2} - |s|^{3} & si \quad 1 \leq |s| \leq 2 \\ 0 & sinon \end{matrix}\right.
|
|
|
```
|
|
|
|
|
|
Where $`s = k\ or\ l`$
|
|
|
|
|
|
![image113](uploads/4a299f88cf369bbfdbb10b2d8eaadab8/image113.png)
|
|
|
|
|
|
:clap: **Fin approfondissements** :nerd_face:
|
|
|
|
|
|
#
|
|
|
|
|
|
</details>
|
|
|
|
|
|
## Positioning Reference Points
|
|
|
|
|
|
There are three methods for positioning reference points:
|
|
|
|
|
|
![image47](uploads/d43d411ad2f6d4d174bdae70e3c14b44/image47.png)
|
|
|
|
|
|
- The **_Orthorectification 🡪 Orthorectification 🡪 Reference Points 🡪 New_** menu opens the graphical interface for positioning reference points.
|
|
|
- Enter the terrain coordinates (**_Real X_**; **_Real Y_** and **_Real Z_**) of the first point.
|
|
|
- Click on the pixel in the image to locate the Ground Reference Point (GRP); the image coordinates **_I_** and **_J_** will then be populated.
|
|
|
> :thumbsup: You can zoom in for better visibility of a point. You can also delete or reorder reference points, as well as modify, copy, or paste the coordinates of reference points in the input table.
|
|
|
|
|
|
Repeat this operation for all reference points (at least 4 for 2D orthorectification (ideal: 15-25 points); at least 6 for 3D orthorectification (ideal: 20-35 points); see [principles of orthorectification](#approfondissements) for more details).
|
|
|
|
|
|
The **_End Entry_** button finalizes the operation and creates a file in the project directory: **_outputs.dir\\GRP.dat_**.
|
|
|
|
|
|
![image48](uploads/92997e6efe5b40f20fa719fe181c0a81/image48.png)
|
|
|
|
|
|
- The **_Orthorectification 🡪 Orthorectification 🡪 Reference Points 🡪 Import_** menu allows you to load a **_GRP.dat_** file. This file should be a text file with the following format:
|
|
|
- The first line contains only the text "GRP."
|
|
|
- The second line is an integer specifying the number of reference points used.
|
|
|
- The third line contains the data labels: X Y Z i j, where X, Y, Z are the terrain coordinates of the points, and i, j are the coordinates of the points on the image.
|
|
|
- The following lines contain the data.
|
|
|
|
|
|
> :loudspeaker: _**Note!**_
|
|
|
>
|
|
|
> i, j are not the image indices but the Cartesian coordinates on the image. This means that i corresponds to the x-coordinate and j to the y-coordinate on the image, with point (0,0) located at the bottom-left.
|
|
|
>
|
|
|
> It is important to note that reference points should be provided in metric units (this defines the units for further processing).
|
|
|
|
|
|
![image49](uploads/cdfb0776f52b50fd0c4675bc9573aaa6/image49.png)
|
|
|
|
|
|
- The **_Orthorectification_** 🡪 **_Orthorectification_** 🡪 **_Reference Points_** 🡪 **_4-Point Mode…_** menu offers a simplified specification for 2D orthorectification:
|
|
|
- Select 4 reference points in the image in a counter-clockwise order (click on the **_Interactive Input…_** button).
|
|
|
- Enter the 5 distances (in meters) between these points.
|
|
|
The corresponding real-world coordinates (X and Y) are automatically calculated in an arbitrary reference system. The water level is assumed to be zero.
|
|
|
|
|
|
![image50](uploads/0a18d569cab9ea0986632abdb18a60bd/image50.png)
|
|
|
|
|
|
## Verification of GRPs
|
|
|
|
|
|
The **_Orthorectification 🡪 Orthorectification 🡪 Verify Reference Points_** menu allows you to check the quality of the match between terrain and image coordinates of the GRPs. The orthorectification matrix (see [Principles of Orthorectification](#approfondissements)) is calculated, and the terrain position (X; Y; Z) of the reference points is determined from their image coordinates (I and J).
|
|
|
Then, the real terrain coordinates are compared with the calculated terrain coordinates. The distance between these real and calculated coordinates, called **_Offsets_**, is shown in a table and as a graph.
|
|
|
|
|
|
![image51](uploads/53e406f79b41496b15bd433cfcaf2cfb/image51.png)
|
|
|
|
|
|
> :loudspeaker: _**Note!**_
|
|
|
>
|
|
|
> It’s essential to check the GRPs to avoid data entry errors. Position offsets should not exceed 1% of the studied area (10-20 cm for a river of about 20 m).
|
|
|
>
|
|
|
> Sometimes only specific points show large offsets, which can result from incorrect marking on the image. Check that the image coordinates are correct; if not, adjust them. In some cases, removing the point can yield better results.
|
|
|
|
|
|
## Transformation Parameters
|
|
|
|
|
|
There are two ways to set the transformation parameters:
|
|
|
|
|
|
![image52](uploads/a0e50824b173a25ff7626c137b342b26/image52.png)
|
|
|
|
|
|
The **_Orthorectification 🡪 Orthorectification 🡪 Transformation Parameters 🡪 Define_** menu opens the **_Transformation Parameters_** management window.
|
|
|
- Define the study area with a rectangle, specifying the corner positions in the real-world coordinates (**_Xmin, Xmax, Ymin, Ymax_**). This frame limits orthorectification to the area of interest, thus reducing computation time.
|
|
|
- **_Resolution_**, in meters per pixel, represents the size of one pixel in the orthorectified image. Adjust the resolution to keep tracer details visible in the orthoimage without producing excessively large orthoimages (the orthoimage should be about the same size as the raw image). The button ![image53](uploads/67c708dadea4320b35173c0f5155cc72/image53.png) automatically fills in the fields **_Xmin, Xmax, Ymin, Ymax, and Resolution._**
|
|
|
- Finally, specify the **_Water Level_** in real-world coordinates. The orthoimage will only be valid at this level (see [the principles of orthoimage creation](#cr%C3%A9ation-des-orthoimages)).
|
|
|
|
|
|
Clicking **_Apply_** produces an orthorectified image. Adjust the parameters as needed, then **_Validate._** Transformation parameters are stored in the file **_outputs.dir\\img_ref.dat_**.
|
|
|
|
|
|
![image54](uploads/8fbf30d89cf8dc84ee5e03b724e047d5/image54.png)
|
|
|
|
|
|
- The **_Orthorectification 🡪 Orthorectification 🡪 Transformation Parameters 🡪 Import_** menu allows you to load the orthorectification parameters of an existing study via a **_img_ref.dat_** file. This file has the following format:
|
|
|
|
|
|
![image55](uploads/68ba01b3a000298f89d6ecb92f0ab0a2/image55.png)
|
|
|
|
|
|
# :gear: Transforming All Images
|
|
|
|
|
|
The **_Orthorectification 🡪 Transform Images_** menu starts orthorectification for all selected images. The orthorectified images are stored in the **_img_transf_** folder.
|
|
|
|
|
|
> The cache folder contains the same images in a smaller GIF format.
|
|
|
>
|
|
|
> Creating these images may take time, especially for a large number of high-resolution images. Optionally, you can disable cache image creation for all but the first image in the series via **_Edit 🡪 Preferences 🡪 General 🡪 Calculation._** Only the first image will then be viewable in the 2D Views **_Real Space_** and **_Transformed Image Space_**.
|
|
|
|
|
|
![image56](uploads/2fae64e4a31306a657ab5660b45bb6c3/image56.png)
|
|
|
|
|
|
# :chains: Downsampling Transformed Images
|
|
|
|
|
|
The **_Orthorectification 🡪 Downsample Transformed Images_** menu allows you to downsample the created orthorectified images.
|
|
|
This downsampling does not delete the calculated intermediate images. In case of a change in downsampling, it is not necessary to repeat the video sampling, stabilization, and orthorectification steps.
|
|
|
|
|
|
![image57](uploads/efc0f74a1f1a7c3fbec472ef27dfb506/image57.png)
|
|
|
|
|
|
> :thumbsup: This option is especially useful for identifying the optimal video sampling without re-running previous steps.
|
|
|
>
|
|
|
> :warning: As a reminder, the video sampling must ensure **sufficient pixel movement** to reduce the impact of resolution error on displacement measurement. **Movements over 3 pixels are recommended (ideally around 10 pixels).**
|
|
|
|
|
|
#
|
|
|
-> [**Next Section: 6. Calculating Tracer Displacement Velocity**](Manuel-utilisateur/Calcul-de-la-vitesse-de-déplacement-des-traceurs) |
|
|
\ No newline at end of file |