ImageDev

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 See also

Function Syntax

This function returns the outputImage output parameter.
// 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 the outputImage output parameter.
// Function prototype.
mask_image( input_image, input_binary_image, output_image = None )
This function returns the outputImage output parameter.
// Function prototype.
public static IOLink.ImageView
MaskImage( IOLink.ImageView inputImage,
           IOLink.ImageView inputBinaryImage,
           IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Class Name MaskImage

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
inputBinaryImage
The binary mask image. This image must have same dimensions as the main input image. Image Binary nullptr
output
outputImage
The output image, size and type are forced to the same values as the input. Image nullptr

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() );