Grid Mask Boolean Combination

Combine identically shaped binary masks by explicit AND, OR, XOR or left difference; no resampling or alignment inference.

Description

Combine identically shaped binary masks by explicit AND, OR, XOR or left difference; no resampling or alignment inference.

Binary masks support several element-wise set operations only when their shapes match.

When to use this tool

Combine identically shaped binary masks by explicit AND, OR, XOR or left difference; no resampling or alignment inference.

  • Prepare the supplied left, right, operation fields for this operation.
  • Compare the complete example with the representation used by your own input before carrying the result into another step.

How to use the tool and how it works

  1. Enter left, right, operation. Use the exact text syntax, units and index conventions explained below.
  2. Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
  3. Read result.mask. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.

Validate nonempty rectangular zero/one masks of equal dimensions. Apply and, or, xor or left-minus-right to each aligned cell, returning a binary mask.1

Input fieldMeaning and representationAccepted input
leftleft.Numeric rows; at most 128 rows and 128 values per row
rightright.Numeric rows; at most 128 rows and 128 values per row
operationoperation.Text; at most 8,192 UTF-16 code units, subject to the grammar above
Output fieldInterpretation
resultObject containing the named outputs below.
result.maskThe mask list in the ordering and representation described above.
json
{
  "input": {
    "left": [
      [
        1,
        0
      ]
    ],
    "right": [
      [
        1,
        1
      ]
    ],
    "operation": "xor"
  },
  "output": {
    "result": {
      "mask": [
        [
          0,
          1
        ]
      ]
    }
  }
}

Limitations and assumptions

  • The operation does not align, resize or threshold masks. Left-minus-right is directional, and each mask is bounded to 16,384 cells.
  • Coordinate pairs use [row,column] where stated. Masks are nonempty rectangular zero/one matrices of at most 128 rows, 128 columns and 16,384 cells; outside-mask values are unset for the neighborhood operations.
  • Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
  • String lists have at most 128 entries of at most 128 code units; matrices have at most 128 rows and columns. Larger numeric lists and parsed JSON have separate bounded budgets. Nonfinite results and excessively large serialized outputs are rejected.
  • Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.

Alternative or Complementary methods

Keep row/column coordinates distinct from x/y pairs and byte offsets. Select the neighborhood metric, outside-mask rule and storage-order convention explicitly; these operations do not infer an image format.

References

  1. Tool behavior and example: Grid Mask Boolean Combination — tool.io

Similar or alternative tools

  • Grid Mask Border Cells

    List set binary mask cells adjacent to a four-neighbor unset/outside position in stable row-major order.

  • Grid Mask Bounding Rectangle

    Find the smallest half-open row/column bounding rectangle of set binary mask cells; an all-zero mask has no rectangle.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies