Handlers¶
This module provides a class for handling file operations related to segmentation data.
It includes functionalities for saving and loading segmentation data in HDF files, verifying the integrity of HDF and video files, and checking the validity of analysis files.
| CLASS | DESCRIPTION |
|---|---|
FileHandler |
A class for handling file operations related to segmentation data and metadata. |
FileHandler
¶
A class for handling file operations related to segmentation data and metadata.
This class provides methods for saving and loading segmentation data in HDF files, verifying the integrity of HDF and video files, and checking analysis files.
| METHOD | DESCRIPTION |
|---|---|
save_hdf_file |
Saves segmentation data and metadata to an HDF file. |
load_hdf_file |
Loads segmentation data and metadata from an HDF file. |
verify_hdf_file |
Verifies the integrity of an HDF file. |
verify_video_file |
Verifies the integrity of a video file. |
verify_analysis_files |
Verifies the analysis files for counts and percentages. |
save_hdf_file
¶
Saves segmentation data and metadata to an HDF file.
| PARAMETER | DESCRIPTION |
|---|---|
file_path |
Path to the HDF file.
TYPE:
|
segmentation_data |
Segmentation data to be saved.
TYPE:
|
metadata |
Metadata associated with the segmentation data.
TYPE:
|
Source code in cityseg/file_handler.py
load_hdf_file
¶
Loads segmentation data and metadata from an HDF file.
| PARAMETER | DESCRIPTION |
|---|---|
file_path |
Path to the HDF file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tuple[File, Dict[str, Any]]
|
Tuple[h5py.File, Dict[str, Any]]: Loaded HDF file and metadata. |
Source code in cityseg/file_handler.py
verify_hdf_file
¶
Verifies the integrity of an HDF file.
| PARAMETER | DESCRIPTION |
|---|---|
file_path |
Path to the HDF file.
TYPE:
|
config |
Configuration object for comparison.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the HDF file is valid and up-to-date, False otherwise.
TYPE:
|
Source code in cityseg/file_handler.py
verify_video_file
¶
Verifies the integrity of a video file.
| PARAMETER | DESCRIPTION |
|---|---|
file_path |
Path to the video file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the video file is valid and up-to-date, False otherwise.
TYPE:
|
Source code in cityseg/file_handler.py
verify_analysis_files
¶
Verifies the analysis files for counts and percentages.
| PARAMETER | DESCRIPTION |
|---|---|
counts_file |
Path to the counts file.
TYPE:
|
percentages_file |
Path to the percentages file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the analysis files are valid, False otherwise.
TYPE:
|
Source code in cityseg/file_handler.py
cityseg.visualization_handler
¶
This module provides a class for visualizing segmentation results using color palettes.
It includes methods to visualize segmentation maps with color palettes and options for displaying colored or blended results.
| CLASS | DESCRIPTION |
|---|---|
VisualizationHandler |
A class for visualizing segmentation results using color palettes. |
VisualizationHandler
¶
A class for visualizing segmentation results using color palettes.
This class provides methods to visualize segmentation maps with color palettes and options for displaying colored or blended results.
| METHOD | DESCRIPTION |
|---|---|
visualize_segmentation |
Visualizes segmentation results with color palettes. |
_generate_palette |
Generates a color palette for visualization. |
visualize_segmentation
¶
Visualizes segmentation results using color palettes.
This method takes input images and their corresponding segmentation maps, applies the specified color palette, and returns the visualized results.
| PARAMETER | DESCRIPTION |
|---|---|
images |
Input images or a list of images.
TYPE:
|
seg_maps |
Segmentation maps or a list of maps.
TYPE:
|
palette |
Color palette for visualization. If None, a default palette is generated.
TYPE:
|
colored_only |
Flag to indicate if only colored results are desired (True) or blended with the original images (False).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Union[ndarray, List[ndarray]]
|
Union[np.ndarray, List[np.ndarray]]: Visualized segmentation results, either as a single array or a list of arrays. |