ImageDev

LogicalOperationWithValue

Performs a pointwise logical operation between an image and a value.

Access to parameter description

The logical operators to apply between the input images $I$ and the constant value $C$ can be selected from: 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 > logicalOperationWithValue( std::shared_ptr< iolink::ImageView > inputImage, uint32_t value, LogicalOperationWithValue::LogicalOperator logicalOperator, std::shared_ptr< iolink::ImageView > outputImage = nullptr );
This function returns outputImage.
// Function prototype.
logical_operation_with_value(input_image: idt.ImageType,
                             value: int = 0,
                             logical_operator: LogicalOperationWithValue.LogicalOperator = LogicalOperationWithValue.LogicalOperator.AND,
                             output_image: idt.ImageType = None) -> idt.ImageType
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
LogicalOperationWithValue( IOLink.ImageView inputImage,
                           UInt32 value = 0,
                           LogicalOperationWithValue.LogicalOperator logicalOperator = ImageDev.LogicalOperationWithValue.LogicalOperator.AND,
                           IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image, must be integer, including grayscale, binary, label, and color. Image Binary, Label, Grayscale or Multispectral nullptr
input
value
The value to apply, cast to the type of the input image. UInt32 Any value 0
input
logicalOperator
The logical operator to apply. Default is AND.
AND The logical AND operator performs a bitwise conjunction between an image and a constant value. On a binary image, it is equivalent to a $Minimum$ operation, as it appears in the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \wedge C\\ \hline 1 & 1 & 1\\ 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 0\\ \hline \end{array} $$
OR The logical OR operator performs a bitwise disjunction between an image and a constant value. On a binary image $I$, it is equivalent to a $Maximum$ operation as it appears in the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \vee C\\ \hline 1 & 1 & 1\\ 1 & 0 & 1\\ 0 & 1 & 1\\ 0 & 0 & 0\\ \hline \end{array} $$
XOR The logical XOR operator performs a bitwise exclusive disjunction between an image and a constant value. On a binary image $I$ and a constant value $C$, the logical XOR operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \veebar C\\ \hline 1 & 1 & 0\\ 1 & 0 & 1\\ 0 & 1 & 1\\ 0 & 0 & 0\\ \hline \end{array} $$
NAND The logical NAND operator performs a bitwise alternative denial between an image and a constant value. On a binary image $I$ and a constant value $C$, the logical NAND operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \uparrow C\\ \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 an image and a constant value. On a binary image $I$ and a constant value $C$, the logical NOR operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \downarrow C\\ \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 an image and a constant value. It is the negation of the exclusive OR between an image $I$ and a constant value $C$ as described by the truth table and the following figure. $$ \begin{array}{|c|c|c|} \hline I & C & I \equiv C\\ \hline 1 & 1 & 1\\ 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\\ \hline \end{array} $$
SUBTRACT The logical SUBTRACT operator performs a bitwise logical difference between an image and a constant value. On a binary image $I$ and a constant value $C$, the logical SUBTRACT operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I - C\\ \hline 1 & 1 & 0\\ 1 & 0 & 1\\ 0 & 1 & 0\\ 0 & 0 & 0\\ \hline \end{array} $$ Remark: the logical difference is the only non commutative logical operation; for instance, $I-C\neq C-I$.
Enumeration AND
output
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
input_image
The input image, must be integer, including grayscale, binary, label, and color. image Binary, Label, Grayscale or Multispectral None
input
value
The value to apply, cast to the type of the input image. uint32 Any value 0
input
logical_operator
The logical operator to apply. Default is AND.
AND The logical AND operator performs a bitwise conjunction between an image and a constant value. On a binary image, it is equivalent to a $Minimum$ operation, as it appears in the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \wedge C\\ \hline 1 & 1 & 1\\ 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 0\\ \hline \end{array} $$
OR The logical OR operator performs a bitwise disjunction between an image and a constant value. On a binary image $I$, it is equivalent to a $Maximum$ operation as it appears in the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \vee C\\ \hline 1 & 1 & 1\\ 1 & 0 & 1\\ 0 & 1 & 1\\ 0 & 0 & 0\\ \hline \end{array} $$
XOR The logical XOR operator performs a bitwise exclusive disjunction between an image and a constant value. On a binary image $I$ and a constant value $C$, the logical XOR operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \veebar C\\ \hline 1 & 1 & 0\\ 1 & 0 & 1\\ 0 & 1 & 1\\ 0 & 0 & 0\\ \hline \end{array} $$
NAND The logical NAND operator performs a bitwise alternative denial between an image and a constant value. On a binary image $I$ and a constant value $C$, the logical NAND operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \uparrow C\\ \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 an image and a constant value. On a binary image $I$ and a constant value $C$, the logical NOR operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \downarrow C\\ \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 an image and a constant value. It is the negation of the exclusive OR between an image $I$ and a constant value $C$ as described by the truth table and the following figure. $$ \begin{array}{|c|c|c|} \hline I & C & I \equiv C\\ \hline 1 & 1 & 1\\ 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\\ \hline \end{array} $$
SUBTRACT The logical SUBTRACT operator performs a bitwise logical difference between an image and a constant value. On a binary image $I$ and a constant value $C$, the logical SUBTRACT operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I - C\\ \hline 1 & 1 & 0\\ 1 & 0 & 1\\ 0 & 1 & 0\\ 0 & 0 & 0\\ \hline \end{array} $$ Remark: the logical difference is the only non commutative logical operation; for instance, $I-C\neq C-I$.
enumeration AND
output
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
input
inputImage
The input image, must be integer, including grayscale, binary, label, and color. Image Binary, Label, Grayscale or Multispectral null
input
value
The value to apply, cast to the type of the input image. UInt32 Any value 0
input
logicalOperator
The logical operator to apply. Default is AND.
AND The logical AND operator performs a bitwise conjunction between an image and a constant value. On a binary image, it is equivalent to a $Minimum$ operation, as it appears in the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \wedge C\\ \hline 1 & 1 & 1\\ 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 0\\ \hline \end{array} $$
OR The logical OR operator performs a bitwise disjunction between an image and a constant value. On a binary image $I$, it is equivalent to a $Maximum$ operation as it appears in the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \vee C\\ \hline 1 & 1 & 1\\ 1 & 0 & 1\\ 0 & 1 & 1\\ 0 & 0 & 0\\ \hline \end{array} $$
XOR The logical XOR operator performs a bitwise exclusive disjunction between an image and a constant value. On a binary image $I$ and a constant value $C$, the logical XOR operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \veebar C\\ \hline 1 & 1 & 0\\ 1 & 0 & 1\\ 0 & 1 & 1\\ 0 & 0 & 0\\ \hline \end{array} $$
NAND The logical NAND operator performs a bitwise alternative denial between an image and a constant value. On a binary image $I$ and a constant value $C$, the logical NAND operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \uparrow C\\ \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 an image and a constant value. On a binary image $I$ and a constant value $C$, the logical NOR operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I \downarrow C\\ \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 an image and a constant value. It is the negation of the exclusive OR between an image $I$ and a constant value $C$ as described by the truth table and the following figure. $$ \begin{array}{|c|c|c|} \hline I & C & I \equiv C\\ \hline 1 & 1 & 1\\ 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\\ \hline \end{array} $$
SUBTRACT The logical SUBTRACT operator performs a bitwise logical difference between an image and a constant value. On a binary image $I$ and a constant value $C$, the logical SUBTRACT operator is described by the following truth table. $$ \begin{array}{|c|c|c|} \hline I & C & I - C\\ \hline 1 & 1 & 0\\ 1 & 0 & 1\\ 0 & 1 & 0\\ 0 & 0 & 0\\ \hline \end{array} $$ Remark: the logical difference is the only non commutative logical operation; for instance, $I-C\neq C-I$.
Enumeration AND
output
outputImage
The output image, size and type are forced to the same values as the input. Image null

Object Examples

auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

LogicalOperationWithValue logicalOperationWithValueAlgo;
logicalOperationWithValueAlgo.setInputImage( polystyrene );
logicalOperationWithValueAlgo.setValue( 10 );
logicalOperationWithValueAlgo.setLogicalOperator( LogicalOperationWithValue::LogicalOperator::AND );
logicalOperationWithValueAlgo.execute();

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

logical_operation_with_value_algo = imagedev.LogicalOperationWithValue()
logical_operation_with_value_algo.input_image = polystyrene
logical_operation_with_value_algo.value = 10
logical_operation_with_value_algo.logical_operator = imagedev.LogicalOperationWithValue.AND
logical_operation_with_value_algo.execute()

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

LogicalOperationWithValue logicalOperationWithValueAlgo = new LogicalOperationWithValue
{
    inputImage = polystyrene,
    value = 10,
    logicalOperator = LogicalOperationWithValue.LogicalOperator.AND
};
logicalOperationWithValueAlgo.Execute();

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

Function Examples

auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = logicalOperationWithValue( polystyrene, 10, LogicalOperationWithValue::LogicalOperator::AND );

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

result = imagedev.logical_operation_with_value(polystyrene, 10, imagedev.LogicalOperationWithValue.AND)

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

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

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