| Match {GeneR} | R Documentation |
'Match' returns a vector of the positions of (first) matches of its first argument in its second.
Second must be an element of class segSet (or a numeric matrix with 2 columns) ordered and without overlapping segments (function or.segSet is designed for this purpose).
Match(x, a)
x |
a vector of positions |
a |
an element of class segSet |
a vector of same size a x. Values are indices corresponding to element 'a', 0 when no segment found.
This can be used for a texture, when we know only regions, described by set of segments.
Antoine Lucas
a = matrix(c(1,30,40,50,60,70,80,110),ncol=2,byrow=TRUE)
a = or.segSet(a)
## show a:
a
Match(1:40,a)
## texture sample:
b = matrix(c(15,18, 28,45,
1,10, 15,20, 25,40,
17,23, 35,38,100,105,
110,120),ncol=2,byrow=TRUE)
b = or.segSet(b)
texture = ( Match(1:120,a)>0 ) + ( Match(1:120,b)>0 )*2
## change numbers to colors
texture <- as.factor(texture)
levels(texture) <- c("red","blue","green","yellow")
texture <- as.character(texture)
plot(1:120,rep(1,120),col=as.character(texture))