|
Rectangle | FindBoxSobel (Bitmap originalImage, Rectangle lookInside, byte threshold) |
| Returns a rectangle inside 'lookInside' that bounds any energy greater than 'threshold'. More...
|
|
Rectangle | FindBoxSobel (Bitmap rgb, byte threshold) |
| Requires 24 bit or 32 bit (A) RGB image. More...
|
|
Rectangle | FindBoxExactGrayscale (BitmapData sourceData, byte indexToRemove) |
| Returns a bounding box that only excludes the specified color. Only works on 8-bit images. More...
|
|
Definition at line 12 of file BoundingBoxFinder.cs.
Rectangle ImageResizer.Plugins.WhitespaceTrimmer.BoundingBoxFinder.FindBoxExactGrayscale |
( |
BitmapData |
sourceData, |
|
|
byte |
indexToRemove |
|
) |
| |
|
inline |
Returns a bounding box that only excludes the specified color. Only works on 8-bit images.
- Parameters
-
sourceData | |
colorToRemove | The palette index to remove. |
- Returns
Definition at line 83 of file BoundingBoxFinder.cs.
84 if (sourceData.PixelFormat != PixelFormat.Format8bppIndexed)
throw new ArgumentOutOfRangeException(
"FindBoxExact only operates on 8-bit grayscale images");
86 int width = sourceData.Width;
87 int height = sourceData.Height;
88 int offset = sourceData.Stride - width;
97 byte* src = (byte*)sourceData.Scan0;
99 for (
int y = 0; y < height; y++) {
100 if (y > 0) src += offset;
101 for (
int x = 0; x < width; x++) {
102 if (x > 0 || y > 0) src++;
103 if (*src != indexToRemove) {
118 if ((minX == width) && (minY == height) && (maxX == 0) && (maxY == 0)) {
122 return new Rectangle(minX,minY,maxX - minX + 1, maxY - minY + 1);
Rectangle ImageResizer.Plugins.WhitespaceTrimmer.BoundingBoxFinder.FindBoxSobel |
( |
Bitmap |
originalImage, |
|
|
Rectangle |
lookInside, |
|
|
byte |
threshold |
|
) |
| |
|
inline |
Returns a rectangle inside 'lookInside' that bounds any energy greater than 'threshold'.
- Parameters
-
image | |
lookInside | A rectangle of 'image' to look inside. |
threshold | 1-255, the energy threshold to detect activity. 80-150 is a good range. |
- Returns
Definition at line 21 of file BoundingBoxFinder.cs.
23 Bitmap image = originalImage;
26 if (image.PixelFormat != PixelFormat.Format24bppRgb &&
27 image.PixelFormat != PixelFormat.Format32bppArgb &&
28 image.PixelFormat != PixelFormat.Format32bppRgb) {
29 image = AForge.Imaging.Image.Clone(image, PixelFormat.Format24bppRgb);
33 if (!lookInside.Equals(
new Rectangle(0, 0, image.Width, image.Height))) {
34 Bitmap oldImage = image;
36 image =
new Crop(lookInside).Apply(image);
38 if (oldImage != originalImage) oldImage.Dispose();
45 return new Rectangle(lookInside.X + result.X, lookInside.Y + result.Y, result.Width, result.Height);
49 if (image != originalImage) image.Dispose();
Rectangle FindBoxSobel(Bitmap originalImage, Rectangle lookInside, byte threshold)
Returns a rectangle inside 'lookInside' that bounds any energy greater than 'threshold'.
Width and height are considered exact values - cropping is used if there is an aspect ratio differenc...
Rectangle ImageResizer.Plugins.WhitespaceTrimmer.BoundingBoxFinder.FindBoxSobel |
( |
Bitmap |
rgb, |
|
|
byte |
threshold |
|
) |
| |
|
inline |
Requires 24 bit or 32 bit (A) RGB image.
- Parameters
-
- Returns
Definition at line 59 of file BoundingBoxFinder.cs.
60 using (Bitmap gray = Grayscale.CommonAlgorithms.Y.Apply(rgb)) {
63 new SobelEdgeDetector().ApplyInPlace(gray);
65 new Threshold(threshold).ApplyInPlace(gray);
68 BitmapData data = gray.LockBits(
new Rectangle(0, 0, gray.Width, gray.Height), ImageLockMode.ReadOnly, gray.PixelFormat);
72 gray.UnlockBits(data);
Rectangle FindBoxExactGrayscale(BitmapData sourceData, byte indexToRemove)
Returns a bounding box that only excludes the specified color. Only works on 8-bit images...
The documentation for this class was generated from the following file: