PixelExtractor Class
Extracts the pixel values from an image.
- Inheritance
-
nimbusml.internal.core.feature_extraction.image._pixelextractor.PixelExtractorPixelExtractornimbusml.base_transform.BaseTransformPixelExtractorsklearn.base.TransformerMixinPixelExtractor
Constructor
PixelExtractor(use_alpha=False, use_red=True, use_green=True, use_blue=True, order='ARGB', interleave=False, convert=True, offset=None, scale=None, columns=None, **params)
Parameters
Name | Description |
---|---|
columns
|
a dictionary of key-value pairs, where key is the output column name and value is the input column name.
simply specify The << operator can be used to set this value (see Column Operator) For example
For more details see Columns. |
use_alpha
|
Specifies whether to use alpha channel. The default
value is |
use_red
|
Specifies whether to use red channel. The default value
is |
use_green
|
Specifies whether to use green channel. The default
value is |
use_blue
|
Specifies whether to use blue channel. The default value
is |
order
|
Order of colors. |
interleave
|
Whether to separate each channel or interleave in ARGB order. This might be important, for example, if you are training a convolutional neural network, since this would affect the shape of the kernel, stride etc. |
convert
|
Whether to convert to floating point. The default value
is |
offset
|
Specifies the offset (pre-scale). This requires |
scale
|
Specifies the scale factor. This requires |
params
|
Additional arguments sent to compute engine. |
Examples
###############################################################################
# Loader
# Resizer
# PixelExtractor
# DnnFeaturizer
# FastLinearBinaryClassifier
import numpy as np
import pandas
from nimbusml import Pipeline
from nimbusml.datasets.image import get_RevolutionAnalyticslogo, get_Microsoftlogo
from nimbusml.feature_extraction.image import Loader, Resizer, PixelExtractor
from nimbusml.linear_model import FastLinearBinaryClassifier
data = pandas.DataFrame(data=dict(
Path=[get_RevolutionAnalyticslogo(), get_Microsoftlogo()],
Label=[True, False]))
X = data[['Path']]
y = data[['Label']]
# define the training pipeline
pipeline = Pipeline([
Loader(columns={'ImgPath': 'Path'}),
Resizer(image_width=32, image_height=32,
columns={'ImgResize': 'ImgPath'}),
PixelExtractor(columns={'ImgPixels': 'ImgResize'}),
FastLinearBinaryClassifier(feature='ImgPixels')
])
# train
pipeline.fit(X, y)
# predict
scores = pipeline.predict(X)
print("Predicted Labels:", scores.PredictedLabel.values)
# Predicted Labels : [True False]
print("Accuracy:", np.mean(y.Label.values == scores.PredictedLabel.values))
# Accuracy : 1
Remarks
PixelExtractor
extracts the pixel values from an image. The input
variables
are images of the same size, typically the output of a Resizer
transform. The
output are pixel data in vector form that are typically used as
features for a learner.
Methods
get_params |
Get the parameters for this operator. |
get_params
Get the parameters for this operator.
get_params(deep=False)
Parameters
Name | Description |
---|---|
deep
|
Default value: False
|