sgsPy
structurally guided sampling
Loading...
Searching...
No Matches
sgs::strat::FocalWindow

#include <strat.h>

Public Member Functions

 FocalWindow (int wrow, int wcol, int width)
void reset (int row)
bool check (int x, int y)

Public Attributes

int wrow
int wcol
int width
int vpad
int hpad
std::vector< bool > m
std::vector< bool > valid

Detailed Description

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.

Constructor & Destructor Documentation

◆ FocalWindow()

sgs::strat::FocalWindow::FocalWindow ( int wrow,
int wcol,
int width )
inline

Constructor, uses wrow, wcol, and width values to set corrosponding values. Also calculate vertical pad (vpad), horizontal pad (hpad), and resize the m and valid vectors.

Parameters
intwrow
intwcol
intwidth

Member Function Documentation

◆ check()

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
intx
inty
Returns
bool

◆ reset()

void sgs::strat::FocalWindow::reset ( int row)
inline

this function is used to reset the values to fales for a no longer used row, so that it can be used for the next row.

This function is called at the beginning of each scanline/row.

Parameters
introw

Member Data Documentation

◆ hpad

int sgs::strat::FocalWindow::hpad

◆ m

std::vector<bool> sgs::strat::FocalWindow::m

◆ valid

std::vector<bool> sgs::strat::FocalWindow::valid

◆ vpad

int sgs::strat::FocalWindow::vpad

◆ wcol

int sgs::strat::FocalWindow::wcol

◆ width

int sgs::strat::FocalWindow::width

◆ wrow

int sgs::strat::FocalWindow::wrow

The documentation for this struct was generated from the following file: