Description Details Author(s) See Also Examples
If there is a need to recognise edges on a raster image or a bitmap or any kind of a matrix, one can find packages that does only 90 degrees vectorization. Typically the nature of artefact images is linear and can be vectorized in much more efficient way than draw a series of 90 degrees lines. The fasteraster package does recognition of lines using only one pass. It also allows to calculate weight and the mass centers for the recognized zones or polygons.
Use raster2vector to vectorize input matrix. Use rasterZoneAnalyzer to break the input matrix by zones and get their weight and mass center.
Andy Bosyi <andy@bosyi.com>.
Maintainer: Andy Bosyi <andy@bosyi.com>
http://bosyi.com/craft/
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## Not run:
library(fasteraster);
library(datasets);
polygons <- raster2vector(volcano, 120, 200, 20, 1);
image(volcano, col = rev(grey.colors(100)), useRaster = TRUE)
plot(0, type = "l", xlim = c(0, nrow(volcano)), ylim = c(0, ncol(volcano)))
a <- lapply(polygons, function(x) lines(rbind(x, x[1,])))
zones <- rasterZoneAnalyzer(volcano, 120, 200, 20);
a <- text(zones[ , 3], zones[ , 4], labels = zones[ , 2]);
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.