hypso.rgb.registration#
Registering HYPSO-2’s RGB camera image to the HSI capture (TODO 4e).
The camera image has no georeferencing. Registration is never run when an
image is read (hypso.rgb.read_camera_image() only reads and demosaics);
call register_camera() explicitly. It registers the image to the HSI
capture’s own geolocation:
the HSI product (georeferenced L1B or L1C, three bands near red, green and blue) is regridded onto a UTM map - a true map plane, unlike the pushbroom swath;
SIFT keypoints are matched between that map and the (downsampled) camera image (scikit-image; ratio test and cross-check);
RANSAC fits a homography from camera pixels to map coordinates - for a frame camera looking at nearly flat ground, the right model;
the fit is checked: enough inliers, spread over enough of the camera image (a fit anchored in one corner is unreliable elsewhere), and a small enough residual. A capture that fails is left unregistered, with the reason.
On three test captures (Ariake, Venice, Annapolis) this gave residuals of about 190-220 m on a 150 m map, well below the HSI’s 876 x 108 m pixels, in about 40 s each (REFACTOR_PROGRESS.md ×83).
Examples
>>> from hypso.rgb import find_camera_image, read_camera_image
>>> camera = read_camera_image(find_camera_image(capture_dir))
>>> reg = register_camera(camera, l1c)
>>> geo = georeference_camera(camera, reg, l1c) # per-pixel latitude/longitude
Classes#
Result of |
Functions#
|
Latitude and longitude (degrees, float32) of every camera pixel centre, |
|
For every camera pixel, the nearest HSI pixel |
|
The camera image in its own frame with per-pixel geolocation. |
|
For every HSI pixel, the fractional camera |
|
Register a camera image to an HSI capture. |
Module Contents#
- class hypso.rgb.registration.CameraRegistration[source]#
Result of
register_camera().
- hypso.rgb.registration.camera_lonlat(registration, shape)[source]#
Latitude and longitude (degrees, float32) of every camera pixel centre,
(rows, cols)arrays for an image ofshape.- Parameters:
registration (CameraRegistration)
- Return type:
- hypso.rgb.registration.camera_to_hsi_pixels(registration, hsi, shape, max_distance_m=None)[source]#
For every camera pixel, the nearest HSI pixel
(line, sample)(-1 where it is farther thanmax_distance_m, default the HSI’s resolution, i.e. outside the swath). Arrays of the camera’sshape.- Parameters:
registration (CameraRegistration)
max_distance_m (float)
- Return type:
- hypso.rgb.registration.georeference_camera(camera, registration, hsi=None)[source]#
The camera image in its own frame with per-pixel geolocation.
- Parameters:
camera (xarray.DataArray) –
(y, x, channel)image (hypso.rgb.read_camera_image()).registration (CameraRegistration) – From
register_camera(); must beok.hsi (hypso.Product, optional) – The HSI product, to flag camera pixels outside its swath (their geolocation is extrapolated from the fit).
- Returns:
R,G,B(y, x),latitude,longitude, optionallyin_hsi_swath, and the registration in the attributes; writable withto_netcdf.- Return type:
- hypso.rgb.registration.hsi_to_camera_pixels(registration, hsi, shape)[source]#
For every HSI pixel, the fractional camera
(row, col)it falls on (via the inverse homography; exact for the model), NaN outside the camera image ofshape. Arrays of the HSI’s spatial shape.- Parameters:
registration (CameraRegistration)
- Return type:
- hypso.rgb.registration.register_camera(camera, hsi, resolution=150.0, downsample=0.25, min_inliers=30, min_coverage=0.25, max_rms_m=500.0, ratio=0.8, ransac_threshold_px=3.0, seed=0)[source]#
Register a camera image to an HSI capture.
- Parameters:
camera (xarray.DataArray) –
(y, x, channel)image fromhypso.rgb.read_camera_image()(demosaiced, rotated as the ground processing does).hsi (hypso.Product) – The capture’s georeferenced L1B or L1C product (needs geolocation).
resolution (float, default 150) – Pixel size (m) of the UTM map the camera is matched against.
downsample (float, default 0.25) – Scale of the camera image used for matching.
min_inliers (int) – Quality check: at least this many RANSAC inliers, covering at least this fraction of the camera image (convex hull), with at most this residual RMS (m).
min_coverage (float) – Quality check: at least this many RANSAC inliers, covering at least this fraction of the camera image (convex hull), with at most this residual RMS (m).
max_rms_m (float) – Quality check: at least this many RANSAC inliers, covering at least this fraction of the camera image (convex hull), with at most this residual RMS (m).
ratio (float, default 0.8) – Lowe’s ratio test for descriptor matching.
ransac_threshold_px (float, default 3) – RANSAC inlier threshold, in map pixels.
seed (int, default 0) – RANSAC random seed (reproducible results).
- Return type: