ImageDev

LogicalOperationWithImage

Performs a pointwise logical operation between two images.

Access to parameter description

The logical operators to apply between both input images $I1$ and $I2$ can be selected between: More information about logical operations are available in the Logical Operations group presentation.

See also

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > logicalOperationWithImage( std::shared_ptr< iolink::ImageView > inputImage1, std::shared_ptr< iolink::ImageView > inputImage2, LogicalOperationWithImage::LogicalOperator logicalOperator, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns outputImage.
// Function prototype.
logical_operation_with_image( input_image1,
                              input_image2,
                              logical_operator = LogicalOperationWithImage.LogicalOperator.AND,
                              output_image = None )
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
LogicalOperationWithImage( IOLink.ImageView inputImage1,
                           IOLink.ImageView inputImage2,
                           LogicalOperationWithImage.LogicalOperator logicalOperator = ImageDev.LogicalOperationWithImage.LogicalOperator.AND,
                           IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Class Name LogicalOperationWithImage

Parameter Name Description Type Supported Values Default Value
input
inputImage1
The first input image, must be integer, including grayscale, binary, label, and color. Image Binary, Label, Grayscale or Multispectral nullptr
input
inputImage2
The second input image, must have same dimensions and type as the first input. Image Binary, Label, Grayscale or Multispectral nullptr
input
logicalOperator
The operator to apply.
AND The logical AND operator performs a bitwise conjunction between two images. On two binary images $I_1$ and $I_2$, it is equivalent to a $Minimum$ operation, or to the intersection of two sets, as it appears in the truth table and the following figure. $$ \begin{array}{|c|c|c|} \hline I_1 & I_2 & I_1 \wedge I_2\\ \hline 1 & 1 & 1\\ 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 0\\ \hline \end{array} $$
Intersection of two sets A and B illustrating the logical AND operator
Intersection of two sets A and B illustrating the logical AND operator
OR The logical OR operator performs a bitwise disjunction between two images. On two binary images $I_1$ and $I_2$, it is equivalent to a $Maximum$ operation, or to the union of two sets, as it appears in the truth table and the following figure. $$ \begin{array}{|c|c|c|} \hline I_1 & I_2 & I_1 \vee I_2\\ \hline 1 & 1 & 1\\ 1 & 0 & 1\\ 0 & 1 & 1\\ 0 & 0 & 0\\ \hline \end{array} $$
Union of two sets A and B illustrating the logical OR operator
Union of two sets A and B illustrating the logical OR operator
XOR The logical XOR operator performs a bitwise exclusive disjunction between two images. On two binary images $I_1$ and $I_2$, the logical XOR is described by the truth table and the following figure. $$ \begin{array}{|c|c|c|} \hline I_1 & I_2 & I_1 \veebar I_2\\ \hline 1 & 1 & 0\\ 1 & 0 & 1\\ 0 & 1 & 1\\ 0 & 0 & 0\\ \hline \end{array} $$
Illustration of the logical XOR operation on two sets A and B
Illustration of the logical XOR operation on two sets A and B
NAND The logical NAND operator performs a bitwise alternative denial between two images. On two binary images $I_1$ and $I_2$, the logical NAND operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I_1 & I_2 & I_1 \uparrow I_2\\ \hline 1 & 1 & 0\\ 1 & 0 & 1\\ 0 & 1 & 1\\ 0 & 0 & 1\\ \hline \end{array} $$
NOR The logical NOR operator performs a bitwise joint denial between two images. On two binary images $I_1$ and $I_2$, the logical NOR operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I_1 & I_2 & I_1 \downarrow I_2\\ \hline 1 & 1 & 0\\ 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\\ \hline \end{array} $$
NXOR The logical NXOR operator performs a bitwise equivalence (or logical biconditional) between two images. It is the negation of the exclusive OR between two images $I_1$ and $I_2$. The logical equivalence between two binary sets $I_1$ and $I_2$ is described by the truth table and the following figure. $$ \begin{array}{|c|c|c|} \hline I_1 & I_2 & I_1 \equiv I_2\\ \hline 1 & 1 & 1\\ 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\\ \hline \end{array} $$
Illustration of the logical NXOR operation on two sets A and B
Illustration of the logical NXOR operation on two sets A and B
SUBTRACT The logical SUBTRACT operator performs a bitwise logical difference between two images. On two binary images $I_1$ and $I_2$, the logical SUBTRACT operator is described by the truth table and the following figure. $$ \begin{array}{|c|c|c|} \hline I_1 & I_2 & I_1 - I_2\\ \hline 1 & 1 & 0\\ 1 & 0 & 1\\ 0 & 1 & 0\\ 0 & 0 & 0\\ \hline \end{array} $$
Illustration of the logical SUB operation on two sets A and B
Illustration of the logical SUB operation on two sets A and B
Remark: the logical difference is the only non commutative logical operation, i.e., $A-B\neq B-A$.
Enumeration AND
output
outputImage
The output image, size and type are forced to the same values as the inputs. Image nullptr

Object Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

LogicalOperationWithImage logicalOperationWithImageAlgo;
logicalOperationWithImageAlgo.setInputImage1( polystyrene );
logicalOperationWithImageAlgo.setInputImage2( polystyrene );
logicalOperationWithImageAlgo.setLogicalOperator( LogicalOperationWithImage::LogicalOperator::AND );
logicalOperationWithImageAlgo.execute();

std::cout << "outputImage:" << logicalOperationWithImageAlgo.outputImage()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

logical_operation_with_image_algo = imagedev.LogicalOperationWithImage()
logical_operation_with_image_algo.input_image1 = polystyrene
logical_operation_with_image_algo.input_image2 = polystyrene
logical_operation_with_image_algo.logical_operator = imagedev.LogicalOperationWithImage.AND
logical_operation_with_image_algo.execute()

print( "output_image:", str( logical_operation_with_image_algo.output_image ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

LogicalOperationWithImage logicalOperationWithImageAlgo = new LogicalOperationWithImage
{
    inputImage1 = polystyrene,
    inputImage2 = polystyrene,
    logicalOperator = LogicalOperationWithImage.LogicalOperator.AND
};
logicalOperationWithImageAlgo.Execute();

Console.WriteLine( "outputImage:" + logicalOperationWithImageAlgo.outputImage.ToString() );

Function Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = logicalOperationWithImage( polystyrene, polystyrene, LogicalOperationWithImage::LogicalOperator::AND );

std::cout << "outputImage:" << result->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

result = imagedev.logical_operation_with_image( polystyrene, polystyrene, imagedev.LogicalOperationWithImage.AND )

print( "output_image:", str( result ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

IOLink.ImageView result = Processing.LogicalOperationWithImage( polystyrene, polystyrene, LogicalOperationWithImage.LogicalOperator.AND );

Console.WriteLine( "outputImage:" + result.ToString() );