MaskImage
Masks a graylevel or color image I by a binary mask B.
Access to parameter description
The output image $O$ is given by the formula:
$$ O(n,m)=\left\{\begin{array}{ll} I(n,m) & ~\mbox{if $B(n,m) = 1$}\\ 0 & ~\mbox{if $B(n,m) = 0$}\end{array}\right. $$
Remarks: The same result can be obtained by
Access to parameter description
The output image $O$ is given by the formula:
$$ O(n,m)=\left\{\begin{array}{ll} I(n,m) & ~\mbox{if $B(n,m) = 1$}\\ 0 & ~\mbox{if $B(n,m) = 0$}\end{array}\right. $$
Remarks: The same result can be obtained by
- Multiplying I by B.
- Applying a logical AND between I and a mask of same type as I for which the mask value is 1 at each bit; for example, 255 if I is an 8-bit unsigned integer image.
Function Syntax
This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > maskImage( std::shared_ptr< iolink::ImageView > inputImage, std::shared_ptr< iolink::ImageView > inputBinaryImage, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns outputImage.
// Function prototype. mask_image( input_image, input_binary_image, output_image = None )
This function returns outputImage.
// Function prototype. public static IOLink.ImageView MaskImage( IOLink.ImageView inputImage, IOLink.ImageView inputBinaryImage, IOLink.ImageView outputImage = null );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
inputImage |
The input image. | Image | Binary, Label, Grayscale or Multispectral | nullptr | |
inputBinaryImage |
The binary mask image. This image must have same dimensions as the main input image. | Image | Binary | nullptr | |
outputImage |
The output image, size and type are forced to the same values as the input. | Image | nullptr |
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
input_image |
The input image. | image | Binary, Label, Grayscale or Multispectral | None | |
input_binary_image |
The binary mask image. This image must have same dimensions as the main input image. | image | Binary | None | |
output_image |
The output image, size and type are forced to the same values as the input. | image | None |
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
inputImage |
The input image. | Image | Binary, Label, Grayscale or Multispectral | null | |
inputBinaryImage |
The binary mask image. This image must have same dimensions as the main input image. | Image | Binary | null | |
outputImage |
The output image, size and type are forced to the same values as the input. | Image | null |
Object Examples
auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" ); auto foam_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam_sep.vip" ); MaskImage maskImageAlgo; maskImageAlgo.setInputImage( foam ); maskImageAlgo.setInputBinaryImage( foam_sep ); maskImageAlgo.execute(); std::cout << "outputImage:" << maskImageAlgo.outputImage()->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip")) foam_sep = imagedev.read_vip_image(imagedev_data.get_image_path("foam_sep.vip")) mask_image_algo = imagedev.MaskImage() mask_image_algo.input_image = foam mask_image_algo.input_binary_image = foam_sep mask_image_algo.execute() print( "output_image:", str( mask_image_algo.output_image ) )
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" ); ImageView foam_sep = Data.ReadVipImage( @"Data/images/foam_sep.vip" ); MaskImage maskImageAlgo = new MaskImage { inputImage = foam, inputBinaryImage = foam_sep }; maskImageAlgo.Execute(); Console.WriteLine( "outputImage:" + maskImageAlgo.outputImage.ToString() );
Function Examples
auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" ); auto foam_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam_sep.vip" ); auto result = maskImage( foam, foam_sep ); std::cout << "outputImage:" << result->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip")) foam_sep = imagedev.read_vip_image(imagedev_data.get_image_path("foam_sep.vip")) result = imagedev.mask_image( foam, foam_sep ) print( "output_image:", str( result ) )
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" ); ImageView foam_sep = Data.ReadVipImage( @"Data/images/foam_sep.vip" ); IOLink.ImageView result = Processing.MaskImage( foam, foam_sep ); Console.WriteLine( "outputImage:" + result.ToString() );