dip::Interval class

Represents the shape of an interval for inf-generating and sup-generating operators.

An interval is typically expressed as two structuring elements, one marking the foreground pixels, one marking background pixels. Pixels not marked in either are the “don’t care” pixels. An interval must always have at least one foreground pixel. If there are no background pixels in the interval, consider using a plain dilation or erosion instead.

There are two constructors: one accepting two binary structuring elements, and one accepting a single kernel containing 1 for foreground, 0 for background, and any other value for “don’t care”. The constructors only take their input in the form of images, not as a dip::StructuringElement or dip::Kernel. The generic shapes that are easier to generate using those classes are not often useful in intervals.

Constructors, destructors, assignment and conversion operators

Interval(dip::Image image)
An interval can be constructed with a grey-value image, where 1 indicates foreground, 0 indicates background, and any other value indicates “don’t care” pixels.
Interval(dip::Image hit, dip::Image miss)
An interval can be constructed with two binary images, one for the foreground mask and one for the background mask.

Functions

void Invert()
Inverts the interval, swapping foreground and background pixels. Caution using this function, as the Interval can potentially share data with other intervals.
auto Image() const -> dip::Image const&
Returns the interval image, a dip::DT_SFLOAT image with values 0, 1 and NaN (for don’t care).
auto HitImage() const -> dip::Image
Returns the foreground mask image, a binary image.
auto MissImage() const -> dip::Image
Returns the background mask image, a binary image.
auto Sizes() const -> dip::UnsignedArray const&
Returns the sizes of the interval. The output array always has two elements.
auto GenerateRotatedVersions(dip::uint rotationAngle = 45, dip::String rotationDirection = S::INTERLEAVED_CLOCKWISE) const -> dip::IntervalArray
Returns rotated versions of the interval, applicable to 2D intervals only.

Function documentation

Interval(dip::Image image)

An interval can be constructed with a grey-value image, where 1 indicates foreground, 0 indicates background, and any other value indicates “don’t care” pixels.

The image must be odd in size, the origin is in the middle pixel.

Such an image converts implicitly to an Interval.

Interval(dip::Image hit, dip::Image miss)

An interval can be constructed with two binary images, one for the foreground mask and one for the background mask.

The images must be odd in size, the origin is in the middle pixel.

The two images must be disjoint, meaning that dip::Any( dip::Infimum( hit, miss )) must be false. An exception will be raised if this is not the case.

dip::IntervalArray GenerateRotatedVersions(dip::uint rotationAngle = 45, dip::String rotationDirection = S::INTERLEAVED_CLOCKWISE) const

Returns rotated versions of the interval, applicable to 2D intervals only.

rotationAngle can be 45, 90 or 180, the output vector will have 8, 4 or 2 intervals. Some of the interval images might point at the same data. Rotation angles of 45 degrees are only possible for square intervals. If the interval is not square, it will be made square by adding “don’t care” pixels.

rotationDirection affects the order of the intervals in the output vector:

  • "interleaved clockwise" sorts the angles as follows: 0, 180, 45, 225, 90, 270, 135, 315.
  • "interleaved counter-clockwise" is the same, but goes around the other way.
  • "clockwise" sorts the angles as follows: 0, 45, 90, 135, 180, 225, 270, 315.
  • "counter-clockwise" is the same, but goes around the other way.