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)={I(n,m) if B(n,m)=10 if B(n,m)=0
Remarks: The same result can be obtained by
Access to parameter description
The output image O is given by the formula:
O(n,m)={I(n,m) if B(n,m)=10 if B(n,m)=0
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 );
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 |
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();
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();