Table of Contents

Method IsBlank

Namespace
LMKit.Media.Image
Assembly
LM-Kit.NET.dll

IsBlank(byte)

Determines whether the image is blank (all pixels have the same or similar values within a tolerance).

public bool IsBlank(byte tolerance = 0)

Parameters

tolerance byte

Maximum allowed per-channel absolute difference between pixels (0-255). Default is 0 (exact match required). For GRAY8: absolute difference between gray values. For RGB24/RGBA32: maximum absolute difference across any channel.

Returns

bool

true if all pixels in the image have values within the specified tolerance; otherwise, false.

Remarks

This method efficiently checks if all pixels have similar values by comparing each pixel against the first pixel in the image. The implementation is optimized with separate fast paths for exact matching (tolerance = 0) and tolerant matching.

For GRAY8 images, it checks if all bytes differ by at most the tolerance. For RGB24 images, it checks if all R, G, B channels independently differ by at most the tolerance. For RGBA32 images, it checks if all R, G, B, A channels independently differ by at most the tolerance.

Performance: O(n) where n is the number of pixels, but returns early upon finding the first pixel that exceeds the tolerance.

// Check for exact uniformity
bool isExactlyBlank = image.IsBlank();

// Allow slight variations (e.g., for scanned documents with noise)
bool isNearlyBlank = image.IsBlank(tolerance: 10);

Exceptions

NotSupportedException

Thrown if the pixel format is not one of GRAY8, RGB24, or RGBA32.