pixel_rule | R Documentation |
Creates an object of class pixel_rule
from a line in rgb
space,
defined by the user, and a relational operator.
pixel_rule(rule_name, x_axis, y_axis, line_points, comp_op)
is.rule(x)
## S3 method for class 'pixel_rule'
summary(object, ...)
rule_name |
a character string containing the name of the rule. |
x_axis |
a character string selecting the colour variable used as x
axis, one of |
y_axis |
a character string selecting the colour variable used as y
axis, one of |
line_points |
either an object of of class |
comp_op |
a character string containing one of the comparison operators
|
x |
the R object being tested |
object |
an object of class |
... |
additional parameters to pass to the function. |
This function estimates the slope (a
) and intercept
(c
) of the line y = ax + c
from the coordinates of two points
on the line. x
and y
are two colour variables selected by the
user (r
, g
, or b
). The line divides the plane in two
subsets and the comparison operator selects the subset that contains the
points (pixels) of interest.
When the line is defined by a list containing a couple of points, it is
first converted into an object of class "pixel_rule_points"
(see
place_rule
, and the examples below).
The lines are mathematical objects that extend without bound, i.e. all along the x axis. The pair of points do not set the line limits, they only allow the estimation of the line parameters. Therefore, they are not constrained to be inside the triangular area occupied by the pixels, and the points can be selected in the most convenient way, provided that the line divides correctly the categories. Convenience in this context means that the line should seem nice in the plot, if this matters.
Because the variables were transformed into proportions, the pixels in the
plot are always inside the triangle defined by the points (0, 0), (1,
0), (0, 1)
. So, the sides of this triangle can be considered as implicit
rules which do not need to be created explicitly. In this way, a single
line creates two polygons by cutting the triangle in two. Usually, the
implicit rules reduce the number of rules to create.
An object of class "pixel_rule"
containing these elements:
rule_name
: a character string containing the rule name.
rule_text
: a character string containing the mathematical
expression of the rule.
comp_op
: a character string containing the comparison operator
used in the rule.
a
: a numerical vector containing the parameter a
(slope) of the line.
c
: a numerical vector containing the parameter c
(intercept) of the line.
x_axis
: a character string containing the colour variable
selected as x
axis (one of "r", "g" or "b").
y_axis
: a character string containing the colour variable
selected as y
axis.
first_point
: a numerical vector containing the coordinates of
the first point used to estimate the line equation.
second_point
: a numerical vector containing the coordinates of
the second point.
pixel_subcategory
, pixel_category
,
plot_rule
, plot_rgb_plane
# Creating the line by passing the coordinates of two points on the line:
rule01 <- pixel_rule("rule01", "g", "b",
list(c(0.35, 0.30), c(0.45, 0.10)),">")
# A vertical line as a rule; note that the equation will be simplified
rule02 <- pixel_rule("rule02", "g", "b",
list(c(0.35, 0.30), c(0.35, 0.00)), ">")
## Not run:
# Creating the rule by passing an object of type rule_point:
rule_points01 <- place_rule("g", "b")
rule03 <- pixel_rule("rule03", "g", "b", rule_points01,">")
# Note that the creation of the intermediate object can be avoided:
rule04 <- pixel_rule("rule04", "g", "b", place_rule("g", "b"),">")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.