從影像中擷取像素值。
使用方式
extractPixels(vars, useAlpha = FALSE, useRed = TRUE, useGreen = TRUE,
useBlue = TRUE, interleaveARGB = FALSE, convert = TRUE, offset = NULL,
scale = NULL)
引數
vars
輸入變數名稱和輸出變數名稱的字元向量具名清單。 請注意,輸入變數必須為相同類型。 對於輸入與輸出變數之間的一對一對應,可以使用具名字元向量。
useAlpha
指定是否要使用 Alpha 色板。 預設值是 FALSE。
useRed
指定是否要使用紅色色板。 預設值是 TRUE。
useGreen
指定是否要使用綠色色板。 預設值是 TRUE。
useBlue
指定是否要使用藍色色板。 預設值是 TRUE。
interleaveARGB
是要分隔每個色板還是按 ARGB 順序交錯。 這可能有其重要性,例如,在定型卷積神經網路時就是如此,因為這可能會影響核心的形狀、步幅等。
convert
是否要轉換成浮點數。 預設值是 FALSE。
offset
指定位移 (預先調整)。 這需要 convert = TRUE。 預設值是 NULL。
scale
指定縮放比例。 這需要 convert = TRUE。 預設值是 NULL。
詳細資料
extractPixels 會從影像中擷取像素值。 輸入變數是相同大小的影像,通常是 resizeImage 轉換的輸出。 輸出是向量形式的像素資料,通常用來作為學習模組的特徵。
值
定義轉換的 maml 物件。
作者
Microsoft Corporation Microsoft Technical Support
範例
train <- data.frame(Path = c(system.file("help/figures/RevolutionAnalyticslogo.png", package = "MicrosoftML")), Label = c(TRUE), stringsAsFactors = FALSE)
# Loads the images from variable Path, resizes the images to 1x1 pixels and trains a neural net.
model <- rxNeuralNet(
Label ~ Features,
data = train,
mlTransforms = list(
loadImage(vars = list(Features = "Path")),
resizeImage(vars = "Features", width = 1, height = 1, resizing = "Aniso"),
extractPixels(vars = "Features")
),
mlTransformVars = "Path",
numHiddenNodes = 1,
numIterations = 1)
# Featurizes the images from variable Path using the default model, and trains a linear model on the result.
model <- rxFastLinear(
Label ~ Features,
data = train,
mlTransforms = list(
loadImage(vars = list(Features = "Path")),
resizeImage(vars = "Features", width = 224, height = 224), # If dnnModel == "AlexNet", the image has to be resized to 227x227.
extractPixels(vars = "Features"),
featurizeImage(var = "Features")
),
mlTransformVars = "Path")