Subsections:
[Show/Hide]Binary Operations
Logical Operations
image and | or | xor | nand | nor | xnor | andn | orn image2 -> destination
These logical operations involve two binary images and a destination image to store the result. If one of the two images is not binary, the operation will not be executed. Using image convert -type bin, one can convert any image to a binary one. See convert for more information. The operations are logical tests and they do the following:
- and - the intersection
- or - the union
- xor - the union minus the intersection
- nand - the negation of the intersection, not (a and b)
- nor - the negation of the union, not (a or b)
- xnor - the intersection of the objects and background, or negation of xor
- andn - the intersection with negation, a and (not b)
- orn - the union with the negation, a or (not b)
| A | B | and | or | xor | nand | nor | xnor | andn | orn |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 |
There exists eight other logical operations, but 6 are redundant (a, b, not a, not b, all true, all false) and the other two are the negations of andn (which is equal to b orn a) and orn (which is equal to b andn a). Since they are the same as swapping the sources in orn and andn, the eight operations given above is sufficient to represent all the logical operations.
Dilate/erode a binary image
image dilate | erode -> destination
?-width vector (3 3 3 0 0)?.........Structuring element size
The dilate and erode operations are morphological operations. Dilate "enlarges" the objects in your binary image, while erode "shrinks" the objects. The amount of dilation or erosion is determined by the structuring element size. The structuring element is square and must have an odd size in all dimensions.
Morphological open/close binary operation
image morphOpen | morphClose -> destination
?-width vector (3 3 3 0 0)?.........Structuring element size
The open and close operations are morphological operations. They are the combinations of a dilation and an erosion with the same stucturing element size. The closing operation is a dilation followed by an erosion. This closes all gaps smaller than the structuring element size. The opening operation is an erosion followed by a dilation. This removes all (parts of) objects smaller or thinner than the structuring element size.
Apply a binary mask to an image
image mask maskimage -> destination
?-binOp and | andn (and)?.........Operation choice
With this command one can apply a binary mask to an image. Depending on the operation choice -binOpt, voxels that are not part of the object are set to zero. All other voxels keep their original intensity.