[R-sig-Geo] Image Template Matching
Andrew Niccolai
andrew.niccolai at yale.edu
Sat Oct 6 14:40:48 CEST 2007
Hello spatial R community,
Can anyone help me to convert the following algorithm to R code that will
allow me to take a subset of an image and then produce an image that
"targets" the areas of the original larger image that are highly correlated
with the template image?
Any help would be enormously appreciated.
Thanks in advance
TEMPLATE MATCHING ALGORITHM:
Read in two images, template and target
min_correlation = -1;
for x = 0 to target.width-template.width{
for y = 0 to target.height-template.height{
correlation = correlate(template, target, x, y)
if (min_correlation <0 or correlation < min_correlation){
min_correlation = correlation
min_x = x
min_y = y
}
}
}
for x = 0 to template.width{
for y = 0 to template.height{
target(min_x + x, min_y + y) = some distinctive colour
}
. }
write the modified target image to a new file.
Andrew Niccolai
Doctoral Candidate
Yale School of Forestry
More information about the R-sig-Geo
mailing list