RSGISLib Image Change Detection

Image Pixel Change Detection

rsgislib.changedetect.pxloutlierchng.find_class_pyod_outliers(pyod_obj, input_img, in_msk_img, output_img, out_scores_img=None, img_mask_val=1, img_bands=None, gdalformat='KEA')

This function uses the pyod (https://github.com/yzhao062/pyod) library to find outliers within a class. It is assumed that the input images are from a different date than the mask (classification) and therefore the outliers will related to class changes.

Parameters
  • pyod_obj – an instance of a pyod.models (e.g., pyod.models.knn.KNN) pass parameters to the constructor

  • input_img – input image used for analysis

  • in_msk_img – input image mask use to define the region of interest.

  • output_img – output image with pixel over of 1 for within mask but not outlier and 2 for in mask and outlier.

  • out_scores_img – output image (optional, None and won’t be provided; Default None) providing the probability of each pixel being an outlier

  • img_mask_val – the pixel value within the mask image for the class of interest. (Default 1)

  • img_bands – the image bands to be used for the analysis. If None then all used (Default: None)

  • gdalformat – file format for the output image(s). Default KEA.

rsgislib.changedetect.pxloutlierchng.find_class_kurt_skew_outliers(input_img: str, in_msk_img: str, output_img: str, vld_min: float, vld_max: float, init_thres: float, low_thres: bool, contamination: float = 10.0, only_kurtosis: bool = False, img_mask_val: int = 1, img_band: int = 1, img_val_no_data: Optional[float] = None, gdalformat: str = 'KEA', plot_thres_file: Optional[str] = None) float

This function to find outliers within a class using an optimisation of the skewness and kurtosis. It is assumed that the input_img is from a different date than the mask (classification) and therefore the outliers will related to class changes. The skewness and kurtosis method assume that without change image values will be normally distributed.

Parameters
  • input_img – the input image for the analysis. Just a single band will be used.

  • in_msk_img – input image mask use to define the region (class) of interest.

  • output_img – output image with pixel over of 1 for within mask but not outlier and 2 for in mask and outlier.

  • vld_min – the minimum threshold for valid image values.

  • vld_max – the maximum threshold for valid image values.

  • init_thres – an initial estimate of the change threshold

  • low_thres – a boolean as to whether the threshold is on the upper or lower side of the histogram. If True (default) then outliers will be identified as values below the threshold. If False then outliers will be above the threshold.

  • contamination – An estimate of the amount of contamination (i.e., outliners) which is within the scene.

  • only_kurtosis

    A boolean to specify that only the kurtosis should be used

    to estimate the threshold. Default: False (i.e., both the

    kurtosis and skewness are used.

  • img_mask_val – the pixel value within the in_msk_img specifying the class of interest.

  • img_band – the input_img image band to be used for the analysis.

  • img_val_no_data – the input_img image not data value. If None then the value will be read from the image header.

  • gdalformat – the output image file format. (Default: KEA)

  • plot_thres_file – A file path for a plot of the histogram with the threshold. If None then ignored.

Returns

The threshold identified.

rsgislib.changedetect.pxloutlierchng.find_class_otsu_outliers(input_img: str, in_msk_img: str, output_img: str, low_thres: bool, img_mask_val: int = 1, img_band: int = 1, img_val_no_data: Optional[float] = None, gdalformat: str = 'KEA', plot_thres_file: Optional[str] = None) float

This function to find outliers within a class using an otsu thresholding. It is assumed that the input_img is from a different date than the mask (classification) and therefore the outliers will related to class changes.

Parameters
  • input_img – the input image for the analysis. Just a single band will be used.

  • in_msk_img – input image mask use to define the region (class) of interest.

  • output_img – output image with pixel over of 1 for within mask but not outlier and 2 for in mask and outlier.

  • low_thres – a boolean as to whether the threshold is on the upper or lower side of the histogram. If True (default) then outliers will be identified as values below the threshold. If False then outliers will be above the threshold.

  • img_mask_val – the pixel value within the in_msk_img specifying the class of interest.

  • img_band – the input_img image band to be used for the analysis.

  • img_val_no_data – the input_img image not data value. If None then the value will be read from the image header.

  • gdalformat – the output image file format. (Default: KEA)

  • plot_thres_file – A file path for a plot of the histogram with the threshold. If None then ignored.

Returns

The threshold identified.

rsgislib.changedetect.pxloutlierchng.find_class_li_outliers(input_img: str, in_msk_img: str, output_img: str, low_thres: bool, tolerance: Optional[float] = None, init_thres: Optional[float] = None, img_mask_val: int = 1, img_band: int = 1, img_val_no_data: Optional[float] = None, gdalformat: str = 'KEA', plot_thres_file: Optional[str] = None) float

This function to find outliers within a class using Li’s iterative Minimum Cross Entropy method. It is assumed that the input_img is from a different date than the mask (classification) and therefore the outliers will related to class changes.

Parameters
  • input_img – the input image for the analysis. Just a single band will be used.

  • in_msk_img – input image mask use to define the region (class) of interest.

  • output_img – output image with pixel over of 1 for within mask but not outlier and 2 for in mask and outlier.

  • low_thres – a boolean as to whether the threshold is on the upper or lower side of the histogram. If True (default) then outliers will be identified as values below the threshold. If False then outliers will be above the threshold.

  • tolerance – float (optional) - Finish the computation when the change in the threshold in an iteration is less than this value. By default, this is half the smallest difference between data values.

  • init_thres – an initial estimate of the change threshold

  • img_mask_val – the pixel value within the in_msk_img specifying the class of interest.

  • img_band – the input_img image band to be used for the analysis.

  • img_val_no_data – the input_img image not data value. If None then the value will be read from the image header.

  • gdalformat – the output image file format. (Default: KEA)

  • plot_thres_file – A file path for a plot of the histogram with the threshold. If None then ignored.

Returns

The threshold identified.