Example #1
0
 /// <include file='doc.xml' path='doc/members/member[@name="ImagePixelExtractingEstimator"]/*' />
 /// <param name="catalog"> The transform's catalog.</param>
 /// <param name="outputColumnName"> Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
 /// <param name="inputColumnName"> Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
 /// <param name="colors"> Specifies which <see cref="ImagePixelExtractingEstimator.ColorBits"/> to extract from the image. The order of colors is: Alpha, Red, Green Blue.</param>
 /// <param name="interleave">Wheather to interleave the pixels, meaning keep them in the `ARGB ARGB` order, or leave them separated in the planar form, where the colors are outputed one by one
 /// alpha, red, green, blue for all the pixels of the image. </param>
 /// <param name="scale">Scale color pixel value by this amount.</param>
 /// <param name="offset">Offset color pixel value by this amount.</param>
 /// <param name="asFloat">Output the array as float array. If false, output as byte array.</param>
 /// <example>
 /// <format type="text/markdown">
 /// <![CDATA[
 ///  [!code-csharp[ExtractPixels](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/ImageAnalytics/ExtractPixels.cs)]
 /// ]]></format>
 /// </example>
 public static ImagePixelExtractingEstimator ExtractPixels(this TransformsCatalog catalog,
                                                           string outputColumnName,
                                                           string inputColumnName = null,
                                                           ImagePixelExtractingEstimator.ColorBits colors = ImagePixelExtractingEstimator.ColorBits.Rgb,
                                                           bool interleave = false,
                                                           float scale     = ImagePixelExtractingTransformer.Defaults.Scale,
                                                           float offset    = ImagePixelExtractingTransformer.Defaults.Offset,
                                                           bool asFloat    = ImagePixelExtractingTransformer.Defaults.Convert)
 => new ImagePixelExtractingEstimator(CatalogUtils.GetEnvironment(catalog), outputColumnName, inputColumnName, colors, interleave, scale, offset, asFloat);
 /// <include file='doc.xml' path='doc/members/member[@name="ImagePixelExtractingEstimator"]/*' />
 /// <param name="catalog">The transform's catalog.</param>
 /// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
 /// <param name="inputColumnName">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
 /// <param name="colorsToExtract">The colors to extract from the image.</param>
 /// <param name="orderOfExtraction">The order in which to extract colors from pixel.</param>
 /// <param name="interleavePixelColors">Whether to interleave the pixels colors, meaning keep them in the <paramref name="orderOfExtraction"/> order, or leave them in the plannar form:
 /// all the values for one color for all pixels, then all the values for another color, and so on.</param>
 /// <param name="offsetImage">Offset each pixel's color value by this amount. Applied to color value before <paramref name="scaleImage"/>.</param>
 /// <param name="scaleImage">Scale each pixel's color value by this amount. Applied to color value after <paramref name="offsetImage"/>.</param>
 /// <param name="outputAsFloatArray">Output array as float array. If false, output as byte array and ignores <paramref name="offsetImage"/> and <paramref name="scaleImage"/>.</param>
 /// <example>
 /// <format type="text/markdown">
 /// <![CDATA[
 ///  [!code-csharp[ExtractPixels](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/ImageAnalytics/ExtractPixels.cs)]
 /// ]]></format>
 /// </example>
 public static ImagePixelExtractingEstimator ExtractPixels(this TransformsCatalog catalog,
                                                           string outputColumnName,
                                                           string inputColumnName = null,
                                                           ImagePixelExtractingEstimator.ColorBits colorsToExtract     = ImagePixelExtractingEstimator.Defaults.Colors,
                                                           ImagePixelExtractingEstimator.ColorsOrder orderOfExtraction = ImagePixelExtractingEstimator.Defaults.Order,
                                                           bool interleavePixelColors = false,
                                                           float offsetImage          = ImagePixelExtractingEstimator.Defaults.Offset,
                                                           float scaleImage           = ImagePixelExtractingEstimator.Defaults.Scale,
                                                           bool outputAsFloatArray    = ImagePixelExtractingEstimator.Defaults.Convert)
 => new ImagePixelExtractingEstimator(CatalogUtils.GetEnvironment(catalog), outputColumnName, inputColumnName, colorsToExtract, orderOfExtraction, interleavePixelColors, offsetImage, scaleImage, outputAsFloatArray);
 /// <summary>
 /// Converts vectors of pixels into <see cref="ImageType"/> representation.
 /// </summary>
 /// <param name="catalog">The transforms' catalog.</param>
 /// <param name="imageHeight">The height of the output images.</param>
 /// <param name="imageWidth">The width of the output images.</param>
 /// <param name="outputColumnName"> Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
 /// <param name="inputColumnName"> Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
 /// <param name="colorsPresent">Specifies which <see cref="ImagePixelExtractingEstimator.ColorBits"/> are in present the input pixel vectors. The order of colors is specified in <paramref name="orderOfColors"/>.</param>
 /// <param name="orderOfColors">The order in which colors are presented in the input vector.</param>
 /// <param name="interleavedColors">Whether the pixels are interleaved, meaning whether they are in <paramref name="orderOfColors"/> order, or separated in the planar form:
 /// all the values for one color for all pixels, then all the values for another color and so on.</param>
 /// <param name="scaleImage">The values are scaled by this value before being converted to pixels. Applied to vector value before <paramref name="offsetImage"/>.</param>
 /// <param name="offsetImage">The offset is subtracted before converting the values to pixels. Applied to vector value after <paramref name="scaleImage"/>.</param>
 /// <param name="defaultAlpha">Default value for alpha color, would be overriden if <paramref name="colorsPresent"/> contains <see cref="ImagePixelExtractingEstimator.ColorBits.Alpha"/>.</param>
 /// <param name="defaultRed">Default value for red color, would be overriden if <paramref name="colorsPresent"/> contains <see cref="ImagePixelExtractingEstimator.ColorBits.Red"/>.</param>
 /// <param name="defaultGreen">Default value for grenn color, would be overriden if <paramref name="colorsPresent"/> contains <see cref="ImagePixelExtractingEstimator.ColorBits.Green"/>.</param>
 /// <param name="defaultBlue">Default value for blue color, would be overriden if <paramref name="colorsPresent"/> contains <see cref="ImagePixelExtractingEstimator.ColorBits.Blue"/>.</param>
 public static VectorToImageConvertingEstimator ConvertToImage(this TransformsCatalog catalog, int imageHeight, int imageWidth, string outputColumnName, string inputColumnName = null,
                                                               ImagePixelExtractingEstimator.ColorBits colorsPresent   = ImagePixelExtractingEstimator.Defaults.Colors,
                                                               ImagePixelExtractingEstimator.ColorsOrder orderOfColors = ImagePixelExtractingEstimator.Defaults.Order,
                                                               bool interleavedColors = ImagePixelExtractingEstimator.Defaults.Interleave,
                                                               float scaleImage       = VectorToImageConvertingEstimator.Defaults.Scale,
                                                               float offsetImage      = VectorToImageConvertingEstimator.Defaults.Offset,
                                                               int defaultAlpha       = VectorToImageConvertingEstimator.Defaults.DefaultAlpha,
                                                               int defaultRed         = VectorToImageConvertingEstimator.Defaults.DefaultRed,
                                                               int defaultGreen       = VectorToImageConvertingEstimator.Defaults.DefaultGreen,
                                                               int defaultBlue        = VectorToImageConvertingEstimator.Defaults.DefaultBlue)
 => new VectorToImageConvertingEstimator(CatalogUtils.GetEnvironment(catalog), imageHeight, imageWidth, outputColumnName, inputColumnName, colorsPresent, orderOfColors, interleavedColors, scaleImage, offsetImage);
Example #4
0
 ///<summary>
 /// Extract pixels values from image and produce array of values.
 ///</summary>
 /// <param name="env">The host environment.</param>
 /// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
 /// <param name="inputColumnName">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
 /// <param name="colors">What colors to extract.</param>
 /// <param name="interleave"></param>
 /// <param name="scale">Scale color pixel value by this amount.</param>
 /// <param name="offset">Offset color pixel value by this amount.</param>
 /// <param name="asFloat">Output array as float array. If false, output as byte array.</param>
 internal ImagePixelExtractingTransformer(IHostEnvironment env,
                                          string outputColumnName,
                                          string inputColumnName = null,
                                          ImagePixelExtractingEstimator.ColorBits colors = ImagePixelExtractingEstimator.ColorBits.Rgb,
                                          bool interleave = Defaults.Interleave,
                                          float scale     = Defaults.Scale,
                                          float offset    = Defaults.Offset,
                                          bool asFloat    = Defaults.Convert)
     : this(env, new ImagePixelExtractingEstimator.ColumnInfo(outputColumnName, inputColumnName, colors, interleave, scale, offset, asFloat))
 {
 }
 ///<summary>
 /// Extract pixels values from image and produce array of values.
 ///</summary>
 /// <param name="env">The host environment.</param>
 /// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
 /// <param name="inputColumnName">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
 /// <param name="colorsToExtract">What colors to extract.</param>
 /// <param name="orderOfExtraction">In which order to extract colors from pixel.</param>
 /// <param name="interleavePixelColors">Whether to interleave the pixels colors, meaning keep them in the <paramref name="orderOfExtraction"/> order, or leave them in the plannar form:
 /// all the values for one color for all pixels, then all the values for another color and so on.</param>
 /// <param name="offsetImage">Offset each pixel's color value by this amount. Applied to color value first.</param>
 /// <param name="scaleImage">Scale each pixel's color value by this amount. Applied to color value second.</param>
 /// <param name="outputAsFloatArray">Output array as float array. If false, output as byte array and ignores <paramref name="offsetImage"/> and <paramref name="scaleImage"/>.</param>
 internal ImagePixelExtractingTransformer(IHostEnvironment env,
                                          string outputColumnName,
                                          string inputColumnName = null,
                                          ImagePixelExtractingEstimator.ColorBits colorsToExtract     = ImagePixelExtractingEstimator.Defaults.Colors,
                                          ImagePixelExtractingEstimator.ColorsOrder orderOfExtraction = ImagePixelExtractingEstimator.Defaults.Order,
                                          bool interleavePixelColors = ImagePixelExtractingEstimator.Defaults.Interleave,
                                          float offsetImage          = ImagePixelExtractingEstimator.Defaults.Offset,
                                          float scaleImage           = ImagePixelExtractingEstimator.Defaults.Scale,
                                          bool outputAsFloatArray    = ImagePixelExtractingEstimator.Defaults.Convert)
     : this(env, new ImagePixelExtractingEstimator.ColumnOptions(outputColumnName, inputColumnName, colorsToExtract, orderOfExtraction, interleavePixelColors, offsetImage, scaleImage, outputAsFloatArray))
 {
 }
Example #6
0
 /// <param name="env">The host environment.</param>
 /// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
 /// <param name="imageHeight">The height of the output images.</param>
 /// <param name="imageWidth">The width of the output images.</param>
 /// <param name="inputColumnName">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
 /// <param name="colorsPresent">Specifies which <see cref="ImagePixelExtractingEstimator.ColorBits"/> are in present the input pixel vectors. The order of colors is specified in <paramref name="orderOfColors"/>.</param>
 /// <param name="orderOfColors">The order in which colors are presented in the input vector.</param>
 /// <param name="interleavedColors">Whether the pixels are interleaved, meaning whether they are in <paramref name="orderOfColors"/> order, or separated in the planar form, where the colors are specified one by one
 /// for all the pixels of the image. </param>
 /// <param name="scaleImage">Scale each pixel's color value by this amount.</param>
 /// <param name="offsetImage">Offset each pixel's color value by this amount.</param>
 /// <param name="defaultAlpha">Default value for alpha color, would be overriden if <paramref name="colorsPresent"/> contains <see cref="ImagePixelExtractingEstimator.ColorBits.Alpha"/>.</param>
 /// <param name="defaultRed">Default value for red color, would be overriden if <paramref name="colorsPresent"/> contains <see cref="ImagePixelExtractingEstimator.ColorBits.Red"/>.</param>
 /// <param name="defaultGreen">Default value for grenn color, would be overriden if <paramref name="colorsPresent"/> contains <see cref="ImagePixelExtractingEstimator.ColorBits.Green"/>.</param>
 /// <param name="defaultBlue">Default value for blue color, would be overriden if <paramref name="colorsPresent"/> contains <see cref="ImagePixelExtractingEstimator.ColorBits.Blue"/>.</param>
 internal VectorToImageConvertingTransformer(IHostEnvironment env, string outputColumnName,
                                             int imageHeight, int imageWidth,
                                             string inputColumnName = null,
                                             ImagePixelExtractingEstimator.ColorBits colorsPresent   = ImagePixelExtractingEstimator.Defaults.Colors,
                                             ImagePixelExtractingEstimator.ColorsOrder orderOfColors = ImagePixelExtractingEstimator.Defaults.Order,
                                             bool interleavedColors = ImagePixelExtractingEstimator.Defaults.Interleave,
                                             float scaleImage       = VectorToImageConvertingEstimator.Defaults.Scale,
                                             float offsetImage      = VectorToImageConvertingEstimator.Defaults.Offset,
                                             int defaultAlpha       = VectorToImageConvertingEstimator.Defaults.DefaultAlpha,
                                             int defaultRed         = VectorToImageConvertingEstimator.Defaults.DefaultRed,
                                             int defaultGreen       = VectorToImageConvertingEstimator.Defaults.DefaultGreen,
                                             int defaultBlue        = VectorToImageConvertingEstimator.Defaults.DefaultBlue)
     : this(env, new VectorToImageConvertingEstimator.ColumnOptions(outputColumnName, imageHeight, imageWidth, inputColumnName, colorsPresent, orderOfColors, interleavedColors, scaleImage, offsetImage, defaultAlpha, defaultRed, defaultGreen, defaultBlue))
 {
 }
 /// <param name="env">The host environment.</param>
 /// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
 /// <param name="height">The height of the output images.</param>
 /// <param name="width">The width of the output images.</param>
 /// <param name="inputColumnName">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
 /// <param name="colors">What colors to extract.</param>
 /// <param name="order">In which order extracted colors presented in array.</param>
 /// <param name="interleave">Whether the pixels are interleaved, meaning whether they are in <paramref name="order"/> order, or separated in the planar form, where the colors are specified one by one
 /// for all the pixels of the image. </param>
 /// <param name="scale">Scale color pixel value by this amount.</param>
 /// <param name="offset">Offset color pixel value by this amount.</param>
 /// <param name="defaultAlpha">Default value for alpha color, would be overriden if <paramref name="colors"/> contains <see cref="ImagePixelExtractingEstimator.ColorBits.Alpha"/>.</param>
 /// <param name="defaultRed">Default value for red color, would be overriden if <paramref name="colors"/> contains <see cref="ImagePixelExtractingEstimator.ColorBits.Red"/>.</param>
 /// <param name="defaultGreen">Default value for grenn color, would be overriden if <paramref name="colors"/> contains <see cref="ImagePixelExtractingEstimator.ColorBits.Green"/>.</param>
 /// <param name="defaultBlue">Default value for blue color, would be overriden if <paramref name="colors"/> contains <see cref="ImagePixelExtractingEstimator.ColorBits.Blue"/>.</param>
 internal VectorToImageConvertingTransformer(IHostEnvironment env, string outputColumnName,
                                             int height, int width,
                                             string inputColumnName = null,
                                             ImagePixelExtractingEstimator.ColorBits colors  = ImagePixelExtractingEstimator.Defaults.Colors,
                                             ImagePixelExtractingEstimator.ColorsOrder order = ImagePixelExtractingEstimator.Defaults.Order,
                                             bool interleave  = ImagePixelExtractingEstimator.Defaults.Interleave,
                                             float scale      = VectorToImageConvertingEstimator.Defaults.Scale,
                                             float offset     = VectorToImageConvertingEstimator.Defaults.Offset,
                                             int defaultAlpha = VectorToImageConvertingEstimator.Defaults.DefaultAlpha,
                                             int defaultRed   = VectorToImageConvertingEstimator.Defaults.DefaultRed,
                                             int defaultGreen = VectorToImageConvertingEstimator.Defaults.DefaultGreen,
                                             int defaultBlue  = VectorToImageConvertingEstimator.Defaults.DefaultBlue)
     : this(env, new VectorToImageConvertingEstimator.ColumnInfo(outputColumnName, height, width, inputColumnName, colors, order, interleave, scale, offset, defaultAlpha, defaultRed, defaultGreen, defaultBlue))
 {
 }
Example #8
0
 /// <summary>
 /// Converts vectors of pixels into <see cref="ImageType"/> representation.
 /// </summary>
 /// <param name="catalog">The transforms' catalog.</param>
 /// <param name="height">The height of the output images.</param>
 /// <param name="width">The width of the output images.</param>
 /// <param name="outputColumnName"> Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
 /// <param name="inputColumnName"> Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
 /// <param name="colors"> Specifies which <see cref="ImagePixelExtractingEstimator.ColorBits"/> are in the input pixel vectors. The order of colors is: Alpha, Red, Green Blue.</param>
 /// <param name="interleave">Whether the pixels are interleaved, meaning whether they are in `ARGB ARGB` order, or separated in the planar form, where the colors are specified one by one
 /// alpha, red, green, blue for all the pixels of the image. </param>
 /// <param name="scale">The values are scaled by this value before being converted to pixels.</param>
 /// <param name="offset">The offset is subtracted (before scaling) before converting the values to pixels.</param>
 public static VectorToImageConvertingEstimator ConvertToImage(this TransformsCatalog catalog, int height, int width, string outputColumnName, string inputColumnName = null,
                                                               ImagePixelExtractingEstimator.ColorBits colors = VectorToImageConvertingTransformer.Defaults.Colors,
                                                               bool interleave = VectorToImageConvertingTransformer.Defaults.InterleaveArgb,
                                                               float scale     = VectorToImageConvertingTransformer.Defaults.Scale,
                                                               float offset    = VectorToImageConvertingTransformer.Defaults.Offset)
 => new VectorToImageConvertingEstimator(CatalogUtils.GetEnvironment(catalog), height, width, outputColumnName, inputColumnName, colors, interleave, scale, offset);
 internal VectorToImageConvertingTransformer(IHostEnvironment env, string outputColumnName, string inputColumnName, int imageHeight, int imageWidth, ImagePixelExtractingEstimator.ColorBits colors, bool interleave, float scale, float offset)
     : this(env, new VectorToImageConvertingEstimator.ColumnInfo(outputColumnName, inputColumnName, imageHeight, imageWidth, colors, interleave, scale, offset))
 {
 }