AutoCropOptions Class
Immutable options for ImageProcessingExtensions.AutoCrop and ImageProcessingExtensions.AnalyzeAutoCrop.
public sealed class AutoCropOptionsRemarks
The background is the most frequent color of the one-pixel outer border of the image. A border exists when the border has fewer than AutoCropOptions.ColorThreshold distinct colors, or when AutoCropOptions.BucketThreshold is set and at least that share of the border pixels is as bright as the background. The content is then the bounding box of the pixels that differ from the background by more than AutoCropOptions.ColorThreshold.
Thresholds are expressed on the 8-bit scale whatever the pixel format; comparisons are made at the storage precision (a threshold of 35 is 35 * 257 for 16-bit samples).
Constructors
| Name | Description |
|---|---|
| AutoCropOptions() |
AutoCropOptions()
AutoCropOptions.cspublic AutoCropOptions()No documentation is available.
Properties
| Name | Description |
|---|---|
| AnalyzeWeights | Gets a value indicating whether the analysis also computes AutoCropAnalysis.WeightX and AutoCropAnalysis.WeightY, which shift the padded rectangle toward the visually heavier side of the image by padding * weight pixels (truncated, with the weight clamped to [-1, 1], so the content always stays inside the padded rectangle). Defaults to false. It needs one more pass over the pixels. |
| BucketThreshold | Gets the minimum share of the border pixels, from 0 to 1, whose luma falls in the same of 11 equal luma buckets as the background color, for the border to be accepted even when it has AutoCropOptions.ColorThreshold distinct colors or more (noisy or compressed backgrounds). Defaults to null: only the number of distinct colors decides. It is not used by the retry. |
| ColorThreshold | Gets the color threshold, from 1 to 255 on the 8-bit scale. Defaults to 35. It is both the tolerance of the background test (a pixel is background when its luma-weighted difference from the background color, 0.2126 |dR| + 0.7152 |dG| + 0.0722 |dB|, is at most the threshold and its alpha difference is below the threshold) and the number of distinct border colors (after reduction to 8 bits) from which the border is no longer considered uniform. When no border is found, the detection is retried once with half the threshold (rounded up) on the image without its outer 5% on each side. |
| Default | Gets the default options: no padding, a color threshold of 35, no bucket threshold, AutoCropPaddingMode.Expand, no weight analysis. |
| PaddingMode | Gets what happens when the padding reaches outside the canvas. Defaults to AutoCropPaddingMode.Expand. |
| PaddingX | Gets the padding kept on the left and on the right of the content, in pixels. Defaults to 0. |
| PaddingY | Gets the padding kept above and below the content, in pixels. Defaults to 0. |
AnalyzeWeights
AutoCropOptions.csGets a value indicating whether the analysis also computes AutoCropAnalysis.WeightX and AutoCropAnalysis.WeightY, which shift the padded rectangle toward the visually heavier side of the image by padding * weight pixels (truncated, with the weight clamped to [-1, 1], so the content always stays inside the padded rectangle). Defaults to false. It needs one more pass over the pixels.
public bool AnalyzeWeights { get; init; }Property value
BucketThreshold
AutoCropOptions.csGets the minimum share of the border pixels, from 0 to 1, whose luma falls in the same of 11 equal luma buckets as the background color, for the border to be accepted even when it has AutoCropOptions.ColorThreshold distinct colors or more (noisy or compressed backgrounds). Defaults to null: only the number of distinct colors decides. It is not used by the retry.
public double? BucketThreshold { get; init; }ColorThreshold
AutoCropOptions.csGets the color threshold, from 1 to 255 on the 8-bit scale. Defaults to 35. It is both the tolerance of the background test (a pixel is background when its luma-weighted difference from the background color, 0.2126 |dR| + 0.7152 |dG| + 0.0722 |dB|, is at most the threshold and its alpha difference is below the threshold) and the number of distinct border colors (after reduction to 8 bits) from which the border is no longer considered uniform. When no border is found, the detection is retried once with half the threshold (rounded up) on the image without its outer 5% on each side.
public int ColorThreshold { get; init; }Default
AutoCropOptions.csGets the default options: no padding, a color threshold of 35, no bucket threshold, AutoCropPaddingMode.Expand, no weight analysis.
public static AutoCropOptions Default { get; }Property value
PaddingMode
AutoCropOptions.csGets what happens when the padding reaches outside the canvas. Defaults to AutoCropPaddingMode.Expand.
public AutoCropPaddingMode PaddingMode { get; init; }PaddingX
AutoCropOptions.csGets the padding kept on the left and on the right of the content, in pixels. Defaults to 0.
public int PaddingX { get; init; }PaddingY
AutoCropOptions.csGets the padding kept above and below the content, in pixels. Defaults to 0.
public int PaddingY { get; init; }