Match {GeneR}R Documentation

Value Matching

Description

'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).

Usage

Match(x, a)

Arguments

x

a vector of positions

a

an element of class segSet

Value

a vector of same size a x. Values are indices corresponding to element 'a', 0 when no segment found.

Note

This can be used for a texture, when we know only regions, described by set of segments.

Author(s)

Antoine Lucas

Examples

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))




[Package GeneR version 2.24.0 Index]