The focal window is a method used by Queinnec sampling to ensure that pixels which are surrounded by other pixels of the same strata are prioritized over pixels which aren't.
This struct is used to control the storage of values to keep track of which pixels are eligible as 'queinnec' values i.e. surrounded by pixels of the same strata.
the m vector is a vector of bool which keeps track whether a particular pixels is eligible considering it's horizontal pixels. The values are initialized to false, and when iterating through the raster, the m vector is set if it is horizontally surrounded by the same pixels. These saved values will then be used later to determine if a whole pixel is eligible. The logic is used that if all vertical values within the horizontal range of the focal window are the same, AND this stored horizontal value is true for all of the pixels, then the pixel in the middle must be surrounded by whole pixels of the same type.
the valid vector is a vector of bool which keeps track whether a particular pixel is available for sampling. Specifically, it isn't nan, is accessible, and isn't an existing sample. The reason why this data needs to be saved, rather than used for the current pixel, is that in order to check the vertical focal window we must have iterated past a particular pixel before we know whether it is fully eligible. Rather than checking if it is available for sampling twice, the second time for the focal window's purpose, this value is saved in the valid vector.
Both the m and the valid vectors have the same width of the raster, but significantly less height. They only need to have the height of the focal window, and when an old row becomes unused it is reset to false and used for another row in the raster.
| bool sgs::strat::FocalWindow::check |
( |
int | x, |
|
|
int | y ) |
|
inline |
This function checks whether a particular index is eligible to be added as a queinnec pixel, i.e. is surrounded by pixels of the same strata.
Both the m and the valid vectors are checked in this function, although both the m and valid vectors are set outside of the functions of this struct. They are set directly during the iteration through the raster.
This function only checks whether the pixel is valid (not nan, accessible, not part of an existing sampling network), and whether all of the pixels vertically within the focal window are horizontally surrounded by the same values. If this function returns true, those vertical pixels will then be checked to ensure they are equivalent.
- Parameters
-
- Returns
- bool