cars_mesh.core.texture
Texturing methods to project radiometric information over surfaces to provide a realistic rendering.
Module Contents
Functions
|
Normalize an image to a 8-bit image by recomputing the color dynamic |
|
Function that executes a user defined function using a tiling process. |
|
Function that transforms a 16-bit tif image into an 8-bit jpg cropped to |
|
Function that computes the UVs coordinates |
|
Function that creates the texture of a mesh. |
- cars_mesh.core.texture.tile_norm(arr: numpy.ndarray, q_percent: tuple | list | numpy.ndarray = None)[source]
Normalize an image to a 8-bit image by recomputing the color dynamic
- Parameters:
arr (np.ndarray) – Image array
q_percent ((2, ) list or tuple or np.ndarray) – Percentage of the respectively minimum and maximum values of the image from which to clip the dynamic
- cars_mesh.core.texture.process_raster_by_tile(rio_infile, rio_outfile, fn_process_tile, col_off=0, row_off=0, tile_size=(1000, 1000), dst_bands=None, **kwargs)[source]
Function that executes a user defined function using a tiling process.
- Parameters:
rio_infile (rasterio.io.DatasetReader) –
rio_outfile (rasterio.io.DatasetWriter) –
fn_process_tile (Function) –
col_off (int) –
row_off (int) –
tile_size (tuple or list or np.ndarray) – (row, col)
dst_bands (list or tuple or np.ndarray or None) – List of bands to handle in input and output file
kwargs –
- cars_mesh.core.texture.preprocess_image_texture(img_path: str, bbox: tuple | list | numpy.ndarray, output_dir: str, tile_size: tuple | list | numpy.ndarray = (1000, 1000))[source]
Function that transforms a 16-bit tif image into an 8-bit jpg cropped to a bbox extent
- Parameters:
img_path (str) – Path to the TIF image to crop and normalize
bbox (list or tuple or np.ndarray) – Bounding box extent for cropping: [top_left_col, top_left_row, bottom_right_col, bottom_right_row]
output_dir (str) – Output directory path
tile_size ((2, ) tuple or list or np.ndarray) – Tile size for the processing applied by tile for memory purpose (row, col)
- cars_mesh.core.texture.generate_uvs(img_pts: tuple | list | numpy.ndarray, triangles: tuple | list | numpy.ndarray, bbox: tuple | list | numpy.ndarray, img_texture_size: tuple | list | numpy.ndarray) numpy.ndarray [source]
Function that computes the UVs coordinates
- Parameters:
img_pts ((N, 2) list or tuple or np.ndarray) – Equivalent image coordinates of ground point cloud data
triangles ((M, 3) list or tuple or np.ndarray) – Mesh triangle indexes. The indexes must correspond to the ‘img_pts’ indexes.
bbox ((4, ) list or tuple or np.ndarray) – List of coordinates for respectively the top left and bottom right corners in image frame and in the order (col, row)
img_texture_size ((2, ) list or tuple or np.ndarray) – Size (col, row) of the image texture
- Returns:
uvs – Normalized coordinates in the image texture of each triangle vertex. Normalization is done according to the image texture size and in [0, 1]
- Return type:
np.ndarray
- cars_mesh.core.texture.texturing(mesh: cars_mesh.tools.handlers.Mesh, cfg: dict) cars_mesh.tools.handlers.Mesh [source]
Function that creates the texture of a mesh.
- Parameters:
mesh (Mesh) – Mesh object
cfg (dict:) –
Configuration dictionary. The algorithm retrieves the following information:
output_dir: Str Output directory to write the new texture image.
rpc_path: Str Path to the xml rpc file.
tif_img_path: Str Path to the TIF image.
utm_code: int UTM code of the point cloud
- Returns:
mesh – Mesh object with texture parameters
- Return type: