eumap.gapfiller.InPainting¶
- class InPainting(fn_files=None, data=None, space_win=10, data_mask=None, mode=1, outlier_remover=None, std_win=3, std_env=2, perc_env=[2, 98], n_jobs_io=4, verbose=True)[source]¶
Bases:
eumap.gapfiller.ImageGapfill
Approach that uses a inpating technique [1] to gapfill raster data using neighborhood values.
- Parameters
fn_files (
Optional
[List
]) – Raster file paths to be read and gapfilled.data (
Optional
[array
]) – 3D array where the last dimension is the time.space_win – Radius of a circular neighborhood of each point inpainted that is considered by the algorithm.
data_mask – 2D array indicating a valid areas, equal 1, where in case of gaps should be filled.
mode – Inpainting method that could be cv::INPAINT_NS or cv::INPAINT_TELEA [1]
outlier_remover (
Optional
[OutlierRemover
]) – Strategy to remove outliers.std_win (
int
) – Temporal window size used to calculate a local median and std.std_env (
int
) – Number of std used to define a local envelope around the median. Values outside of this envelope are removed.perc_env (
list
) – A list containing the lower and upper percentiles used to defined a global envelope for the time series. Values outside of this envelope are removed.n_jobs_io – Number of parallel jobs to read/write raster files.
verbose – Use
True
to print the progress of the gapfilled.
References
[1] OpenCV Tutorial - Image Inpainting
Examples
>>> from eumap import gapfiller >>> >>> # Considerer land_mask as 2D numpy array where 1 indicates land >>> inPainting = gapfiller.InPainting(fn_files=fn_rasters, space_win = 10, data_mask=land_mask) >>> data_inp = inPainting.run() >>> >>> fn_rasters_inp = inPainting.save_rasters('./gapfilled_inp')
Methods
Execute the gapfilling approach.
Save the result in raster files maintaining the same filenames of the read rasters.
- run()¶
Execute the gapfilling approach.
- save_rasters(out_dir, dtype=None, out_mantain_subdirs=True, root_dir_name='eumap_data', fn_files=None, nodata=None, spatial_win=None, save_flag=True)¶
Save the result in raster files maintaining the same filenames of the read rasters.
- Parameters
out_dir – Folder path to save the files.
dtype (
Optional
[str
]) – Convert the rasters for the specified Numpydtype
before save. This argument overwrite the values retrieved offn_files
out_mantain_subdirs (
bool
) – Keep the full folder hierarchy of the read raster in theout_dir
.root_dir_name (
str
) – Keep the relative folder hierarchy of the read raster in theout_dir
considering of the sub folders ofroot_dir_name
.fn_files (
Optional
[List
]) – Raster file paths to retrieve the filenames and folders. Use this parameter in situations where thedata
parameter is informed in the class constructor. The pixel size, crs, extent, image size and nodata for the gapfilled rasters are retrieved from the first valid raster offn_files
nodata –
Nodata
value used for the the gapfilled rasters. This argument overwrite the values retrieved offn_files
. This argument doesn’t affect the flag rasters (gapfill summary), which havenodata=0
.spatial_win (
Optional
[Window
]) – Save the gapfilled rasters considering the specified spatial window.save_flag – Save the flag rasters (gapfill summary).