Title: | Quantification of Color Pattern Variation |
---|---|
Description: | Quantification of variation in organismal color patterns as obtained from image data. Patternize defines homology between pattern positions across images either through fixed landmarks or image registration. Pattern identification is performed by categorizing the distribution of colors using RGB thresholds or image segmentation. |
Authors: | Steven Van Belleghem [aut, cre] |
Maintainer: | Steven Van Belleghem <[email protected]> |
License: | GPL-3 |
Version: | 0.0.5 |
Built: | 2024-11-22 05:08:08 UTC |
Source: | https://github.com/stevenvb12/patternize |
Align images using landmarks
alignLan( imageList, landList, IDlist = NULL, adjustCoords = FALSE, resampleFactor = NULL, res = c(300, 300), transformRef = "meanshape", transformType = "tps", maskOutline = NULL, removebg = NULL, removebgColOffset = 0.1, inverse = FALSE, cartoonID = NULL, refImage = NULL, plotTransformed = FALSE, format = "imageJ" )
alignLan( imageList, landList, IDlist = NULL, adjustCoords = FALSE, resampleFactor = NULL, res = c(300, 300), transformRef = "meanshape", transformType = "tps", maskOutline = NULL, removebg = NULL, removebgColOffset = 0.1, inverse = FALSE, cartoonID = NULL, refImage = NULL, plotTransformed = FALSE, format = "imageJ" )
imageList |
List of RasterStack objects. |
landList |
Landmark list as returned by |
IDlist |
List of sample IDs should be specified when masking outline and transformRef is 'meanshape'. |
adjustCoords |
Adjust landmark coordinates in case they are reversed compared to pixel coordinates (default = FALSE). |
resampleFactor |
Integer for downsampling used by |
res |
Resolution vector c(x,y) for output rasters (default = c(300,300)). This should be reduced if the number of pixels in the image is lower than th raster. |
transformRef |
ID or landmark matrix of reference sample for shape to which color patterns will be transformed to. Can be 'meanshape' for transforming to mean shape of Procrustes analysis. |
transformType |
Transformation type as used by |
maskOutline |
When outline is specified, everything outside of the outline will be masked for the color extraction (default = NULL). This can be a list of multiple outlines. |
removebg |
Integer or RGB vector indicating the range of RGB threshold to remove from image (e.g. 100 removes pixels with average RGB > 100; default = NULL). |
removebgColOffset |
Color offset for color background extraction (default = 0.10). |
inverse |
If TRUE, areas withing the outline will be masked. If maskOutline is a list, this should also be a list. |
cartoonID |
ID of the sample for which the cartoon was drawn and will be used for masking (should be set when transformRef = 'meanShape'). |
refImage |
Image (RasterStack) used for target. Use raster::stack('filename'). |
plotTransformed |
Plot transformed image (default = FALSE). |
format |
ImageJ (Fiji) or tps format (default = 'imageJ'). |
List of aligned RasterStack objects.
niftyreg
utilities for automated image registration..Aligns images using niftyreg
utilities for automated image registration..
alignReg( sampleList, target, resampleFactor = NULL, useBlockPercentage = 75, crop = c(0, 0, 0, 0), removebgR = NULL, maskOutline = NULL, plotTransformed = FALSE )
alignReg( sampleList, target, resampleFactor = NULL, useBlockPercentage = 75, crop = c(0, 0, 0, 0), removebgR = NULL, maskOutline = NULL, plotTransformed = FALSE )
sampleList |
List of RasterStack objects. |
target |
Image imported as RasterStack used as target for registration. |
resampleFactor |
Integer for downsampling used by |
useBlockPercentage |
Block percentage as used in |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image. |
removebgR |
Integer indicating the range RGB treshold to remove from image (e.g. 100 removes pixels with average RGB > 100; default = NULL) for registration analysis. This works only to remove a white background. |
maskOutline |
When outline is specified, everything outside of the outline will be masked for the color extraction (default = NULL). |
plotTransformed |
Whether to plot transformed images while processing (default = FALSE). |
List of raster objects.
Calibrate images using ColorChecker.
colorChecker( IDlist, prepath = NULL, extension = NULL, colorCheckerType = "X-Rite", fixedCorners = FALSE, patchSize = 0.6, colorCheckerXY = NULL, fixedModel = NULL, resampleFactor = NULL, adjustCoords = FALSE )
colorChecker( IDlist, prepath = NULL, extension = NULL, colorCheckerType = "X-Rite", fixedCorners = FALSE, patchSize = 0.6, colorCheckerXY = NULL, fixedModel = NULL, resampleFactor = NULL, adjustCoords = FALSE )
IDlist |
List of sample IDs. |
prepath |
Prepath (default = NULL). |
extension |
Extension (default = NULL). |
colorCheckerType |
Type of colorChecker. Options are 'X-Rite ' and 'ColorGauge Micro Analyzer' (default = 'X-Rite '). |
fixedCorners |
Specify whether to set the coordinates of the colorChecker corners for every image (default = FALSE). |
patchSize |
Proportion of ColorChecker patch that will be used for observed RGB values (default = 0.6). |
colorCheckerXY |
Landmark list of colorChecker corners as returned
by |
fixedModel |
Precalculated model to adjust colors. Should be a listof a model for R, G and B (the colorChecker function gives as output such a list obtained from the last image in the analysis). |
resampleFactor |
Integer for downsampling used by |
adjustCoords |
Adjust landmark coordinates in case they are reversed compared to pixel coordinates (default = FALSE). |
Calibrated image(s) ('filename_calibrated.jpg')
Calibrate images using ColorChecker.
colorChecker_customGray( IDlist, prepath = NULL, extension = NULL, colorCheckerType = "X-Rite", fixedCorners = FALSE, patchSize = 0.6, colorCheckerXY = NULL, fixedModel = NULL, resampleFactor = NULL )
colorChecker_customGray( IDlist, prepath = NULL, extension = NULL, colorCheckerType = "X-Rite", fixedCorners = FALSE, patchSize = 0.6, colorCheckerXY = NULL, fixedModel = NULL, resampleFactor = NULL )
IDlist |
List of sample IDs. |
prepath |
Prepath (default = NULL). |
extension |
Extension (default = NULL). |
colorCheckerType |
Type of colorChecker. Options are 'X-Rite ' and 'ColorGauge Micro Analyzer' (default = 'X-Rite '). |
fixedCorners |
Specify whether to set the coordinates of the colorChecker corners for every image (default = FALSE). |
patchSize |
Proportion of ColorChecker patch that will be used for observed RGB values (default = 0.6). |
colorCheckerXY |
Landmark list of colorChecker corners as returned
by |
fixedModel |
Precalculated model to adjust colors. Should be a listof a model for R, G and B (the colorChecker function gives as output such a list obtained from the last image in the analysis). |
resampleFactor |
Integer for downsampling used by |
Calibrated image(s) ('filename_calibrated.jpg')
Calibrate images using (right) half of ColorChecker. Only works for X-Rite.
colorChecker_half( IDlist, prepath = NULL, extension = NULL, colorCheckerType = "X-Rite", fixedCorners = FALSE, patchSize = 0.6, colorCheckerXY = NULL, fixedModel = NULL, resampleFactor = NULL, adjustCoords = FALSE )
colorChecker_half( IDlist, prepath = NULL, extension = NULL, colorCheckerType = "X-Rite", fixedCorners = FALSE, patchSize = 0.6, colorCheckerXY = NULL, fixedModel = NULL, resampleFactor = NULL, adjustCoords = FALSE )
IDlist |
List of sample IDs. |
prepath |
Prepath (default = NULL). |
extension |
Extension (default = NULL). |
colorCheckerType |
Type of colorChecker. Options are 'X-Rite ' and 'ColorGauge Micro Analyzer' (default = 'X-Rite'). |
fixedCorners |
Specify whether to set the coordinates of the colorChecker corners for every image (default = FALSE). |
patchSize |
Proportion of ColorChecker patch that will be used for observed RGB values (default = 0.6). |
colorCheckerXY |
Landmark list of colorChecker corners as returned
by |
fixedModel |
Precalculated model to adjust colors. Should be a listof a model for R, G and B (the colorChecker function gives as output such a list obtained from the last image in the analysis). |
resampleFactor |
Integer for downsampling used by |
adjustCoords |
Adjust landmark coordinates in case they are reversed compared to pixel coordinates (default = FALSE). |
Calibrated image(s) ('filename_calibrated.jpg')
Plot color pattern prediction for specified PCA values
createPhenotype( PCAdata, PCApredict, IDlist, rasterList, colpalette = NULL, plotCartoon = FALSE, refShape = NULL, outline = NULL, lines = NULL, landList = NULL, adjustCoords = FALSE, cartoonID = NULL, normalized = TRUE, crop = c(0, 0, 0, 0), flipRaster = NULL, flipOutline = NULL, imageList = NULL, cartoonOrder = "above", lineOrder = "above", cartoonCol = "gray", cartoonFill = NULL, legendTitle = "Proportion", zlim = NULL )
createPhenotype( PCAdata, PCApredict, IDlist, rasterList, colpalette = NULL, plotCartoon = FALSE, refShape = NULL, outline = NULL, lines = NULL, landList = NULL, adjustCoords = FALSE, cartoonID = NULL, normalized = TRUE, crop = c(0, 0, 0, 0), flipRaster = NULL, flipOutline = NULL, imageList = NULL, cartoonOrder = "above", lineOrder = "above", cartoonCol = "gray", cartoonFill = NULL, legendTitle = "Proportion", zlim = NULL )
PCAdata |
Output of PCA analysis. List item 3 of patPCA. |
PCApredict |
A vector with the PCA values for which to predict the phenotype. This vector only needs to include the values upto the last PCA axis to predict along, other values are set to zero. |
IDlist |
List of sample IDs. |
rasterList |
rasterList used for PCA. |
colpalette |
Vector of colors for color palette (default = c("white","lightblue","blue","green", "yellow","red")) |
plotCartoon |
Whether to plot a cartoon. This cartoon should be drawn on one of the samples used in the analysis. |
refShape |
This can be 'target' in case the reference shape is a single sample (for registration analysis) or 'mean' if the images were transformed to a mean shape (only for meanshape when using landmark transformation) |
outline |
xy coordinates that define outline. |
lines |
list of files with xy coordinates of line objects to be added to cartoon. |
landList |
Landmark landmarkList. |
adjustCoords |
Adjust landmark coordinates. |
cartoonID |
ID of the sample for which the cartoon was drawn. |
normalized |
Set this to true in case the summed rasters are already devided by the sample number. |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image used in landmark or registration analysis. |
flipRaster |
Whether to flip raster along xy axis (in case there is an inconsistency between raster and outline coordinates). |
flipOutline |
Whether to flip plot along x, y or xy axis. |
imageList |
List of images should be given if one wants to flip the outline or adjust landmark coordinates. |
cartoonOrder |
Whether to plot the cartoon outline 'above' or 'under' the pattern raster (default = 'above'). Set to 'under' for filled outlines. |
lineOrder |
Whether to plot the cartoon lines 'above' or 'under' the pattern raster (default = 'above'). |
cartoonCol |
Outline and line color for cartoon (deafault = 'gray'). |
cartoonFill |
Fill color for outline of cartoon (default = NULL). |
legendTitle |
Title of the raster legend (default = 'Proportion'). |
zlim |
zlim values for predicted pattern. |
Create a target image (RasterStack) from a polygon.
createTarget( outline, image, res = 300, colorFill = "black", colorBG = "white", sigma = 10, plot = FALSE )
createTarget( outline, image, res = 300, colorFill = "black", colorBG = "white", sigma = 10, plot = FALSE )
outline |
xy coordinates that define outline. |
image |
Image imported as RasterStack used in the analysis. This is used to extract the extent and dimensions for the raster layers. |
res |
Resolution for RasterStack (default = 300). |
colorFill |
Color for the fill of the polygon (default = 'black'). |
colorBG |
Color for the background (default = 'white'). |
sigma |
Size of sigma for Gaussian blurring (default = 10). |
plot |
Whether to plot the created target image (default = FALSE). |
RasterStack
## Not run: outline_BC0077 <- read.table(paste(system.file("extdata", package = 'patternize'), '/BC0077_outline.txt', sep=''), header = FALSE) data(imageList) target <- createTarget(outline_BC0077, imageList[[1]], plot = TRUE) ## End(Not run)
## Not run: outline_BC0077 <- read.table(paste(system.file("extdata", package = 'patternize'), '/BC0077_outline.txt', sep=''), header = FALSE) data(imageList) target <- createTarget(outline_BC0077, imageList[[1]], plot = TRUE) ## End(Not run)
Raw image, landmark and cartoon data of Heliconius erato hydara wings.
Raw JPG images, landmark and cartoon data.
jpeg image
jpeg image
jpeg image
jpeg image
jpeg image
xy landmark coordinates
xy landmark coordinates
xy landmark coordinates
xy landmark coordinates
xy landmark coordinates
xy outline coordinates
xy vein coordinates
xy vein coordinates
xy vein coordinates
xy vein coordinates
xy vein coordinates
xy vein coordinates
xy vein coordinates
xy vein coordinates
xy vein coordinates
xy vein coordinates
xy vein coordinates
GMM
clustering of image imported as a RasterStack.GMM
clustering of image imported as a RasterStack.
GMMImage(image, k = 5, maskToNA = NULL, kmeansOnAll = FALSE)
GMMImage(image, k = 5, maskToNA = NULL, kmeansOnAll = FALSE)
image |
Image imported as a RasterStack for clustering. |
k |
Integer for number of k clusters (default = 3). |
maskToNA |
Replace the color value used for masking (i.e. 0 or 255) with NA. |
kmeansOnAll |
Whether to perform the kmeans clusters on the combined set of pixels of all images first (default = FALSE). |
List including the clustered RasterSatck
returned as an array and object
of class "GMM
".
List of RasterStacks as returned by makeList
.
imageList
imageList
A list of 5 RasterStack
objects of Heliconius erato hydara dorsal forewings.
## Not run: data(imageList) summary(imageList) ## End(Not run)
## Not run: data(imageList) summary(imageList) ## End(Not run)
kmeans
clustering of image imported as a RasterStack. This function is
used by patLanK
and patRegK
.kmeans
clustering of image imported as a RasterStack. This function is
used by patLanK
and patRegK
.
kImage(image, k = 5, startCenter = NULL, maskToNA = NULL, kmeansOnAll = FALSE)
kImage(image, k = 5, startCenter = NULL, maskToNA = NULL, kmeansOnAll = FALSE)
image |
Image imported as a RasterStack for k-means clustering. |
k |
Integer for number of k-means clusters (default = 3). |
startCenter |
A matrix of cluster centres to start k-means clustering from (default = NULL). |
maskToNA |
Replace the color value used for masking (i.e. 0 or 255) with NA. |
kmeansOnAll |
Whether to perform the kmeans clusters on the combined set of pixels of all images first (default = FALSE). |
List including the k-means clustered RasterSatck
returned as an array and object
of class "kmeans
".
image <- raster::stack(system.file("extdata", "BC0077.jpg", package = "patternize")) out <- kImage(image, 6)
image <- raster::stack(system.file("extdata", "BC0077.jpg", package = "patternize")) out <- kImage(image, 6)
kmeans
clustering of image imported as a RasterStack. This function is
used by patLanK
and patRegK
.kmeans
clustering of image imported as a RasterStack. This function is
used by patLanK
and patRegK
.
kImageHSV( image, k = 5, startCenter = NULL, maskToNA = NULL, kmeansOnAll = FALSE, ignoreHSVvalue = FALSE )
kImageHSV( image, k = 5, startCenter = NULL, maskToNA = NULL, kmeansOnAll = FALSE, ignoreHSVvalue = FALSE )
image |
HSV image imported as a RasterStack for k-means clustering. |
k |
Integer for number of k-means clusters (default = 3). |
startCenter |
A matrix of cluster centres to start k-means clustering from (default = NULL). |
maskToNA |
Replace the color value used for masking (i.e. 0 or 255) with NA. |
kmeansOnAll |
Whether to perform the kmeans clusters on the combined set of pixels of all images first (default = FALSE). |
ignoreHSVvalue |
Whether to ignore the HSV value (~darkness). |
List including the k-means clustered RasterSatck
returned as an array and object
of class "kmeans
".
image <- raster::stack(system.file("extdata", "BC0077.jpg", package = "patternize")) out <- kImage(image, 6)
image <- raster::stack(system.file("extdata", "BC0077.jpg", package = "patternize")) out <- kImage(image, 6)
Morpho
.Build landmark array for Morpho
.
lanArray(sampleList, adjustCoords = FALSE, imageList = NULL, imageIDs = NULL)
lanArray(sampleList, adjustCoords = FALSE, imageList = NULL, imageIDs = NULL)
sampleList |
List of landmark matrices as returned by |
adjustCoords |
Adjust landmark coordinates in case they are reversed compared to pixel coordinates (default = FALSE). |
imageList |
List of RasterStacks as returned by |
imageIDs |
A list of IDs to match landmarks to images if landmarkList and imageList don't have the same length. |
X x Y x n array, where X and Y define the coordinates of the landmark points and n is the sample size.
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) landmarkArray <- lanArray(landmarkList) ## End(Not run)
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) landmarkArray <- lanArray(landmarkList) ## End(Not run)
Array of landmarks as returned by lanArray
and used by
link[Morpho]{procsym}
.
landmarkArray
landmarkArray
An array of landmarks for 5 Heliconius erato hydara dorsal forewings.
## Not run: data(landmarkArray) summary(landmarkArray) ## End(Not run)
## Not run: data(landmarkArray) summary(landmarkArray) ## End(Not run)
List of landmarks as returned by makeList
.
landmarkList
landmarkList
A list of landmarks for 5 Heliconius erato hydara dorsal forewings.
## Not run: data(landmarkList) summary(landmarkList) ## End(Not run)
## Not run: data(landmarkList) summary(landmarkList) ## End(Not run)
Build list of landmarks or RasterStacks from images using filepath and file extension.
makeList( IDlist, type, prepath = NULL, extension = NULL, format = "imageJ", tpsFile = NULL, skipLandmark = NULL )
makeList( IDlist, type, prepath = NULL, extension = NULL, format = "imageJ", tpsFile = NULL, skipLandmark = NULL )
IDlist |
List of sample IDs. |
type |
'landmark' or 'image' depending on what type of list to make. |
prepath |
Prepath (default = NULL). |
extension |
Extension (default = NULL). |
format |
ImageJ (Fiji) or tps format (default = 'imageJ'). |
tpsFile |
Provide filename of tps file ff format is 'tps'. |
skipLandmark |
Vector of rownumbers of landmarks to skip. |
Landmark or RasterStack list.
IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension)
IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension)
Intersects a RasterStack with an outline. Everything outside of the outline will be removed from the raster.
maskOutline( RasterStack, outline, refShape, landList = NULL, adjustCoords = FALSE, cartoonID = NULL, IDlist = NULL, crop = c(0, 0, 0, 0), flipRaster = NULL, flipOutline = NULL, imageList = NULL, maskColor = 0, inverse = FALSE )
maskOutline( RasterStack, outline, refShape, landList = NULL, adjustCoords = FALSE, cartoonID = NULL, IDlist = NULL, crop = c(0, 0, 0, 0), flipRaster = NULL, flipOutline = NULL, imageList = NULL, maskColor = 0, inverse = FALSE )
RasterStack |
RasterStack to be masked. |
outline |
xy coordinates that define outline. |
refShape |
This can be 'target' in case the reference shape is a single sample (for registration analysis) or 'mean' if the images were transformed to a mean shape (only for meanshape when using landmark transformation) |
landList |
Landmark list to be given when type = 'mean'. |
adjustCoords |
Adjust landmark coordinates in case they are reversed compared to pixel coordinates (default = FALSE). |
cartoonID |
ID of the sample for which the cartoon was drawn. Only has to be given when refShape is 'mean'. |
IDlist |
List of sample IDs should be specified when refShape is 'mean'. |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image used in landmark or registration analysis. |
flipRaster |
Whether to flip raster along xy axis (in case there is an inconsistency between raster and outline coordinates). |
flipOutline |
Whether to flip plot along x, y or xy axis. |
imageList |
List of image as obtained from |
maskColor |
Color the masked area gets. Set to 0 for black (default) or 255 for white. |
inverse |
If TRUE, areas withing the outline will be masked. |
## Not run: data(imageList) outline_BC0077 <- read.table(paste(system.file("extdata", package = 'patternize'), '/BC0077_outline.txt', sep=''), header = FALSE) masked <- maskOutline(imageList[[1]], outline_BC0077, refShape = 'target', flipOutline = 'y') ## End(Not run)
## Not run: data(imageList) outline_BC0077 <- read.table(paste(system.file("extdata", package = 'patternize'), '/BC0077_outline.txt', sep=''), header = FALSE) masked <- maskOutline(imageList[[1]], outline_BC0077, refShape = 'target', flipOutline = 'y') ## End(Not run)
This fucntion calculates the area in which the color pattern is expressed in each sample as the relative proportion using the provided outline of the considered trait or structure.
patArea( rList, IDlist, refShape, type, outline = NULL, landList = NULL, adjustCoords = FALSE, cartoonID = NULL, crop = c(0, 0, 0, 0), flipRaster = NULL, flipOutline = NULL, imageList = NULL )
patArea( rList, IDlist, refShape, type, outline = NULL, landList = NULL, adjustCoords = FALSE, cartoonID = NULL, crop = c(0, 0, 0, 0), flipRaster = NULL, flipOutline = NULL, imageList = NULL )
rList |
List of RasterLayers as obtained from the main patternize functions. |
IDlist |
List of sample IDs. |
refShape |
This can be 'target' in case the reference shape is a single sample (for registration analysis) or 'mean' if the images were transformed to a mean shape using landmark transformation. |
type |
Type of rasterlist; 'RGB' or 'k' (result from RGB or k-means analysis, respectively). |
outline |
xy coordinates that define outline. |
landList |
Landmark list as returned by |
adjustCoords |
Adjust landmark coordinates in case they are reversed compared to pixel coordinates (default = FALSE). |
cartoonID |
ID of the sample for which the cartoon was drawn. |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image used in landmark or registration analysis. |
flipRaster |
Whether to flip raster along xy axis (in case there is an inconsistency between raster and outline coordinates). |
flipOutline |
Whether to flip plot along x, y or xy axis. |
imageList |
List of images as obtained from |
Table or list of tables with sample IDs and relative area of color pattern or kmeans cluster.
data(rasterList_lanRGB) #data(rasterList_regRGB) #data(rasterList_lanK) #data(rasterList_regK) data(imageList) IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') outline_BC0077 <- read.table(paste(system.file("extdata", package = 'patternize'), '/BC0077_outline.txt', sep=''), header = FALSE) prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) ## Not run: area_lanRGB <- patArea(rasterList_lanRGB, IDlist, refShape = 'mean', type = 'RGB', outline = outline_BC0077, landList = landmarkList, adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077') area_regRGB <- patArea(rasterList_regRGB, IDlist, refShape = 'target', type = 'RGB', outline = outline_BC0077, crop = c(100,400,40,250), adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077', flipRaster = 'xy') areaList_lanK <- patArea(rasterList_lanK, IDlist, refShape = 'mean', type = 'k', outline = outline_BC0077, landList = landmarkList, adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077') areaList_regK <- patArea(rasterList_regK, IDlist, refShape = 'target', type = 'k', outline = outline_BC0077, crop = c(100,400,40,250), adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077', flipRaster = 'xy') ## End(Not run)
data(rasterList_lanRGB) #data(rasterList_regRGB) #data(rasterList_lanK) #data(rasterList_regK) data(imageList) IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') outline_BC0077 <- read.table(paste(system.file("extdata", package = 'patternize'), '/BC0077_outline.txt', sep=''), header = FALSE) prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) ## Not run: area_lanRGB <- patArea(rasterList_lanRGB, IDlist, refShape = 'mean', type = 'RGB', outline = outline_BC0077, landList = landmarkList, adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077') area_regRGB <- patArea(rasterList_regRGB, IDlist, refShape = 'target', type = 'RGB', outline = outline_BC0077, crop = c(100,400,40,250), adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077', flipRaster = 'xy') areaList_lanK <- patArea(rasterList_lanK, IDlist, refShape = 'mean', type = 'k', outline = outline_BC0077, landList = landmarkList, adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077') areaList_regK <- patArea(rasterList_regK, IDlist, refShape = 'target', type = 'k', outline = outline_BC0077, crop = c(100,400,40,250), adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077', flipRaster = 'xy') ## End(Not run)
Extract colors using GMM clustering (for pre-aligned images).
patGMM( sampleList, k = 3, resampleFactor = NULL, maskOutline = NULL, plot = FALSE, focal = FALSE, sigma = 3, maskToNA = NULL, kmeansOnAll = FALSE )
patGMM( sampleList, k = 3, resampleFactor = NULL, maskOutline = NULL, plot = FALSE, focal = FALSE, sigma = 3, maskToNA = NULL, kmeansOnAll = FALSE )
sampleList |
List of RasterStack objects. |
k |
Integere for defining number of clusters (default = 3). |
resampleFactor |
Integer for downsampling used by |
maskOutline |
When outline is specified, everything outside of the outline will be masked for the color extraction (default = NULL). |
plot |
Whether to plot transformed color patterns while processing (default = FALSE). |
focal |
Whether to perform Gaussian blurring (default = FALSE). |
sigma |
Size of sigma for Gaussian blurring (default = 3). |
maskToNA |
Replace the color value used for masking (i.e. 0 or 255) with NA. |
kmeansOnAll |
Whether to perform the kmeans clusters on the combined set of pixels of all images first (default = FALSE). |
List of summed raster for each k-means cluster objects.
Extract colors using k-means clustering (for pre-aligned images).
patK( sampleList, k = 3, fixedStartCenter = NULL, resampleFactor = NULL, maskOutline = NULL, plot = FALSE, focal = FALSE, sigma = 3, maskToNA = NULL, kmeansOnAll = FALSE )
patK( sampleList, k = 3, fixedStartCenter = NULL, resampleFactor = NULL, maskOutline = NULL, plot = FALSE, focal = FALSE, sigma = 3, maskToNA = NULL, kmeansOnAll = FALSE )
sampleList |
List of RasterStack objects. |
k |
Integere for defining number of k-means clusters (default = 3). |
fixedStartCenter |
Specify a dataframe with start centers for k-means clustering. |
resampleFactor |
Integer for downsampling used by |
maskOutline |
When outline is specified, everything outside of the outline will be masked for the color extraction (default = NULL). |
plot |
Whether to plot transformed color patterns while processing (default = FALSE). |
focal |
Whether to perform Gaussian blurring (default = FALSE). |
sigma |
Size of sigma for Gaussian blurring (default = 3). |
maskToNA |
Replace the color value used for masking (i.e. 0 or 255) with NA. |
kmeansOnAll |
Whether to perform the kmeans clusters on the combined set of pixels of all images first (default = FALSE). |
List of summed raster for each k-means cluster objects.
Extract colors using k-means clustering (for pre-aligned images).
patK_HSV( sampleList, k = 3, fixedStartCenter = NULL, resampleFactor = NULL, maskOutline = NULL, plot = FALSE, focal = FALSE, sigma = 3, maskToNA = NULL, kmeansOnAll = FALSE, ignoreHSVvalue = FALSE )
patK_HSV( sampleList, k = 3, fixedStartCenter = NULL, resampleFactor = NULL, maskOutline = NULL, plot = FALSE, focal = FALSE, sigma = 3, maskToNA = NULL, kmeansOnAll = FALSE, ignoreHSVvalue = FALSE )
sampleList |
List of RasterStack objects. |
k |
Integere for defining number of k-means clusters (default = 3). |
fixedStartCenter |
Specify a dataframe with start centers for k-means clustering. |
resampleFactor |
Integer for downsampling used by |
maskOutline |
When outline is specified, everything outside of the outline will be masked for the color extraction (default = NULL). |
plot |
Whether to plot transformed color patterns while processing (default = FALSE). |
focal |
Whether to perform Gaussian blurring (default = FALSE). |
sigma |
Size of sigma for Gaussian blurring (default = 3). |
maskToNA |
Replace the color value used for masking (i.e. 0 or 255) with NA. |
kmeansOnAll |
Whether to perform the kmeans clusters on the combined set of pixels of all images first (default = FALSE). |
ignoreHSVvalue |
Whether to ignore the HSV value (~darkness). |
List of summed raster for each k-means cluster objects.
Aligns images usings transformations obtained from fixed landmarks and extracts colors using a predefined RGB values and cutoff value.
patLanHSV( sampleList, landList, HSV, resampleFactor = NULL, colOffset = 0.1, crop = FALSE, cropOffset = c(0, 0, 0, 0), res = 300, transformRef = "meanshape", transformType = "tps", adjustCoords = FALSE, plot = NULL, focal = FALSE, sigma = 3, iterations = 0, ignoreHSVvalue = FALSE, patternsToFile = NULL )
patLanHSV( sampleList, landList, HSV, resampleFactor = NULL, colOffset = 0.1, crop = FALSE, cropOffset = c(0, 0, 0, 0), res = 300, transformRef = "meanshape", transformType = "tps", adjustCoords = FALSE, plot = NULL, focal = FALSE, sigma = 3, iterations = 0, ignoreHSVvalue = FALSE, patternsToFile = NULL )
sampleList |
List of RasterStack objects. |
landList |
Landmark list as returned by |
HSV |
HSV values for color pattern extraction specified as vector. |
resampleFactor |
Integer for downsampling used by |
colOffset |
Color offset for color pattern extraction (default = 0.10). |
crop |
Whether to use the landmarks range to crop the image. This can speed up the analysis (default = FALSE). |
cropOffset |
Vector c(xmin, xmax, ymin, ymax) that specifies the number of pixels you want the cropping to be offset from the landmarks (in case the landmarks do not surround the entire color pattern). The values specified should present the percentage of the maximum landmark value along the x and y axis. |
res |
Resolution for color pattern raster (default = 300). This should be reduced if the number of pixels in the image is lower than th raster. |
transformRef |
ID of reference sample for shape to which color patterns will be transformed to. Can be 'meanshape' for transforming to mean shape of Procrustes analysis. |
transformType |
Transformation type as used by |
adjustCoords |
Adjust landmark coordinates in case they are reversed compared to pixel coordinates (default = FALSE). |
plot |
Whether to plot transformed color patterns while processing (default = NULL). Transformed color patterns can be plot on top of each other ('stack') or next to the original image for each sample ('compare'). |
focal |
Whether to perform Gaussian blurring (default = FALSE). |
sigma |
Size of sigma for Gaussian blurring (default = 3). |
iterations |
Number of iterations for recalculating average color. |
ignoreHSVvalue |
Whether to ignore the HSV value (~darkness). |
patternsToFile |
Name of directory to which the color pattern of each individual will be outputted (default = NULL). |
List of raster objects.
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) HSV <- c(0.025,1,0.45) rasterList_lanHSV <- patLanRGB(imageList, landmarkList, HSV, colOffset = 0.15, crop = TRUE, res = 100, adjustCoords = TRUE, plot = 'stack') ## End(Not run)
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) HSV <- c(0.025,1,0.45) rasterList_lanHSV <- patLanRGB(imageList, landmarkList, HSV, colOffset = 0.15, crop = TRUE, res = 100, adjustCoords = TRUE, plot = 'stack') ## End(Not run)
Aligns images usings transformations obtained from fixed landmarks and extracts colors using k-means clustering.
patLanK( sampleList, landList, k = 3, fixedStartCenter = NULL, resampleFactor = NULL, crop = FALSE, cropOffset = c(0, 0, 0, 0), res = 300, transformRef = "meanshape", transformType = "tps", removebg = NULL, removebgColOffset = 0.1, adjustCoords = FALSE, plot = FALSE, focal = FALSE, sigma = 3 )
patLanK( sampleList, landList, k = 3, fixedStartCenter = NULL, resampleFactor = NULL, crop = FALSE, cropOffset = c(0, 0, 0, 0), res = 300, transformRef = "meanshape", transformType = "tps", removebg = NULL, removebgColOffset = 0.1, adjustCoords = FALSE, plot = FALSE, focal = FALSE, sigma = 3 )
sampleList |
List of RasterStack objects. |
landList |
Landmark list as returned by |
k |
Integere for defining number of k-means clusters (default = 3). |
fixedStartCenter |
Specify a dataframe with start centers for k-means clustering. |
resampleFactor |
Integer for downsampling used by |
crop |
Whether to use the landmarks range to crop the image. This can significantly speed up the analysis (default = FALSE). |
cropOffset |
Vector c(xmin, xmax, ymin, ymax) that specifies the number of pixels you want the cropping to be offset from the landmarks (in case the landmarks do not surround the entire color pattern). The values specified should present the percentage of the maximum landmark value along the x and y axis. |
res |
Resolution for color pattern raster (default = 300). This should be reduced if the number of pixels in the image is lower than th raster. |
transformRef |
ID of reference sample for shape to which color patterns will be transformed to. Can be 'meanshape' for transforming to mean shape of Procrustes analysis. |
transformType |
Transformation type as used by |
removebg |
Integer or RGB vector indicating the range of RGB threshold to remove from image (e.g. 100 removes pixels with average RGB > 100; default = NULL). |
removebgColOffset |
Color offset for color background extraction (default = 0.10). |
adjustCoords |
Adjust landmark coordinates in case they are reversed compared to pixel coordinates (default = FALSE). |
plot |
Whether to plot transformed color patterns while processing (default = FALSE). |
focal |
Whether to perform Gaussian blurring (default = FALSE). |
sigma |
Size of sigma for Gaussian blurring (default = 3). |
List of summed raster for each k-means cluster objects.
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) # Note that this example only aligns two images with the target, # remove [1:2] to run a full examples. rasterList_lanK <- patLanK(imageList[1:2], landmarkList[1:2], k = 4, crop = TRUE, res = 100, removebg = 100, adjustCoords = TRUE, plot = TRUE) ## End(Not run)
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) # Note that this example only aligns two images with the target, # remove [1:2] to run a full examples. rasterList_lanK <- patLanK(imageList[1:2], landmarkList[1:2], k = 4, crop = TRUE, res = 100, removebg = 100, adjustCoords = TRUE, plot = TRUE) ## End(Not run)
Aligns images usings transformations obtained from fixed landmarks and extracts colors using k-means clustering.
patLanK_HSV( sampleList, landList, k = 3, fixedStartCenter = NULL, resampleFactor = NULL, crop = FALSE, cropOffset = c(0, 0, 0, 0), res = 300, transformRef = "meanshape", transformType = "tps", removebgK = NULL, adjustCoords = FALSE, plot = FALSE, focal = FALSE, sigma = 3, ignoreHSVvalue = FALSE )
patLanK_HSV( sampleList, landList, k = 3, fixedStartCenter = NULL, resampleFactor = NULL, crop = FALSE, cropOffset = c(0, 0, 0, 0), res = 300, transformRef = "meanshape", transformType = "tps", removebgK = NULL, adjustCoords = FALSE, plot = FALSE, focal = FALSE, sigma = 3, ignoreHSVvalue = FALSE )
sampleList |
List of RasterStack objects. |
landList |
Landmark list as returned by |
k |
Integere for defining number of k-means clusters (default = 3). |
fixedStartCenter |
Specify a dataframe with start centers for k-means clustering. |
resampleFactor |
Integer for downsampling used by |
crop |
Whether to use the landmarks range to crop the image. This can significantly speed up the analysis (default = FALSE). |
cropOffset |
Vector c(xmin, xmax, ymin, ymax) that specifies the number of pixels you want the cropping to be offset from the landmarks (in case the landmarks do not surround the entire color pattern). The values specified should present the percentage of the maximum landmark value along the x and y axis. |
res |
Resolution for color pattern raster (default = 300). This should be reduced if the number of pixels in the image is lower than th raster. |
transformRef |
ID of reference sample for shape to which color patterns will be transformed to. Can be 'meanshape' for transforming to mean shape of Procrustes analysis. |
transformType |
Transformation type as used by |
removebgK |
Integer indicating the range RGB treshold to remove from image (e.g. 100 removes pixels with average RGB > 100; default = NULL) for k-means analysis. This works only to remove a white background. |
adjustCoords |
Adjust landmark coordinates in case they are reversed compared to pixel coordinates (default = FALSE). |
plot |
Whether to plot transformed color patterns while processing (default = FALSE). |
focal |
Whether to perform Gaussian blurring (default = FALSE). |
sigma |
Size of sigma for Gaussian blurring (default = 3). |
ignoreHSVvalue |
Whether to ignore the HSV value (~darkness). |
List of summed raster for each k-means cluster objects.
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) # Note that this example only aligns two images with the target, # remove [1:2] to run a full examples. rasterList_lanK <- patLanK(imageList[1:2], landmarkList[1:2], k = 4, crop = TRUE, res = 100, removebgK = 100, adjustCoords = TRUE, plot = TRUE) ## End(Not run)
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) # Note that this example only aligns two images with the target, # remove [1:2] to run a full examples. rasterList_lanK <- patLanK(imageList[1:2], landmarkList[1:2], k = 4, crop = TRUE, res = 100, removebgK = 100, adjustCoords = TRUE, plot = TRUE) ## End(Not run)
Aligns images usings transformations obtained from fixed landmarks and extracts colors using a predefined RGB values and cutoff value.
patLanRGB( sampleList, landList, RGB = NULL, sampleRGB = FALSE, sampleRGBtype = "point", resampleFactor = NULL, colOffset = 0.1, crop = FALSE, cropOffset = c(0, 0, 0, 0), res = 300, transformRef = "meanshape", transformType = "tps", adjustCoords = FALSE, plot = NULL, focal = FALSE, sigma = 3, iterations = 0, imageIDs = NULL, patternsToFile = NULL )
patLanRGB( sampleList, landList, RGB = NULL, sampleRGB = FALSE, sampleRGBtype = "point", resampleFactor = NULL, colOffset = 0.1, crop = FALSE, cropOffset = c(0, 0, 0, 0), res = 300, transformRef = "meanshape", transformType = "tps", adjustCoords = FALSE, plot = NULL, focal = FALSE, sigma = 3, iterations = 0, imageIDs = NULL, patternsToFile = NULL )
sampleList |
List of RasterStack objects. |
landList |
Landmark list as returned by |
RGB |
RGB values for color pattern extraction specified as vector. |
sampleRGB |
Whether to set RGB for each image manually. |
sampleRGBtype |
Whether to pick a point or area (defined by left bottom and top right) for sampleRGB. |
resampleFactor |
Integer for downsampling used by |
colOffset |
Color offset for color pattern extraction (default = 0.10). |
crop |
Whether to use the landmarks range to crop the image. This can speed up the analysis (default = FALSE). |
cropOffset |
Vector c(xmin, xmax, ymin, ymax) that specifies the number of pixels you want the cropping to be offset from the landmarks (in case the landmarks do not surround the entire color pattern). The values specified should present the percentage of the maximum landmark value along the x and y axis. |
res |
Resolution for color pattern raster (default = 300). This should be reduced if the number of pixels in the image is lower than th raster. |
transformRef |
ID of reference sample for shape to which color patterns will be transformed to. Can be 'meanshape' for transforming to mean shape of Procrustes analysis. |
transformType |
Transformation type as used by |
adjustCoords |
Adjust landmark coordinates in case they are reversed compared to pixel coordinates (default = FALSE). |
plot |
Whether to plot transformed color patterns while processing (default = NULL). Transformed color patterns can be plot on top of each other ('stack') or next to the original image for each sample ('compare'). |
focal |
Whether to perform Gaussian blurring (default = FALSE). |
sigma |
Size of sigma for Gaussian blurring (default = 3). |
iterations |
Number of iterations for recalculating average color. |
imageIDs |
A list of IDs to match landmarks to images if landmarkList and imageList don't have the same length. |
patternsToFile |
Name of directory to which the color pattern of each individual will be outputted (default = NULL). |
List of raster objects.
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) RGB <- c(114,17,0) rasterList_lanRGB <- patLanRGB(imageList, landmarkList, RGB, colOffset = 0.15, crop = TRUE, res = 100, adjustCoords = TRUE, plot = 'stack') ## End(Not run)
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) RGB <- c(114,17,0) rasterList_lanRGB <- patLanRGB(imageList, landmarkList, RGB, colOffset = 0.15, crop = TRUE, res = 100, adjustCoords = TRUE, plot = 'stack') ## End(Not run)
Extracts color pattern from landmark transformed image using watershed segmentation. This function works interactively by allowing to pick a starting pixel within each pattern element from which the watershed will extract the pattern. This function works best for patterns with sharp boundaries.
patLanW( sampleList, landList, IDlist = NULL, adjustCoords = FALSE, transformRef = "meanshape", resampleFactor = NULL, transformType = "tps", maskOutline = NULL, cartoonID = NULL, correct = FALSE, blur = TRUE, sigma = 3, bucketfill = TRUE, cleanP = NULL, splitC = NULL, plotTransformed = FALSE, plotCorrect = FALSE, plotEdges = FALSE, plotPriority = FALSE, plotWS = FALSE, plotBF = FALSE, plotFinal = FALSE )
patLanW( sampleList, landList, IDlist = NULL, adjustCoords = FALSE, transformRef = "meanshape", resampleFactor = NULL, transformType = "tps", maskOutline = NULL, cartoonID = NULL, correct = FALSE, blur = TRUE, sigma = 3, bucketfill = TRUE, cleanP = NULL, splitC = NULL, plotTransformed = FALSE, plotCorrect = FALSE, plotEdges = FALSE, plotPriority = FALSE, plotWS = FALSE, plotBF = FALSE, plotFinal = FALSE )
sampleList |
List of RasterStack objects. |
landList |
Landmark list as returned by |
IDlist |
List of sample IDs should be specified when masking outline and transformRef is 'meanshape'. |
adjustCoords |
Adjust landmark coordinates in case they are reversed compared to pixel coordinates (default = FALSE). |
transformRef |
ID or landmark matrix of reference sample for shape to which color patterns will be transformed to. Can be 'meanshape' for transforming to mean shape of Procrustes analysis. |
resampleFactor |
Integer for downsampling image used by |
transformType |
Transformation type as used by |
maskOutline |
When outline is specified, everything outside of the outline will be masked for the color extraction (default = NULL). |
cartoonID |
ID of the sample for which the cartoon was drawn and will be used for masking (should be set when transformRef = 'meanShape'). |
correct |
Correct image illumination using a linear model (default = FALSE). |
blur |
Blur image for priority map extraction (default = TRUE). |
sigma |
Size of sigma for Gaussian blurring (default = 5). |
bucketfill |
Use a bucket fill on the background to fill holes (default = TRUE). |
cleanP |
Integer to remove spurious areas with width smaller than cleanP (default = NULL). |
splitC |
Integer to split selected patterns into connected components and remove ones with areas smaller than splitC (default = NULL). |
plotTransformed |
Plot transformed image (default = FALSE). |
plotCorrect |
Plot corrected image, corrected for illumination using a linear model (default = FALSE). |
plotEdges |
Plot image gradient (default = FALSE). |
plotPriority |
Plot priority map (default = FALSE). |
plotWS |
Plot watershed result (default = FALSE). |
plotBF |
Plot bucketfill (default = FALSE). |
plotFinal |
Plot extracted patterns (default = FALSE). |
List of raster objects.
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) outline_BC0077 <- read.table(paste(system.file("extdata", package = 'patternize'), '/BC0077_outline.txt', sep=''), header = FALSE) rasterList_W <- patLanW(imageList, landmarkList, IDlist, transformRef = 'meanshape', adjustCoords = TRUE, plotTransformed = FALSE, correct = TRUE, plotCorrect = FALSE, blur = FALSE, sigma = 2, bucketfill = FALSE, cleanP = 0, splitC = 10, plotPriority = TRUE, plotWS = TRUE, plotBF = TRUE, plotFinal = TRUE, maskOutline = outline_BC0077, cartoonID = 'BC0077') ## End(Not run)
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) outline_BC0077 <- read.table(paste(system.file("extdata", package = 'patternize'), '/BC0077_outline.txt', sep=''), header = FALSE) rasterList_W <- patLanW(imageList, landmarkList, IDlist, transformRef = 'meanshape', adjustCoords = TRUE, plotTransformed = FALSE, correct = TRUE, plotCorrect = FALSE, blur = FALSE, sigma = 2, bucketfill = FALSE, cleanP = 0, splitC = 10, plotPriority = TRUE, plotWS = TRUE, plotBF = TRUE, plotFinal = TRUE, maskOutline = outline_BC0077, cartoonID = 'BC0077') ## End(Not run)
prcomp
). This function also allows to plot the
analysis including a visualization of the shape changes along the axis. Pixel values
are predicted by multiplying the rotation matrix (eigenvectors) with a vector that has
the same length as the number of rows in the rotation matrix and in which all values are
set to zero except for the PC value for which we want to predict the pixel values.This function transforms the individual color pattern rasters as obtained by the main
patternize functions to a dataframe of 0 and 1 values that can be used for Principal
Component Analysis (prcomp
). This function also allows to plot the
analysis including a visualization of the shape changes along the axis. Pixel values
are predicted by multiplying the rotation matrix (eigenvectors) with a vector that has
the same length as the number of rows in the rotation matrix and in which all values are
set to zero except for the PC value for which we want to predict the pixel values.
patPCA( rList, popList, colList, symbolList = NULL, rListPredict = NULL, popListPredict = NULL, colListPredict = NULL, pcaListPredict = NULL, pcaPopListPredict = NULL, pcaColPredict = "red", symbolListPredict = NULL, plot = FALSE, plotType = "points", plotChanges = FALSE, PCx = 1, PCy = 2, plotCartoon = FALSE, refShape = NULL, outline = NULL, lines = NULL, landList = NULL, adjustCoords = FALSE, crop = c(0, 0, 0, 0), flipRaster = NULL, flipOutline = NULL, imageList = NULL, cartoonID = NULL, refImage = NULL, colpalette = NULL, normalized = NULL, cartoonOrder = "above", lineOrder = "above", cartoonCol = "gray", cartoonFill = NULL, plotLandmarks = FALSE, landCol = "black", zlim = c(-1, 1), legendTitle = "Predicted", xlab = "", ylab = "", main = "", ... )
patPCA( rList, popList, colList, symbolList = NULL, rListPredict = NULL, popListPredict = NULL, colListPredict = NULL, pcaListPredict = NULL, pcaPopListPredict = NULL, pcaColPredict = "red", symbolListPredict = NULL, plot = FALSE, plotType = "points", plotChanges = FALSE, PCx = 1, PCy = 2, plotCartoon = FALSE, refShape = NULL, outline = NULL, lines = NULL, landList = NULL, adjustCoords = FALSE, crop = c(0, 0, 0, 0), flipRaster = NULL, flipOutline = NULL, imageList = NULL, cartoonID = NULL, refImage = NULL, colpalette = NULL, normalized = NULL, cartoonOrder = "above", lineOrder = "above", cartoonCol = "gray", cartoonFill = NULL, plotLandmarks = FALSE, landCol = "black", zlim = c(-1, 1), legendTitle = "Predicted", xlab = "", ylab = "", main = "", ... )
rList |
List of raster objects. |
popList |
List of vectors including sampleIDs for each population. |
colList |
List of colors for each population. |
symbolList |
List with graphical plotting symbols (default = NULL). |
rListPredict |
List of raster objects to predict into PCA space (default = NULL). |
popListPredict |
List of vectors including sampleIDs for each set of predict samples (default = NULL). Note to that this also has to be a list if only one population is included. |
colListPredict |
List of colors for each set of predict samples (default = NULL). |
pcaListPredict |
Points to plot within PCA space. |
pcaPopListPredict |
List of population symbols for plotting additional PCA values. |
pcaColPredict |
Color for additional PCA values. |
symbolListPredict |
List with graphical plotting symbols for predict sets (default = NULL). |
plot |
Whether to plot the PCA analysis (default = FALSE). |
plotType |
Plot 'points' or sample 'labels' (default = 'points') |
plotChanges |
Wether to include plots of the changes along the PC axis (default = FALSE). |
PCx |
PC axis to be presented for x-axis (default PC1). |
PCy |
PC axis to be presented for y-axis (default PC2). |
plotCartoon |
Whether to plot a cartoon. This cartoon should be drawn on one of the samples used in the analysis. |
refShape |
This can be 'target' in case the reference shape is a single sample (for registration analysis) or 'mean' if the images were transformed to a mean shape (only for meanshape when using landmark transformation) |
outline |
xy coordinates that define outline. |
lines |
list of files with xy coordinates of line objects to be added to cartoon. |
landList |
Landmark landmarkList. |
adjustCoords |
Adjust landmark coordinates. |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image used in landmark or registration analysis. |
flipRaster |
Whether to flip raster along xy axis (in case there is an inconsistency between raster and outline coordinates). |
flipOutline |
Whether to flip plot along x, y or xy axis. |
imageList |
List of image should be given if one wants to flip the outline or adjust landmark coordinates. |
cartoonID |
ID of the sample for which the cartoon was drawn. |
refImage |
Image (RasterStack) used for target. Use raster::stack('filename'). |
colpalette |
Vector of colors for color palette (default = c("white","lightblue","blue","green", "yellow","red")) |
normalized |
Set this to true in case the summed rasters are already devided by the sample number. |
cartoonOrder |
Whether to plot the cartoon outline 'above' or 'under' the pattern raster (default = 'above'). Set to 'under' for filled outlines. |
lineOrder |
Whether to plot the cartoon lines 'above' or 'under' the pattern raster (default = 'above'). |
cartoonCol |
Outline and line color for cartoon (deafault = 'gray'). |
cartoonFill |
Fill color for outline of cartoon (default = NULL). |
plotLandmarks |
Whether to plot the landmarks from the target image or mean shape landmarks (default = FALSE). |
landCol |
Color for plotting landmarks (default = 'black'). |
zlim |
z-axis limit (default = c(0,1)) |
legendTitle |
Title of the raster legend (default = 'Proportion') |
xlab |
Optional x-axis label. |
ylab |
Optional y-axis label. |
main |
Optional main title. |
... |
additional arguments for PCA plot function. |
If plot = TRUE: List including a [1] dataframe of the binary raster values that can be used for principle component analysis, [2] a dataframe of sample IDs and specified population colors and [3] prcomp results. If plot = FALSE: prcomp result.
data(rasterList_lanRGB) pop1 <- c('BC0077','BC0071') pop2 <- c('BC0050','BC0049','BC0004') popList <- list(pop1, pop2) colList <- c("red", "blue") pcaOut <- patPCA(rasterList_lanRGB, popList, colList, plot = TRUE)
data(rasterList_lanRGB) pop1 <- c('BC0077','BC0071') pop2 <- c('BC0050','BC0049','BC0004') popList <- list(pop1, pop2) colList <- c("red", "blue") pcaOut <- patPCA(rasterList_lanRGB, popList, colList, plot = TRUE)
rda
). This function also allows to plot the
analysis including a visualization of the shape changes along the axis.This function transforms the individual color pattern rasters as obtained by the main
patternize functions to a dataframe of 0 and 1 values that can be used for constrained
Redundancy Analysis (RDA) (rda
). This function also allows to plot the
analysis including a visualization of the shape changes along the axis.
patRDA( rList, popList, colList, symbolList = NULL, rListPredict = NULL, popListPredict = NULL, colListPredict = NULL, symbolListPredict = NULL, plot = FALSE, plotType = "points", plotChanges = FALSE, PCx = 1, PCy = 2, plotCartoon = FALSE, refShape = NULL, outline = NULL, lines = NULL, landList = NULL, adjustCoords = FALSE, crop = c(0, 0, 0, 0), flipRaster = NULL, flipOutline = NULL, imageList = NULL, cartoonID = NULL, colpalette = NULL, normalized = NULL, cartoonOrder = "above", lineOrder = "above", cartoonCol = "gray", cartoonFill = NULL, plotLandmarks = FALSE, landCol = "black", zlim = c(-1, 1), legendTitle = "Predicted", xlab = "", ylab = "", main = "" )
patRDA( rList, popList, colList, symbolList = NULL, rListPredict = NULL, popListPredict = NULL, colListPredict = NULL, symbolListPredict = NULL, plot = FALSE, plotType = "points", plotChanges = FALSE, PCx = 1, PCy = 2, plotCartoon = FALSE, refShape = NULL, outline = NULL, lines = NULL, landList = NULL, adjustCoords = FALSE, crop = c(0, 0, 0, 0), flipRaster = NULL, flipOutline = NULL, imageList = NULL, cartoonID = NULL, colpalette = NULL, normalized = NULL, cartoonOrder = "above", lineOrder = "above", cartoonCol = "gray", cartoonFill = NULL, plotLandmarks = FALSE, landCol = "black", zlim = c(-1, 1), legendTitle = "Predicted", xlab = "", ylab = "", main = "" )
rList |
List of raster objects. |
popList |
List of vectors including sampleIDs for each population. |
colList |
List of colors for each population. |
symbolList |
List with graphical plotting symbols (default = NULL). |
rListPredict |
List of raster objects to predict into DFA space (default = NULL). |
popListPredict |
List of vectors including sampleIDs for each set of predict samples (default = NULL). Note to that this also has to be a list if only one population is included. |
colListPredict |
List of colors for each set of predict samples (default = NULL). |
symbolListPredict |
List with graphical plotting symbols for predict sets (default = NULL). |
plot |
Whether to plot the PCA analysis (default = FALSE). |
plotType |
Plot 'points' or sample 'labels' (default = 'points') |
plotChanges |
Wether to include plots of the changes along the PC axis (default = FALSE). |
PCx |
PC axis to be presented for x-axis (default PC1). |
PCy |
PC axis to be presented for y-axis (default PC2). |
plotCartoon |
Whether to plot a cartoon. This cartoon should be drawn on one of the samples used in the analysis. |
refShape |
This can be 'target' in case the reference shape is a single sample (for registration analysis) or 'mean' if the images were transformed to a mean shape (only for meanshape when using landmark transformation) |
outline |
xy coordinates that define outline. |
lines |
list of files with xy coordinates of line objects to be added to cartoon. |
landList |
Landmark landmarkList. |
adjustCoords |
Adjust landmark coordinates. |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image used in landmark or registration analysis. |
flipRaster |
Whether to flip raster along xy axis (in case there is an inconsistency between raster and outline coordinates). |
flipOutline |
Whether to flip plot along x, y or xy axis. |
imageList |
List of image should be given if one wants to flip the outline or adjust landmark coordinates. |
cartoonID |
ID of the sample for which the cartoon was drawn. |
colpalette |
Vector of colors for color palette (default = c("white","lightblue","blue","green", "yellow","red")) |
normalized |
Set this to true in case the summed rasters are already devided by the sample number. |
cartoonOrder |
Whether to plot the cartoon outline 'above' or 'under' the pattern raster (default = 'above'). Set to 'under' for filled outlines. |
lineOrder |
Whether to plot the cartoon lines 'above' or 'under' the pattern raster (default = 'above'). |
cartoonCol |
Outline and line color for cartoon (deafault = 'gray'). |
cartoonFill |
Fill color for outline of cartoon (default = NULL). |
plotLandmarks |
Whether to plot the landmarks from the target image or mean shape landmarks (default = FALSE). |
landCol |
Color for plotting landmarks (default = 'black'). |
zlim |
z-axis limit (default = c(0,1)) |
legendTitle |
Title of the raster legend (default = 'Proportion') |
xlab |
Optional x-axis label. |
ylab |
Optional y-axis label. |
main |
Optional main title. |
If plot = TRUE: List including a [1] dataframe of the binary raster values that can be used for discriminant function analysis, [2] a dataframe of sample IDs and specified population colors and [3] lda results. if rListPredict not empty: [4] class prediction of samples. If plot = FALSE: lda result only.
data(rasterList_lanRGB) pop1 <- c('BC0077','BC0071') pop2 <- c('BC0050','BC0049','BC0004') popList <- list(pop1, pop2) colList <- c("red", "blue") pcaOut <- patRDA(rasterList_lanRGB, popList, colList, plot = TRUE)
data(rasterList_lanRGB) pop1 <- c('BC0077','BC0071') pop2 <- c('BC0050','BC0049','BC0004') popList <- list(pop1, pop2) colList <- c("red", "blue") pcaOut <- patRDA(rasterList_lanRGB, popList, colList, plot = TRUE)
niftyreg
utilities for automated image registration
and extracts colors using a predefined HSV values and cutoff value.Aligns images using niftyreg
utilities for automated image registration
and extracts colors using a predefined HSV values and cutoff value.
patRegHSV( sampleList, target, HSV, resampleFactor = NULL, useBlockPercentage = 75, colOffset = 0.1, crop = c(0, 0, 0, 0), removebgR = NULL, maskOutline = NULL, plot = FALSE, focal = FALSE, sigma = 3, iterations = 0, ignoreHSVvalue = FALSE, patternsToFile = NULL )
patRegHSV( sampleList, target, HSV, resampleFactor = NULL, useBlockPercentage = 75, colOffset = 0.1, crop = c(0, 0, 0, 0), removebgR = NULL, maskOutline = NULL, plot = FALSE, focal = FALSE, sigma = 3, iterations = 0, ignoreHSVvalue = FALSE, patternsToFile = NULL )
sampleList |
List of RasterStack objects. |
target |
Image imported as RasterStack used as target for registration. |
HSV |
Values for color pattern extraction specified as HSV vector. |
resampleFactor |
Integer for downsampling used by |
useBlockPercentage |
Block percentage as used in |
colOffset |
Color offset for color pattern extraction (default = 0.10). |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image. |
removebgR |
Integer indicating the range RGB treshold to remove from image (e.g. 100 removes pixels with average RGB > 100; default = NULL) for registration analysis. This works only to remove a white background. |
maskOutline |
When outline is specified, everything outside of the outline will be masked for the color extraction (default = NULL). |
plot |
Whether to plot transformed color patterns while processing (default = FALSE). Transformed color patterns can be plot on top of each other ('stack') or next to the original image for each sample ('compare'). |
focal |
Whether to perform Gaussian blurring (default = FALSE). |
sigma |
Size of sigma for Gaussian blurring (default = 3). |
iterations |
Number of iterations for recalculating average color (default = 0). If set, the RGB value for pattern extraction will be iteratively recalculated to be the average of the extracted area. This may improve extraction of distinct color pattern, but fail for more gradually distributed (in color space) patterns. |
ignoreHSVvalue |
Whether to ignore the HSV value (~darkness). |
patternsToFile |
Name of directory to which the color pattern of each individual will be outputted (default = NULL). |
List of raster objects.
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) target <- imageList[[1]] HSV <- c(0.025,1,0.45) # Note that this example only aligns one image with the target, # remove [2] to run a full examples. rasterList_regHSV <- patRegRGB(imageList[2], target, HSV, colOffset= 0.15, crop = c(100,400,40,250), removebgR = 100, plot = 'stack') ## End(Not run)
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) target <- imageList[[1]] HSV <- c(0.025,1,0.45) # Note that this example only aligns one image with the target, # remove [2] to run a full examples. rasterList_regHSV <- patRegRGB(imageList[2], target, HSV, colOffset= 0.15, crop = c(100,400,40,250), removebgR = 100, plot = 'stack') ## End(Not run)
niftyreg
utilities for automated image registration
and extracts colors using k-means clustering.Aligns images using niftyreg
utilities for automated image registration
and extracts colors using k-means clustering.
patRegK( sampleList, target, k = 3, fixedStartCenter = NULL, resampleFactor = NULL, useBlockPercentage = 75, crop = c(0, 0, 0, 0), removebgR = NULL, removebgK = NULL, maskOutline = NULL, maskColor = 0, plot = FALSE, focal = FALSE, sigma = 3 )
patRegK( sampleList, target, k = 3, fixedStartCenter = NULL, resampleFactor = NULL, useBlockPercentage = 75, crop = c(0, 0, 0, 0), removebgR = NULL, removebgK = NULL, maskOutline = NULL, maskColor = 0, plot = FALSE, focal = FALSE, sigma = 3 )
sampleList |
List of RasterStack objects. |
target |
Image imported as RasterStack used as target for registration. |
k |
Integere for defining number of k-means clusters (default = 3). |
fixedStartCenter |
Specify a dataframe with start centers for k-means clustering. |
resampleFactor |
Integer for downsampling used by |
useBlockPercentage |
Block percentage as used in |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image. |
removebgR |
Integer indicating the range RGB treshold to remove from image (e.g. 100 removes pixels with average RGB > 100; default = NULL) for registration analysis. This works only to remove a white background. |
removebgK |
Integer indicating the range RGB treshold to remove from image (e.g. 100 removes pixels with average RGB > 100; default = NULL) for k-means analysis. This works only to remove a white background. |
maskOutline |
When outline is specified, everything outside of the outline will be masked for the color extraction (default = NULL). |
maskColor |
Color the masked area gets. Set to 0 for black (default) or 255 for white. |
plot |
Whether to plot k-means clustered image while processing (default = FALSE). |
focal |
Whether to perform Gaussian blurring (default = FALSE). |
sigma |
Size of sigma for Gaussian blurring (default = 3). |
List of rasters for each k-means cluster objects.
IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) target <- imageList[[1]] ## Not run: rasterList_regK <- patRegK(imageList[3], target, k = 5, crop = c(100,400,40,250), removebgR = 100, plot = TRUE) ## End(Not run)
IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) target <- imageList[[1]] ## Not run: rasterList_regK <- patRegK(imageList[3], target, k = 5, crop = c(100,400,40,250), removebgR = 100, plot = TRUE) ## End(Not run)
niftyreg
utilities for automated image registration
and extracts colors using k-means clustering.Aligns images using niftyreg
utilities for automated image registration
and extracts colors using k-means clustering.
patRegK_HSV( sampleList, target, k = 3, fixedStartCenter = NULL, resampleFactor = NULL, useBlockPercentage = 75, crop = c(0, 0, 0, 0), removebgR = NULL, removebgK = NULL, maskOutline = NULL, maskColor = 0, plot = FALSE, focal = FALSE, sigma = 3, ignoreHSVvalue = FALSE )
patRegK_HSV( sampleList, target, k = 3, fixedStartCenter = NULL, resampleFactor = NULL, useBlockPercentage = 75, crop = c(0, 0, 0, 0), removebgR = NULL, removebgK = NULL, maskOutline = NULL, maskColor = 0, plot = FALSE, focal = FALSE, sigma = 3, ignoreHSVvalue = FALSE )
sampleList |
List of RasterStack objects. |
target |
Image imported as RasterStack used as target for registration. |
k |
Integere for defining number of k-means clusters (default = 3). |
fixedStartCenter |
Specify a dataframe with start centers for k-means clustering. |
resampleFactor |
Integer for downsampling used by |
useBlockPercentage |
Block percentage as used in |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image. |
removebgR |
Integer indicating the range RGB treshold to remove from image (e.g. 100 removes pixels with average RGB > 100; default = NULL) for registration analysis. This works only to remove a white background. |
removebgK |
Integer indicating the range RGB treshold to remove from image (e.g. 100 removes pixels with average RGB > 100; default = NULL) for k-means analysis. This works only to remove a white background. |
maskOutline |
When outline is specified, everything outside of the outline will be masked for the color extraction (default = NULL). |
maskColor |
Color the masked area gets. Set to 0 for black (default) or 255 for white. |
plot |
Whether to plot k-means clustered image while processing (default = FALSE). |
focal |
Whether to perform Gaussian blurring (default = FALSE). |
sigma |
Size of sigma for Gaussian blurring (default = 3). |
ignoreHSVvalue |
Whether to ignore the HSV value (~darkness). |
List of rasters for each k-means cluster objects.
IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) target <- imageList[[1]] ## Not run: rasterList_regK <- patRegK(imageList[3], target, k = 5, crop = c(100,400,40,250), removebgR = 100, plot = TRUE) ## End(Not run)
IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) target <- imageList[[1]] ## Not run: rasterList_regK <- patRegK(imageList[3], target, k = 5, crop = c(100,400,40,250), removebgR = 100, plot = TRUE) ## End(Not run)
niftyreg
utilities for automated image registration
and extracts colors using a predefined RGB values and cutoff value.Aligns images using niftyreg
utilities for automated image registration
and extracts colors using a predefined RGB values and cutoff value.
patRegRGB( sampleList, target, RGB, resampleFactor = NULL, useBlockPercentage = 75, colOffset = 0.1, crop = c(0, 0, 0, 0), removebgR = NULL, maskOutline = NULL, plot = FALSE, focal = FALSE, sigma = 3, iterations = 0, patternsToFile = NULL )
patRegRGB( sampleList, target, RGB, resampleFactor = NULL, useBlockPercentage = 75, colOffset = 0.1, crop = c(0, 0, 0, 0), removebgR = NULL, maskOutline = NULL, plot = FALSE, focal = FALSE, sigma = 3, iterations = 0, patternsToFile = NULL )
sampleList |
List of RasterStack objects. |
target |
Image imported as RasterStack used as target for registration. |
RGB |
Values for color pattern extraction specified as RGB vector. |
resampleFactor |
Integer for downsampling used by |
useBlockPercentage |
Block percentage as used in |
colOffset |
Color offset for color pattern extraction (default = 0.10). |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image. |
removebgR |
Integer indicating the range RGB treshold to remove from image (e.g. 100 removes pixels with average RGB > 100; default = NULL) for registration analysis. This works only to remove a white background. |
maskOutline |
When outline is specified, everything outside of the outline will be masked for the color extraction (default = NULL). |
plot |
Whether to plot transformed color patterns while processing (default = FALSE). Transformed color patterns can be plot on top of each other ('stack') or next to the original image for each sample ('compare'). |
focal |
Whether to perform Gaussian blurring (default = FALSE). |
sigma |
Size of sigma for Gaussian blurring (default = 3). |
iterations |
Number of iterations for recalculating average color (default = 0). If set, the RGB value for pattern extraction will be iteratively recalculated to be the average of the extracted area. This may improve extraction of distinct color pattern, but fail for more gradually distributed (in color space) patterns. |
patternsToFile |
Name of directory to which the color pattern of each individual will be outputted (default = NULL). |
List of raster objects.
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) target <- imageList[[1]] RGB <- c(114,17,0) # Note that this example only aligns one image with the target, # remove [2] to run a full examples. rasterList_regRGB <- patRegRGB(imageList[2], target, RGB, colOffset= 0.15, crop = c(100,400,40,250), removebgR = 100, plot = 'stack') ## End(Not run)
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) target <- imageList[[1]] RGB <- c(114,17,0) # Note that this example only aligns one image with the target, # remove [2] to run a full examples. rasterList_regRGB <- patRegRGB(imageList[2], target, RGB, colOffset= 0.15, crop = c(100,400,40,250), removebgR = 100, plot = 'stack') ## End(Not run)
niftyreg
utilities for automated image registration
and extracts color pattern using watershed segmentation. This function works interactively by
allowing to pick a starting pixel within each pattern element from which the watershed will
extract the pattern. This function works best for patterns with sharp boundaries.Aligns images using niftyreg
utilities for automated image registration
and extracts color pattern using watershed segmentation. This function works interactively by
allowing to pick a starting pixel within each pattern element from which the watershed will
extract the pattern. This function works best for patterns with sharp boundaries.
patRegW( sampleList, target, resampleFactor = NULL, useBlockPercentage = 75, crop = c(0, 0, 0, 0), removebgR = NULL, maskOutline = NULL, cartoonID = NULL, correct = FALSE, blur = TRUE, sigma = 3, bucketfill = TRUE, cleanP = NULL, splitC = NULL, plotTransformed = FALSE, plotCorrect = FALSE, plotEdges = FALSE, plotPriority = FALSE, plotWS = FALSE, plotBF = FALSE, plotFinal = FALSE )
patRegW( sampleList, target, resampleFactor = NULL, useBlockPercentage = 75, crop = c(0, 0, 0, 0), removebgR = NULL, maskOutline = NULL, cartoonID = NULL, correct = FALSE, blur = TRUE, sigma = 3, bucketfill = TRUE, cleanP = NULL, splitC = NULL, plotTransformed = FALSE, plotCorrect = FALSE, plotEdges = FALSE, plotPriority = FALSE, plotWS = FALSE, plotBF = FALSE, plotFinal = FALSE )
sampleList |
List of RasterStack objects. |
target |
Image imported as RasterStack used as target for registration. |
resampleFactor |
Integer for downsampling image used by |
useBlockPercentage |
Block percentage as used in |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image. |
removebgR |
Integer indicating the range RGB treshold to remove from image (e.g. 100 removes pixels with average RGB > 100; default = NULL) for registration analysis. This works only to remove a white background. |
maskOutline |
When outline is specified, everything outside of the outline will be masked for the color extraction (default = NULL). |
cartoonID |
ID of the sample for which the cartoon was drawn and will be used for masking. |
correct |
Correct image illumination using a linear model (default = FALSE). |
blur |
Blur image for priority map extraction (default = TRUE). |
sigma |
Size of sigma for Gaussian blurring (default = 5). |
bucketfill |
Use a bucket fill on the background to fill holes (default = TRUE). |
cleanP |
Integer to remove spurious areas with width smaller than cleanP (default = NULL). |
splitC |
Integer to split selected patterns into connected components and remove ones with areas smaller than splitC (default = NULL). |
plotTransformed |
Plot transformed image (default = FALSE). |
plotCorrect |
Plot corrected image, corrected for illumination using a linear model (default = FALSE). |
plotEdges |
Plot image gradient (default = FALSE). |
plotPriority |
Plot priority map (default = FALSE). |
plotWS |
Plot watershed result (default = FALSE). |
plotBF |
Plot bucketfill (default = FALSE). |
plotFinal |
Plot extracted patterns (default = FALSE). |
List of raster objects.
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) target <- imageList[[1]] outline_BC0077 <- read.table(paste(system.file("extdata", package = 'patternize'), '/BC0077_outline.txt', sep=''), header = FALSE) rasterList_regW <- patRegW(imageList, target, plotTransformed = FALSE, cartoonID = 'BC0077', correct = TRUE, plotCorrect = FALSE, blur = FALSE, sigma = 2, bucketfill = FALSE, cleanP = 0, splitC = 10, plotPriority = TRUE, plotWS = FALSE, plotBF = FALSE, plotFinal = TRUE, removebgR = 100, maskOutline = outline_BC0077) ## End(Not run)
## Not run: IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') prepath <- system.file("extdata", package = 'patternize') extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) target <- imageList[[1]] outline_BC0077 <- read.table(paste(system.file("extdata", package = 'patternize'), '/BC0077_outline.txt', sep=''), header = FALSE) rasterList_regW <- patRegW(imageList, target, plotTransformed = FALSE, cartoonID = 'BC0077', correct = TRUE, plotCorrect = FALSE, blur = FALSE, sigma = 2, bucketfill = FALSE, cleanP = 0, splitC = 10, plotPriority = TRUE, plotWS = FALSE, plotBF = FALSE, plotFinal = TRUE, removebgR = 100, maskOutline = outline_BC0077) ## End(Not run)
Quantifying variation in color patterns to study and compare the consistency of their expression necessitates the homologous alignment and color-based segmentation of images. Patternize is an R package that quantifies variation in color patterns as obtained from image data. Patternize defines homology between pattern positions across specimens either through fixed landmarks or image registration. Pattern identification is performed by categorizing the distribution of colors using either an RGB threshold or an unsupervised image segmentation. The quantification of the color patterns can be visualized as heat maps and compared between sets of samples.
The package has six main functions depending on how you want the alignment of the iamges and the color extraction to be performed.
patLanRGB
Aligns images by transformations obtained from fixed landmarks and extracts colors using
a predefined RGB values and cutoff value.
patLanK
Aligns images by transformations obtained from fixed landmarks and extracts colors using
k-means clustering.
patLanW
Aligns images by transformations obtained from fixed landmarks and extracts color
patterns by watershed segmentation using imager
utilities.
patRegRGB
Aligns images using niftyreg
utilities for automated image
registration and extracts colors using a predefined RGB values and cutoff value.
patRegK
Aligns images using niftyreg
utilities for automated image
registration and extracts colors using k-means clustering.
patRegW
Aligns images using niftyreg
utilities for automated image
registration and extracts color patterns by watershed segmentation using
imager
utilities.
The input for the main patternize functions are RasterStack
objects and when landmark
transformation is used, landmark arrays.
makeList
This function returns a list of RasterStacks or a list of landmarks depending on the input
provided.
sampleLandmarks
Sample landmarks in an image.
lanArray
This function creates a landmark array as used by procSym
in the
package Morpho
.
sumRaster
This function sums the individual color pattern rasters as obtained by the main patternize
functions.
plotHeat
Plots the color pattern heatmaps from sumRaster
output.
patPCA
This function transforms the individual color pattern rasters as obtained by the main
patternize functions to a dataframe of 0 and 1 values that can be used for Principal
Component Analysis (prcomp
). This function also allows to plot the
analysis including a visualization of the shape changes along the axis.
patRDA
This function transforms the individual color pattern rasters as obtained by the main
patternize functions to a dataframe of 0 and 1 values that can be used for constrained
Redundancy Analysis (rda
). This function also allows to plot the
analysis including a visualization of the shape changes along the axis.
patArea
This fucntion calculates the area in which the color pattern is expressed in each sample
as the relative proportion using the provided outline of the considered trait or structure.
redRes
Reduces the resolution of the RasterStack
objects to speed up analysis.
kImage
Performs k-means clustering of images.
sampleRGB
Interactive function to sample RGB value from pixel or area in an image.
createTarget
Creates an artificial target images using a provided outline that can be used for image
registration (experimantal).
maskOutline
Intersects a RasterStack with an outline. Everything outside of the outline will be removed
from the raster.
colorChecker
Calibrate images using ColorChecker.
Steven M. Van Belleghem
raster
,
stack
,
procSym
,
computeTransform
,
niftyreg
imager
Jon Clayden, Marc Modat, Benoit Presles, Thanasis Anthopoulos and Pankaj Daga (2017).
RNiftyReg: Image Registration Using the 'NiftyReg' Library. R package version 2.5.0.
https://CRAN.R-project.org/package=RNiftyReg
Stefan Schlager (2016). Morpho: Calculations and Visualisations Related to Geometric
Morphometrics. R package version 2.4.1.1. https://github.com/zarquon42b/Morpho
Simon Barthelmé (2017). imager: Image processing library based on ‘CImg’. R package
version 0.40.2. https://CRAN.R-project.org/package=imager
sumRaster
output.Plots the color pattern heatmaps from sumRaster
output.
plotHeat( summedRaster, IDlist, colpalette = NULL, plotCartoon = FALSE, refShape = NULL, outline = NULL, lines = NULL, landList = NULL, adjustCoords = FALSE, cartoonID = NULL, normalized = FALSE, crop = c(0, 0, 0, 0), flipRaster = NULL, flipOutline = NULL, imageList = NULL, refImage = NULL, cartoonOrder = "above", lineOrder = "above", cartoonCol = "gray", cartoonFill = NULL, plotLandmarks = FALSE, landCol = "black", zlim = c(0, 1), legend = TRUE, legendTitle = "Proportion", legend.side = 4, xlab = "", ylab = "", main = "", plotType = "multi", imageIDs = NULL, format = "imageJ" )
plotHeat( summedRaster, IDlist, colpalette = NULL, plotCartoon = FALSE, refShape = NULL, outline = NULL, lines = NULL, landList = NULL, adjustCoords = FALSE, cartoonID = NULL, normalized = FALSE, crop = c(0, 0, 0, 0), flipRaster = NULL, flipOutline = NULL, imageList = NULL, refImage = NULL, cartoonOrder = "above", lineOrder = "above", cartoonCol = "gray", cartoonFill = NULL, plotLandmarks = FALSE, landCol = "black", zlim = c(0, 1), legend = TRUE, legendTitle = "Proportion", legend.side = 4, xlab = "", ylab = "", main = "", plotType = "multi", imageIDs = NULL, format = "imageJ" )
summedRaster |
Summed raster or summedRasterList. |
IDlist |
List of sample IDs. |
colpalette |
Vector of colors for color palette (default = c("white","lightblue","blue","green", "yellow","red")) |
plotCartoon |
Whether to plot a cartoon. This cartoon should be drawn on one of the samples used in the analysis. |
refShape |
This can be 'target' in case the reference shape is a single sample (for registration analysis) or 'mean' if the images were transformed to a mean shape (only for meanshape when using landmark transformation) |
outline |
xy coordinates that define outline. |
lines |
list of files with xy coordinates of line objects to be added to cartoon. |
landList |
Landmark landmarkList. |
adjustCoords |
Adjust landmark coordinates. |
cartoonID |
ID of the sample for which the cartoon was drawn. |
normalized |
Set this to true in case the summed rasters are already devided by the sample number. |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image used in landmark or registration analysis. |
flipRaster |
Whether to flip raster along xy axis (in case there is an inconsistency between raster and outline coordinates). |
flipOutline |
Whether to flip plot along x, y or xy axis. |
imageList |
List of images should be given if one wants to flip the outline or adjust landmark coordinates. |
refImage |
Image (RasterStack) used for target. Use raster::stack('filename'). |
cartoonOrder |
Whether to plot the cartoon outline 'above' or 'under' the pattern raster (default = 'above'). Set to 'under' for filled outlines. |
lineOrder |
Whether to plot the cartoon lines 'above' or 'under' the pattern raster (default = 'above'). |
cartoonCol |
Outline and line color for cartoon (deafault = 'gray'). |
cartoonFill |
Fill color for outline of cartoon (default = NULL). |
plotLandmarks |
Whether to plot the landmarks from the target image or mean shape landmarks (default = FALSE). |
landCol |
Color for ploting landmarks (default = 'black'). |
zlim |
z-axis limit (default = c(0,1)) |
legend |
Whether to plot legend with heatmaps. |
legendTitle |
Title of the raster legend (default = 'Proportion') |
legend.side |
Side to plot legend (default = 4) |
xlab |
Optional x-axis label. |
ylab |
Optional y-axis label. |
main |
Optional main title. |
plotType |
Set as 'PCA' when visualizing shape changes along PCA axis in \ codepatPCA, as 'one' when visualizing single image or as 'multi' for multi plotting or when setting customized margins (default = 'multi'). |
imageIDs |
A list of IDs to match landmarks to images if landmarkList and imageList don't have the same length. |
format |
ImageJ (Fiji) or tps format (default = 'imageJ'). |
data(rasterList_lanRGB) IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') outline_BC0077 <- read.table(paste(system.file("extdata", package = 'patternize'), '/BC0077_outline.txt', sep=''), header = FALSE) lines_BC0077 <- list.files(path=paste(system.file("extdata", package = 'patternize')), pattern='vein', full.names = TRUE) summedRaster_regRGB <- sumRaster(rasterList_regRGB, IDlist, type = 'RGB') data(imageList) plotHeat(summedRaster_regRGB, IDlist, plotCartoon = TRUE, refShape = 'target', outline = outline_BC0077, lines = lines_BC0077, crop = c(100,400,40,250), flipRaster = 'xy', imageList = imageList, cartoonOrder = 'under', cartoonID = 'BC0077', cartoonFill = 'black', main = 'registration_example') ## Not run: data(rasterList_lanK) IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') summedRasterList <- sumRaster(rasterList_lanK, IDlist, type = 'k') plotHeat(summedRasterList, IDlist) summedRasterList_regK <- sumRaster(rasterList_regK, IDlist, type = 'k') plotHeat(summedRasterList_regK, IDlist, plotCartoon = TRUE, refShape = 'target', outline = outline_BC0077, lines = lines_BC0077, crop = c(100,400,40,250), flipRaster = 'y', imageList = imageList, cartoonOrder = 'under', cartoonFill = 'black', main = 'kmeans_example') plotHeat(summedRasterList_regK[[1]], IDlist, plotCartoon = TRUE, refShape = 'target', outline = outline_BC0077, lines = lines_BC0077, crop = c(100,400,40,250), flipRaster = 'y', imageList = imageList, cartoonOrder = 'under', cartoonFill = 'black', main = 'kmeans_example') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) summedRaster_lanRGB <- sumRaster(rasterList_lanRGB, IDlist, type = 'RGB') plotHeat(summedRaster_lanRGB, IDlist, plotCartoon = TRUE, refShape = 'mean', outline = outline_BC0077, lines = lines_BC0077, landList = landmarkList, adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077', cartoonOrder = 'under', cartoonFill= 'black', main = 'Landmark_example') summedRaster_lanK <- sumRaster(rasterList_lanK, IDlist, type = 'k') plotHeat(summedRaster_lanK, IDlist, plotCartoon = TRUE, refShape = 'mean', outline = outline_BC0077, lines = lines_BC0077, landList = landmarkList, adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077', cartoonOrder = 'under', cartoonFill= 'black', main = 'Landmark_example') plotHeat(summedRaster_lanK[[2]], IDlist, plotCartoon = TRUE, refShape = 'mean', outline = outline_BC0077, lines = lines_BC0077, landList = landmarkList, adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077', cartoonOrder = 'under', cartoonFill= 'black', main = 'Landmark_example') ## End(Not run)
data(rasterList_lanRGB) IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') outline_BC0077 <- read.table(paste(system.file("extdata", package = 'patternize'), '/BC0077_outline.txt', sep=''), header = FALSE) lines_BC0077 <- list.files(path=paste(system.file("extdata", package = 'patternize')), pattern='vein', full.names = TRUE) summedRaster_regRGB <- sumRaster(rasterList_regRGB, IDlist, type = 'RGB') data(imageList) plotHeat(summedRaster_regRGB, IDlist, plotCartoon = TRUE, refShape = 'target', outline = outline_BC0077, lines = lines_BC0077, crop = c(100,400,40,250), flipRaster = 'xy', imageList = imageList, cartoonOrder = 'under', cartoonID = 'BC0077', cartoonFill = 'black', main = 'registration_example') ## Not run: data(rasterList_lanK) IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') summedRasterList <- sumRaster(rasterList_lanK, IDlist, type = 'k') plotHeat(summedRasterList, IDlist) summedRasterList_regK <- sumRaster(rasterList_regK, IDlist, type = 'k') plotHeat(summedRasterList_regK, IDlist, plotCartoon = TRUE, refShape = 'target', outline = outline_BC0077, lines = lines_BC0077, crop = c(100,400,40,250), flipRaster = 'y', imageList = imageList, cartoonOrder = 'under', cartoonFill = 'black', main = 'kmeans_example') plotHeat(summedRasterList_regK[[1]], IDlist, plotCartoon = TRUE, refShape = 'target', outline = outline_BC0077, lines = lines_BC0077, crop = c(100,400,40,250), flipRaster = 'y', imageList = imageList, cartoonOrder = 'under', cartoonFill = 'black', main = 'kmeans_example') prepath <- system.file("extdata", package = 'patternize') extension <- '_landmarks_LFW.txt' landmarkList <- makeList(IDlist, 'landmark', prepath, extension) summedRaster_lanRGB <- sumRaster(rasterList_lanRGB, IDlist, type = 'RGB') plotHeat(summedRaster_lanRGB, IDlist, plotCartoon = TRUE, refShape = 'mean', outline = outline_BC0077, lines = lines_BC0077, landList = landmarkList, adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077', cartoonOrder = 'under', cartoonFill= 'black', main = 'Landmark_example') summedRaster_lanK <- sumRaster(rasterList_lanK, IDlist, type = 'k') plotHeat(summedRaster_lanK, IDlist, plotCartoon = TRUE, refShape = 'mean', outline = outline_BC0077, lines = lines_BC0077, landList = landmarkList, adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077', cartoonOrder = 'under', cartoonFill= 'black', main = 'Landmark_example') plotHeat(summedRaster_lanK[[2]], IDlist, plotCartoon = TRUE, refShape = 'mean', outline = outline_BC0077, lines = lines_BC0077, landList = landmarkList, adjustCoords = TRUE, imageList = imageList, cartoonID = 'BC0077', cartoonOrder = 'under', cartoonFill= 'black', main = 'Landmark_example') ## End(Not run)
Plot rasterStack as image.
plotRasterstackAsImage(rasterStack, flipY = FALSE)
plotRasterstackAsImage(rasterStack, flipY = FALSE)
rasterStack |
A single rasterStack. |
flipY |
Whether to flip the raster along the Y-axis. |
List of RasterLayers as returned by patLanK
.
rasterList_lanK
rasterList_lanK
A list of RasterLayers including the red color pattern extracted from 5 Heliconius
erato hydara dorsal forewings using patLanK
.
## Not run: data(rasterList_lanK) summary(rasterList_lanL) ## End(Not run)
## Not run: data(rasterList_lanK) summary(rasterList_lanL) ## End(Not run)
List of RasterLayers as returned by patLanRGB
.
rasterList_lanRGB
rasterList_lanRGB
A list of RasterLayers including the red color pattern extracted from 5 Heliconius
erato hydara dorsal forewings using patLanRGB
.
## Not run: data(rasterList_lanRGB) summary(rasterList_lanRGB) ## End(Not run)
## Not run: data(rasterList_lanRGB) summary(rasterList_lanRGB) ## End(Not run)
List of RasterLayers as returned by patRegK
.
rasterList_regK
rasterList_regK
A list of RasterLayers including the red color pattern extracted from 5 Heliconius
erato hydara dorsal forewings using patRegK
.
## Not run: data(rasterList_regK) summary(rasterList_regK) ## End(Not run)
## Not run: data(rasterList_regK) summary(rasterList_regK) ## End(Not run)
List of RasterLayers as returned by patRegRGB
.
rasterList_regRGB
rasterList_regRGB
A list of RasterLayers including the red color pattern extracted from 5 Heliconius
erato hydara dorsal forewings using patRegRGB
.
## Not run: data(rasterList_regRGB) summary(rasterList_regRGB) ## End(Not run)
## Not run: data(rasterList_regRGB) summary(rasterList_regRGB) ## End(Not run)
Reduce the resolution of an image imported as a RasterStack by downsampling.
redRes(image, resampleFactor)
redRes(image, resampleFactor)
image |
RasterStack for downsampling. |
resampleFactor |
Integer for downsampling. |
Downsampled RasterStack
image <- raster::stack(system.file("extdata", "BC0077.jpg", package = "patternize")) image_reduced <- redRes(image, 5)
image <- raster::stack(system.file("extdata", "BC0077.jpg", package = "patternize")) image_reduced <- redRes(image, 5)
Sample landmarks in an image.
sampleLandmarks(sampleList, resampleFactor = NULL, crop = c(0, 0, 0, 0))
sampleLandmarks(sampleList, resampleFactor = NULL, crop = c(0, 0, 0, 0))
sampleList |
RasterStack or list of RasterStack objects as obtained
by |
resampleFactor |
Integer for downsampling the image(s) used by |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image. |
landmark matrix or landmark list
## Not run: IDlist <- c('BC0077','BC0071') prepath <- system.file("extdata", package = 'patternize') extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) landmarkList <- sampleLandmarks(imageList) ## End(Not run)
## Not run: IDlist <- c('BC0077','BC0071') prepath <- system.file("extdata", package = 'patternize') extension <- '.jpg' imageList <- makeList(IDlist, 'image', prepath, extension) landmarkList <- sampleLandmarks(imageList) ## End(Not run)
Interactive function to sample RGB value from pixel or square area in an image.
sampleRGB(image, resampleFactor = NULL, crop = c(0, 0, 0, 0), type = "point")
sampleRGB(image, resampleFactor = NULL, crop = c(0, 0, 0, 0), type = "point")
image |
Image imported as a RasterStack. |
resampleFactor |
Integer for downsampling used by |
crop |
Vector c(xmin, xmax, ymin, ymax) that specifies the pixel coordinates to crop the original image. |
type |
Set 'point' to extract RGB from a single point or 'area' to extract from a square area defined by setting two points (default = 'point'). |
RGB vector
image <- raster::stack(system.file("extdata", "BC0077.jpg", package = "patternize")) RGB <- sampleRGB(image, resampleFactor = 1)
image <- raster::stack(system.file("extdata", "BC0077.jpg", package = "patternize")) RGB <- sampleRGB(image, resampleFactor = 1)
Interactive function to to draw an outline for masking.
setMask(summedRaster, IDlist, filename, ...)
setMask(summedRaster, IDlist, filename, ...)
summedRaster |
Summed raster of extracted patterns. |
IDlist |
List of sample IDs. |
filename |
Name of file to which mask will be written. |
... |
additional arguments for plotHeat function. |
file
This function sums the individual color pattern RasterLayes as obtained by the main patternize functions.
sumRaster(rList, IDlist, type)
sumRaster(rList, IDlist, type)
rList |
List of RasterLayers or list of RasterLayers for each k-means cluster. |
IDlist |
List of sample IDs. |
type |
Type of rasterlist; 'RGB' or 'k' (result from RGB or k-means analysis, respectively). |
data(rasterList_lanRGB) IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') summedRaster <- sumRaster(rasterList_lanRGB, IDlist, type = 'RGB') data(rasterList_lanK) IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') summedRasterList <- sumRaster(rasterList_lanK, IDlist, type = 'k')
data(rasterList_lanRGB) IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') summedRaster <- sumRaster(rasterList_lanRGB, IDlist, type = 'RGB') data(rasterList_lanK) IDlist <- c('BC0077','BC0071','BC0050','BC0049','BC0004') summedRasterList <- sumRaster(rasterList_lanK, IDlist, type = 'k')