CVB.Net 15.0
ImagePlane Struct Reference

Plane information container. More...

Public Member Functions

bool TryGetLinearAccess (out LinearAccessData access)
 Attempt a linear access on the plane's pixels. More...
 
bool TryGetLinearAccess< T > (out LinearAccessData< T > access)
 Attempt a typed linear access on the plane's pixels. More...
 
LinearAccessData GetLinearAccess ()
 Gets linear access to the plane's pixels. More...
 
LinearAccessData< T > GetLinearAccess< T > ()
 Gets typed linear access to the plane's pixels. More...
 
VpatAccessData< T > GetVPATAccess< T > ()
 Gets typed VPAT access to the plane's pixels. More...
 
ImageData GetLockedAccess (ImageDataLockMode lockMode)
 Gets thread-locked access to the image data. More...
 
IEnumerable< IntPtr > GetAllPixelsIn (Area2D aoi)
 Gets an enumerator to enumerate all pixel values of this plane in the given aoi . More...
 
IEnumerable< IntPtr > GetAllPixelsIn (Rect aoi)
 Gets an enumerator to enumerate all pixel values of this plane in the given aoi . More...
 
void CopyTo (ImagePlane targetPlane)
 Copies the image data from this plane to the targetPlane . More...
 
void CopyTo (ImagePlane targetPlane, Rect sourceRect, Point2D targetPosition)
 Copies the image data from the sourceRect of this plane to the targetPlane targetPosition . More...
 
double GetPixel (Point2D position)
 Gets the pixel value at the given position . More...
 
double GetPixel (int x, int y)
 Gets the pixel value at the given position. More...
 
void Initialize (double value)
 Initialize this plane to a specific value. More...
 
void Initialize (Area2D area, double value)
 Initialize an area of an image to a specific value. More...
 
MappedImage Map ()
 Create a map from a single image plane that shares its memory with the original plane. More...
 

Properties

Image Parent [get]
 Image to which this descriptor refers to.
 
int Plane [get]
 Plane index in the Parent image to which this descriptor refers to.
 
DataType DataType [get]
 Data type descriptor for this plane. More...
 
Vpat Vpat [get]
 Accesses the virtual pixel access table. More...
 
IEnumerable< IntPtr > AllPixels [get]
 Gets an enumerator to enumerate all pixels of this plane. More...
 

Detailed Description

Plane information container.

Member Function Documentation

◆ CopyTo() [1/2]

void CopyTo ( ImagePlane  targetPlane)

Copies the image data from this plane to the targetPlane .

Parameters
targetPlanePlane to copy to.
Exceptions
CvbExceptionCopy regions or data types incompatible.
ObjectDisposedExceptionIf the parent image has already been disposed

◆ CopyTo() [2/2]

void CopyTo ( ImagePlane  targetPlane,
Rect  sourceRect,
Point2D  targetPosition 
)

Copies the image data from the sourceRect of this plane to the targetPlane targetPosition .

Parameters
targetPlanePlane to copy to.
sourceRectSource rectangle in pixels to copy from.
targetPositionPosition in targetPlane in pixels to copy to.
Exceptions
CvbExceptionCopy regions or data types incompatible.
ObjectDisposedExceptionIf the parent image has already been disposed

◆ GetAllPixelsIn() [1/2]

IEnumerable< IntPtr > GetAllPixelsIn ( Area2D  aoi)

Gets an enumerator to enumerate all pixel values of this plane in the given aoi .

Touches every pixel in the aoi exactly once.

Attention: no interpolation is done!

Parameters
aoiArea to scan for pixel values.
Returns
Enumerator to enumerate all pixel values of this plane in the given aoi .
Exceptions
ObjectDisposedExceptionIf Parent has already been disposed
InvalidOperationExceptionThrown if the size of T and DataType.BytesPerPixel are unequal.

◆ GetAllPixelsIn() [2/2]

IEnumerable< IntPtr > GetAllPixelsIn ( Rect  aoi)

Gets an enumerator to enumerate all pixel values of this plane in the given aoi .

Parameters
aoiArea to scan for pixel values.
Returns
Enumerator to enumerate all pixel values of this plane in the given aoi .
Exceptions
ObjectDisposedExceptionIf Parent has already been disposed
InvalidOperationExceptionThrown if the size of T and DataType.BytesPerPixel are unequal.

◆ GetLinearAccess()

LinearAccessData GetLinearAccess ( )

Gets linear access to the plane's pixels.

See TryGetLinearAccess. Unlike TryGetLinearAccess, GetLinearAccess will throw an exception if linear access is not possible on this plane.

Returns
data structure with the values for accessing the pixels
Exceptions
FormatExceptionIf the plane's pixels are not accessible linearly
ObjectDisposedExceptionIf Parent has already been disposed

◆ GetLinearAccess< T >()

Gets typed linear access to the plane's pixels.

See TryGetLinearAccess<T>(out LinearAccessData<T>). Unlike it, GetLinearAccess will throw an exception if linear access is not possible on this plane.

Attention: Do not use reference types in T as this will leak memory!

Template Parameters
TStructure for access a single plane's pixel.
Returns
Data structure with the values for accessing the pixels
Exceptions
FormatExceptionIf the plane's pixels are not accessible linearly
ObjectDisposedExceptionIf Parent has already been disposed
InvalidOperationExceptionThrown if the size of T and DataType.BytesPerPixel are unequal.
Type Constraints
T :struct 

◆ GetLockedAccess()

ImageData GetLockedAccess ( ImageDataLockMode  lockMode)

Gets thread-locked access to the image data.

Calling this method will enter a reader/writer lock based on the specified lock mode. It is mandatory to ImageData.Dispose() the returned object when pixel access has finished. Best use the returned object in a using block.

All other API functions do not use the reader/writer lock of the image. Thus if you want to use these on a shared image resource with some write access, you need to wrap the calls in a using block initialized by this method.

Also by giving a hint whether you are changing the image data, the Image.PixelContentChanged event is fired when the returned object is disposed and the lockMode is ImageDataLockMode.WriteOnly or ImageDataLockMode.ReadWrite.

Parameters
lockModeAccess mode hint.
Returns
The image access data.

◆ GetPixel() [1/2]

double GetPixel ( int  x,
int  y 
)

Gets the pixel value at the given position.

Parameters
xPosition in pixel coordinates.
yPosition in pixel coordinates.
Returns
The pixel value; double.NaN if the value could not be dereferenced.

◆ GetPixel() [2/2]

double GetPixel ( Point2D  position)

Gets the pixel value at the given position .

Parameters
positionPosition in pixel coordinates.
Returns
The pixel value; double.NaN if the value could not be dereferenced.

◆ GetVPATAccess< T >()

VpatAccessData< T > GetVPATAccess< T > ( )

Gets typed VPAT access to the plane's pixels.

The size of T must be equal to the DataType.BytesPerPixel.

Attention: Do not use reference types in T as this will leak memory!

Template Parameters
TStructure for access a single plane's pixel.
Returns
Data structure with the value for accessing the pixels.
Exceptions
ObjectDisposedExceptionIf Parent has already been disposed
InvalidOperationExceptionThrown if the size of T and DataType.BytesPerPixel are unequal.
Type Constraints
T :struct 

◆ Initialize() [1/2]

void Initialize ( Area2D  area,
double  value 
)

Initialize an area of an image to a specific value.

Parameters
areaarea to be initialized
valuevalue to initialize the area to
Exceptions
ObjectDisposedExceptionIf the parent image has already been disposed

◆ Initialize() [2/2]

void Initialize ( double  value)

Initialize this plane to a specific value.

Parameters
valuevalue to initialize the plane to
Exceptions
ObjectDisposedExceptionIf the parent image has already been disposed

◆ Map()

MappedImage Map ( )

Create a map from a single image plane that shares its memory with the original plane.

Returns
Mapped image object.
Exceptions
ObjectDisposedExceptionIf the parent image has already been disposed

◆ TryGetLinearAccess()

bool TryGetLinearAccess ( out LinearAccessData  access)

Attempt a linear access on the plane's pixels.

This function scans the image's VPAT for the possibility to access the individual pixels with linear increments in x and y direction. If either of the VPATs are jumbled, it will return false, otherwise the values in access can be used to calculate the address of each pixel.

Parameters
accessData structure receiving the values for accessing the pixels
Returns
true if linear access is possible, false otherwise.
Exceptions
ObjectDisposedExceptionIf Parent has already been disposed

◆ TryGetLinearAccess< T >()

bool TryGetLinearAccess< T > ( out LinearAccessData< T >  access)

Attempt a typed linear access on the plane's pixels.

This function scans the image's VPAT for the possibility to access the individual pixels with linear increments in x and y direction. If either of the VPATs are jumbled, it will return false, otherwise the values in access can be used to calculate the address of each pixel.

Additionally the size of T must be equal to the DataType.BytesPerPixel.

Attention: Do not use reference types in T as this will leak memory!

Template Parameters
TStructure for access a single plane's pixel.
Parameters
accessData structure receiving the values for accessing the pixels
Returns
true if linear access is possible, false otherwise.
Exceptions
ObjectDisposedExceptionIf Parent has already been disposed
InvalidOperationExceptionThrown if the size of T and DataType.BytesPerPixel are unequal.
Type Constraints
T :struct 

Property Documentation

◆ AllPixels

IEnumerable<IntPtr> AllPixels
get

Gets an enumerator to enumerate all pixels of this plane.

Enumerator to enumerate the pointers to each pixel in an image.

◆ DataType

Data type descriptor for this plane.

Exceptions
ObjectDisposedExceptionIf Parent has already been disposed

◆ Vpat

Vpat Vpat
get

Accesses the virtual pixel access table.

Normally this property only needs to be accessed if you want to access the underlying CVB image on the pixel level. Note that VPAT access is one of the slower access modes. If possible, linear access is preferred.