Learn R Programming

screenshot (version 0.9.2)

locate_ndl_in_hay: Locate needle image matrix position in a haystack_image matrix. Helper function for locate_image().

Description

Locate needle image matrix position in a haystack_image matrix. Helper function for locate_image().

Usage

locate_ndl_in_hay(ndl_mt, hay_mt, exact = TRUE, timeout = 5)

Value

    A numeric pair of xy location for needle image.

Arguments

ndl_mt, hay_mt

A matrix

exact

A logical. Check matching exactly or not.

timeout

A numeric for timeout seconds.

Examples

Run this code
haystack_image <- imager::load.example("parrots")
w <- 100
h <- 50
needle_image <- crop_image(haystack_image, 129, 257, w, h)
hay_mt <- image2gray_matrix(haystack_image)
ndl_mt <- image2gray_matrix(needle_image)
(pos <- locate_ndl_in_hay(ndl_mt, hay_mt))

found <- crop_image(haystack_image, pos[1], pos[2], w, h)
layout(c(1:3))
plot(haystack_image)
plot(needle_image)
plot(found)

Run the code above in your browser using DataLab