The grec package collaborates with the imagine package to execute
and apply image processing algorithms for identifying oceanic gradients.
imagine furnishes the foundational algorithms, developed efficiently
utilizing C++ tools. Conversely, grec oversees the utilization of these
coding instruments in the context of oceanic gradient recognition and handles
the development of input/output methods. In this context, the available methods
offered by grec are contingent on the installed grec-imagine
versions.
(*) Due to the deprecation of the raster package, grec will not be
supporting the use of RasterLayer
in future versions. Instead,
grec will be incorporating support for
SpatRaster-class, a more recent and actively developed
method for working with raster data. This change will take effect as soon as
raster is removed from CRAN.
Until the current version, grec
performs four methods:
BelkinOReilly2009
(default): Based on Belkin & O'Reilly (2009)
article, it uses a Contextual Median Filter (CMF) for smoothing the original
data before the applying of Sobel filters.
median_filter
: it uses a typical median filter (MF) for
smoothing the original data. It also allows the user to change the window
size for median filter (3 as default).
Agenbag2003-1
: Performs method 1 described on Agenbag et al.
(2003) paper, based on the equation:
$$SST_{grad}=\sqrt{(T_{i+1}-T_{i-1})^2 +(T_{j+1}-T_{j-1})^2}$$
Agenbag2003-2
: Performs method 2 described on Agenbag et al.
(2003) paper, calculating the the standard deviation of the 3x3 neighbor area
for each pixel.
The input data x
can be represented in various formats to accommodate
different data sources. It can be provided as a single numeric matrix
extracted from an environmental map. Alternatively, it can be represented as
a three-dimensional XYZ list
, where X
contains a vector of
longitudes, Y
contains a vector of latitudes, and Z
is a matrix
of dimensions length(x$X)
x length(x$Y)
. Additionally, it can
be specified as an array, SpatRaster
, or RasterLayer
* object.
If x
is an array
, it must have three dimensions: longitude (lon),
latitude (lat), and time. It is not mandatory to define the dimnames. The
output will maintain all the attributes of the input data.
...
allows the (advanced) users to modify some aspects of filter
application. Depending on the selected methodology, some parameters can be
modified:
- times
numeric
. How many times do you want to apply
the filtering method?
- kernelValues
A numeric
vector that will be used for
convolution to detect vertical and horizontal gradients.
- radius
numeric
. If median-filter method was
selected, it allows to change the window size of the filter.
Normalization is a standard practice in convolution to maintain the range of
output values consistent with the input data. This is achieved by dividing
the convolution output by the absolute value of the kernel. While
normalization is recommended to ensure consistent interpretation of results,
it is disabled by default and can be enabled by setting the
ConvolNormalization
parameter to TRUE
.
Finally, Belkin & O'Reilly's work suggests applying a logarithmic
transformation to the gradient output. This step is not enabled by default,
as it is primarily intended for chlorophyll data. Users are free to apply the
transformation manually if it suits their specific needs.