Skip to content

gray_projectionsGrayProjectionsGrayProjectionsgray_projectionsT_gray_projections🔗

Short description🔗

gray_projectionsGrayProjectionsGrayProjectionsgray_projectionsT_gray_projections — Calculate horizontal and vertical gray-value projections.

Signature🔗

gray_projections( region Region, image Image, string Mode, out real HorProjection, out real VertProjection )void GrayProjections( const HObject& Region, const HObject& Image, const HTuple& Mode, HTuple* HorProjection, HTuple* VertProjection )static void HOperatorSet.GrayProjections( HObject region, HObject image, HTuple mode, out HTuple horProjection, out HTuple vertProjection )def gray_projections( region: HObject, image: HObject, mode: str ) -> Tuple[Sequence[float], Sequence[float]]

Herror T_gray_projections( const Hobject Region, const Hobject Image, const Htuple Mode, Htuple* HorProjection, Htuple* VertProjection )

HTuple HImage::GrayProjections( const HRegion& Region, const HString& Mode, HTuple* VertProjection ) const

HTuple HImage::GrayProjections( const HRegion& Region, const char* Mode, HTuple* VertProjection ) const

HTuple HImage::GrayProjections( const HRegion& Region, const wchar_t* Mode, HTuple* VertProjection ) const (Windows only)

HTuple HRegion::GrayProjections( const HImage& Image, const HString& Mode, HTuple* VertProjection ) const

HTuple HRegion::GrayProjections( const HImage& Image, const char* Mode, HTuple* VertProjection ) const

HTuple HRegion::GrayProjections( const HImage& Image, const wchar_t* Mode, HTuple* VertProjection ) const (Windows only)

HTuple HImage.GrayProjections( HRegion region, string mode, out HTuple vertProjection )

HTuple HRegion.GrayProjections( HImage image, string mode, out HTuple vertProjection )

Description🔗

gray_projectionsGrayProjections calculates the horizontal and vertical gray-value projections, i.e., the mean values in the horizontal and vertical direction of the gray values of the input image Imageimageimage within the input region Regionregionregion.

If Modemodemode = 'simple'"simple" is selected the projection is performed in the direction of the coordinate axes of the image, i.e.:

\[\begin{eqnarray*} \textrm{HorProjection}(r) & = & \frac{1}{n(r+r')} \sum_{(r+r',c+c') \in \textrm{Region}} \textrm{Image}(r+r',c+c') \\ \textrm{VertProjection}(c) & = & \frac{1}{n(c+c')} \sum_{(r+r',c+c') \in \textrm{Region}} \textrm{Image}(r+r',c+c') \end{eqnarray*}\]

Here, \((r',c')\) denotes the upper left corner of the smallest enclosing axis-parallel rectangle of the input region (see smallest_rectangle1SmallestRectangle1), and \(n(x)\) denotes the number of region points in the corresponding row \(r+r'\) or column \(c+c'\). Hence, the horizontal projection returns a one-dimensional function that reflects the vertical gray value changes. Likewise, the vertical projection returns a function that reflects the horizontal gray value changes.

If Modemodemode = 'rectangle'"rectangle"is selected the projection is performed in the direction of the major axes of the smallest enclosing rectangle of arbitrary orientation of the input region (see smallest_rectangle2SmallestRectangle2). Here, the horizontal projection direction corresponds to the larger axis, while the vertical direction corresponds to the smaller axis. In this mode, all gray values within the smallest enclosing rectangle of arbitrary orientation of the input region are used to compute the projections.

Attention🔗

The operator gray_projectionsGrayProjections only considers the given Regionregionregion and ignores any previously set domain of the input image Imageimageimage.

If \(n(x) = 0\), i.e., if there are no region points in the corresponding row \(r+r'\) or column \(c+c'\), the respective value of HorProjectionhorProjectionhor_projection or VertProjectionvertProjectionvert_projection is set to \(-1\).

gray_projectionsGrayProjections can be executed on an OpenCL device for the 'simple'"simple" mode if the OpenCL device supports the cl_khr_global_int32_base_atomics OpenCL extension. For processing images of type real, the OpenCL device must support the cl_khr_fp64 and cl_khr_int64_base_atomics extensions.

Execution information🔗

Execution information
  • Supports OpenCL compute devices.

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

Regionregionregion (input_object) region → objectHObjectHRegionHObjectHobject

Region to be processed.

Imageimageimage (input_object) singlechannelimage → object (byte* / int2* / uint2* / real*)HObject (byte* / int2* / uint2* / real*)HImage (byte* / int2* / uint2* / real*)HObject (byte* / int2* / uint2* / real*)Hobject (byte* / int2* / uint2* / real*) *allowed for compute devices

Grayvalues for projections.

Modemodemode (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Method to compute the projections.

Default: 'simple'"simple"
List of values: 'rectangle', 'simple'"rectangle", "simple"
List of values (for compute devices): 'simple'"simple"

HorProjectionhorProjectionhor_projection (output_control) real-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Horizontal projection.

VertProjectionvertProjectionvert_projection (output_control) real-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Vertical projection.

Module🔗

1D Metrology