ColorToGrayscale
Separates a color image into its three grayscale components.
Access to parameter description
For an introduction to image filters: section Color Transforms.
ColorToGrayscale extracts the three channels of a color image and output them into three grayscale output images.
See also
Access to parameter description
For an introduction to image filters: section Color Transforms.
ColorToGrayscale extracts the three channels of a color image and output them into three grayscale output images.
See also
Function Syntax
This function returns a ColorToGrayscaleOutput structure containing outputGrayImage1, outputGrayImage2 and outputGrayImage3.
// Output structure of the colorToGrayscale function. struct ColorToGrayscaleOutput { /// The first channel output image. Its spatial dimensions and type are forced to the same values as the input. std::shared_ptr< iolink::ImageView > outputGrayImage1; /// The second channel output image. Its spatial dimensions and type are forced to the same values as the input. std::shared_ptr< iolink::ImageView > outputGrayImage2; /// The third channel output image. Its spatial dimensions and type are forced to the same values as the input. std::shared_ptr< iolink::ImageView > outputGrayImage3; }; // Function prototype
ColorToGrayscaleOutput colorToGrayscale( std::shared_ptr< iolink::ImageView > inputColorImage, std::shared_ptr< iolink::ImageView > outputGrayImage1 = NULL, std::shared_ptr< iolink::ImageView > outputGrayImage2 = NULL, std::shared_ptr< iolink::ImageView > outputGrayImage3 = NULL );
This function returns a tuple containing output_gray_image1, output_gray_image2 and output_gray_image3.
// Function prototype. color_to_grayscale( input_color_image, output_gray_image1 = None, output_gray_image2 = None, output_gray_image3 = None )
This function returns a ColorToGrayscaleOutput structure containing outputGrayImage1, outputGrayImage2 and outputGrayImage3.
/// Output structure of the ColorToGrayscale function. public struct ColorToGrayscaleOutput { /// /// The first channel output image. Its spatial dimensions and type are forced to the same values as the input. /// public IOLink.ImageView outputGrayImage1; /// /// The second channel output image. Its spatial dimensions and type are forced to the same values as the input. /// public IOLink.ImageView outputGrayImage2; /// /// The third channel output image. Its spatial dimensions and type are forced to the same values as the input. /// public IOLink.ImageView outputGrayImage3; }; // Function prototype. public static ColorToGrayscaleOutput ColorToGrayscale( IOLink.ImageView inputColorImage, IOLink.ImageView outputGrayImage1 = null, IOLink.ImageView outputGrayImage2 = null, IOLink.ImageView outputGrayImage3 = null );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
![]() |
inputColorImage |
The color input image. | Image | Multispectral | nullptr |
![]() |
outputGrayImage1 |
The first channel output image. Its spatial dimensions and type are forced to the same values as the input. | Image | nullptr | |
![]() |
outputGrayImage2 |
The second channel output image. Its spatial dimensions and type are forced to the same values as the input. | Image | nullptr | |
![]() |
outputGrayImage3 |
The third channel output image. Its spatial dimensions and type are forced to the same values as the input. | Image | nullptr |
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
![]() |
input_color_image |
The color input image. | image | Multispectral | None |
![]() |
output_gray_image1 |
The first channel output image. Its spatial dimensions and type are forced to the same values as the input. | image | None | |
![]() |
output_gray_image2 |
The second channel output image. Its spatial dimensions and type are forced to the same values as the input. | image | None | |
![]() |
output_gray_image3 |
The third channel output image. Its spatial dimensions and type are forced to the same values as the input. | image | None |
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
![]() |
inputColorImage |
The color input image. | Image | Multispectral | null |
![]() |
outputGrayImage1 |
The first channel output image. Its spatial dimensions and type are forced to the same values as the input. | Image | null | |
![]() |
outputGrayImage2 |
The second channel output image. Its spatial dimensions and type are forced to the same values as the input. | Image | null | |
![]() |
outputGrayImage3 |
The third channel output image. Its spatial dimensions and type are forced to the same values as the input. | Image | null |
Object Examples
std::shared_ptr< iolink::ImageView > ateneub = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "ateneub.jpg" ); ColorToGrayscale colorToGrayscaleAlgo; colorToGrayscaleAlgo.setInputColorImage( ateneub ); colorToGrayscaleAlgo.execute(); std::cout << "outputGrayImage1:" << colorToGrayscaleAlgo.outputGrayImage1()->toString(); std::cout << "outputGrayImage2:" << colorToGrayscaleAlgo.outputGrayImage2()->toString(); std::cout << "outputGrayImage3:" << colorToGrayscaleAlgo.outputGrayImage3()->toString();
ateneub = ioformat.read_image(imagedev_data.get_image_path("ateneub.jpg")) color_to_grayscale_algo = imagedev.ColorToGrayscale() color_to_grayscale_algo.input_color_image = ateneub color_to_grayscale_algo.execute() print( "output_gray_image1:", str( color_to_grayscale_algo.output_gray_image1 ) ) print( "output_gray_image2:", str( color_to_grayscale_algo.output_gray_image2 ) ) print( "output_gray_image3:", str( color_to_grayscale_algo.output_gray_image3 ) )
ImageView ateneub = ViewIO.ReadImage( @"Data/images/ateneub.jpg" ); ColorToGrayscale colorToGrayscaleAlgo = new ColorToGrayscale { inputColorImage = ateneub }; colorToGrayscaleAlgo.Execute(); Console.WriteLine( "outputGrayImage1:" + colorToGrayscaleAlgo.outputGrayImage1.ToString() ); Console.WriteLine( "outputGrayImage2:" + colorToGrayscaleAlgo.outputGrayImage2.ToString() ); Console.WriteLine( "outputGrayImage3:" + colorToGrayscaleAlgo.outputGrayImage3.ToString() );
Function Examples
std::shared_ptr< iolink::ImageView > ateneub = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "ateneub.jpg" ); auto result = colorToGrayscale( ateneub ); std::cout << "outputGrayImage1:" << result.outputGrayImage1->toString(); std::cout << "outputGrayImage2:" << result.outputGrayImage2->toString(); std::cout << "outputGrayImage3:" << result.outputGrayImage3->toString();
ateneub = ioformat.read_image(imagedev_data.get_image_path("ateneub.jpg")) result_output_gray_image1, result_output_gray_image2, result_output_gray_image3 = imagedev.color_to_grayscale( ateneub ) print( "output_gray_image1:", str( result_output_gray_image1 ) ) print( "output_gray_image2:", str( result_output_gray_image2 ) ) print( "output_gray_image3:", str( result_output_gray_image3 ) )
ImageView ateneub = ViewIO.ReadImage( @"Data/images/ateneub.jpg" ); Processing.ColorToGrayscaleOutput result = Processing.ColorToGrayscale( ateneub ); Console.WriteLine( "outputGrayImage1:" + result.outputGrayImage1.ToString() ); Console.WriteLine( "outputGrayImage2:" + result.outputGrayImage2.ToString() ); Console.WriteLine( "outputGrayImage3:" + result.outputGrayImage3.ToString() );