Statistical Figures
compare_before_after_all_images(input_images_1, input_images_2, output_figure_path, title, ylabel_1, ylabel_2, image_names=None)
¶
Creates a two-row image grid to compare before-and-after raster pairs with consistent per-row contrast stretching. Each column shows a pair of aligned images with transparent nodata. Supports 1- and 3-band rasters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_images_1
|
list
|
List of file paths to the "before" images (top row). |
required |
input_images_2
|
list
|
List of file paths to the "after" images (bottom row). |
required |
output_figure_path
|
str
|
Destination path to save the output PNG figure. |
required |
title
|
str
|
Title of the entire figure. |
required |
ylabel_1
|
str
|
Y-axis label for the top row. |
required |
ylabel_2
|
str
|
Y-axis label for the bottom row. |
required |
image_names
|
list
|
List of image names to use as column titles. Must match the number of image pairs. |
None
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
If input lists have mismatched lengths or if |
Output
Saves a PNG file with the comparison figure.
Source code in spectralmatch/statistics.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
compare_image_spectral_profiles_pairs(image_groups_dict, output_figure_path, title, xlabel, ylabel, line_width=1, estimate_stats=True)
¶
Plots paired spectral profiles for before-and-after image comparisons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_groups_dict
|
dict
|
Mapping of labels to image path pairs (before, after): {'Image A': [ '/image/before/a.tif', 'image/after/a.tif' ], 'Image B': [ '/image/before/b.tif', '/image/after/b.tif' ]} |
required |
output_figure_path
|
str
|
Path to save the resulting comparison figure. |
required |
title
|
str
|
Title of the plot. |
required |
xlabel
|
str
|
X-axis label. |
required |
ylabel
|
str
|
Y-axis label. |
required |
line_width
|
float
|
Width of the spectral profiles lines. Default is 1. |
1
|
estimate_stats
|
bool
|
Whether to estimate band statistics. Default is True. |
True
|
Outputs
Saves a spectral comparison plot showing pre- and post-processing profiles.
Source code in spectralmatch/statistics.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
compare_spatial_spectral_difference_band_average(input_images, output_figure_path, title, diff_label, subtitle, scale=None, *, resampling_method='bilinear')
¶
Reprojects the after image onto the before image's geographic grid and plots the signed mean spectral difference (after minus before) across matching bands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_images
|
list
|
Two georeferenced raster paths [before, after] with matching band counts; dimensions, extents, pixel sizes, and CRSs may differ. The before image defines the comparison CRS, extent, and pixel grid; pixels must be valid in both images across all bands to contribute. |
required |
output_figure_path
|
str
|
Path to save the resulting difference image (PNG). |
required |
title
|
str
|
Title for the plot. |
required |
diff_label
|
str
|
Label for the colorbar. |
required |
subtitle
|
str
|
Subtitle text shown below the image. |
required |
scale
|
tuple
|
Tuple (vmin, vmax) to fix the color scale. Centered at 0. |
None
|
resampling_method
|
Literal['nearest', 'bilinear', 'cubic', 'lanczos']
|
Resampling used to project the after image onto the before grid: nearest, bilinear (default), cubic, or lanczos. Areas outside shared valid coverage remain transparent. |
'bilinear'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input count or resampling method is invalid, band counts differ, georeferencing is missing, or the images have no shared valid pixels. |
Source code in spectralmatch/statistics.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |