C# Class Algorithmix.Preprocessing.Preprocessing

Show file Open project: Algorithmix/Papyrus

Public Properties

Property Type Description
DOUBLE_ROTATE bool
MaskColor Color
MaxAspectRatio int
MinAspectRatio int
MinDimension int
MinTransparencyRatio double
log Logger

Public Methods

Method Description
AspectRatioFilter ( Bitmap shred ) : bool

Simple helper function test to filter extracted images based on their aspect ratio height/width

ExtractImages ( Bitmap Source, Bitmap Mask ) : List

Extracts all objects from the source image

FindBottomTransparent ( Byte>.Image myImg ) : int

Find the bottow row with non-transparent pixels

FindLeftTransparent ( Byte>.Image myImg ) : int

Find the leftmost column with non-transparent pixels

FindRightTransparent ( Byte>.Image myImg ) : int

Find the rightmost column with non-transparent pixels

FindTopTransparent ( Byte>.Image myImg ) : int

Find the top row of non-transparent pixels

FloodFill ( Bitmap image, int xpixel, int ypixel, double threshold, Bgr myColor ) : Bitmap

Flood fill in a BFS manner, so as not to overwhelm the stack

LabelConnectedComponents ( Bitmap &image ) : int

Lable Connected Components of the scan, Identify unique objects

Orient ( Bitmap blob ) : Bitmap

Rotates the blobs to be vertical

Orient_Hough ( Bitmap blob ) : Bitmap
Orient_Step2 ( Bitmap blob ) : Bitmap
RotateImg ( Bitmap bmp, float angle, Color bkColor ) : Bitmap

Rotate the image by angle degrees, with bkColor as new background Uses some magic with the translatetransform and pixel2d :P WOW!

TransparencyFilter ( Bitmap shred ) : bool

Simple helper function that will test to make sure that more than a certain percentage of the shred is non a transparent color.

Private Methods

Method Description
ApplyBlobExtractor ( Bitmap Mask, Bitmap Source ) : Bitmap>>.List

Applies the blob extraction feature of Aforge

ExtractSingleImage ( Bitmap TheBlob, Bitmap Source ) : Bitmap

Extracts a single object given the corresponding mask and rectangle

FilterBlob ( Bitmap mask ) : bool

Simple helper function to filter blobs. Currently works solely on size.

GetCropZone ( Byte>.Image myImg ) : Rectangle

Simple helper function for cropping the image after rotation

Method Details

AspectRatioFilter() public static method

Simple helper function test to filter extracted images based on their aspect ratio height/width
public static AspectRatioFilter ( Bitmap shred ) : bool
shred System.Drawing.Bitmap the extracted shred
return bool

ExtractImages() public static method

Extracts all objects from the source image
public static ExtractImages ( Bitmap Source, Bitmap Mask ) : List
Source System.Drawing.Bitmap the scan of all the shreds
Mask System.Drawing.Bitmap
return List

FindBottomTransparent() public static method

Find the bottow row with non-transparent pixels
public static FindBottomTransparent ( Byte>.Image myImg ) : int
myImg Byte>.Image the image to find the last row with non-transparent pixels
return int

FindLeftTransparent() public static method

Find the leftmost column with non-transparent pixels
public static FindLeftTransparent ( Byte>.Image myImg ) : int
myImg Byte>.Image the image to find the first column with non-transparent pixels
return int

FindRightTransparent() public static method

Find the rightmost column with non-transparent pixels
public static FindRightTransparent ( Byte>.Image myImg ) : int
myImg Byte>.Image the image to find the last column with non-transparent pixels
return int

FindTopTransparent() public static method

Find the top row of non-transparent pixels
public static FindTopTransparent ( Byte>.Image myImg ) : int
myImg Byte>.Image image to find top non-transparent pixels
return int

FloodFill() public static method

Flood fill in a BFS manner, so as not to overwhelm the stack
public static FloodFill ( Bitmap image, int xpixel, int ypixel, double threshold, Bgr myColor ) : Bitmap
image System.Drawing.Bitmap the image we wish to fill on
xpixel int the x pixel to sample from
ypixel int the y pixel to sample from
threshold double the threshold of difference
myColor Bgr
return System.Drawing.Bitmap

LabelConnectedComponents() public static method

Lable Connected Components of the scan, Identify unique objects
public static LabelConnectedComponents ( Bitmap &image ) : int
image System.Drawing.Bitmap The mask
return int

Orient() public static method

Rotates the blobs to be vertical
public static Orient ( Bitmap blob ) : Bitmap
blob System.Drawing.Bitmap image blob to orient
return System.Drawing.Bitmap

Orient_Hough() public static method

public static Orient_Hough ( Bitmap blob ) : Bitmap
blob System.Drawing.Bitmap
return System.Drawing.Bitmap

Orient_Step2() public static method

public static Orient_Step2 ( Bitmap blob ) : Bitmap
blob System.Drawing.Bitmap
return System.Drawing.Bitmap

RotateImg() public static method

Rotate the image by angle degrees, with bkColor as new background Uses some magic with the translatetransform and pixel2d :P WOW!
public static RotateImg ( Bitmap bmp, float angle, Color bkColor ) : Bitmap
bmp System.Drawing.Bitmap the image to be rotated
angle float the angle to rotate by
bkColor Color background color for new background pixels
return System.Drawing.Bitmap

TransparencyFilter() public static method

Simple helper function that will test to make sure that more than a certain percentage of the shred is non a transparent color.
public static TransparencyFilter ( Bitmap shred ) : bool
shred System.Drawing.Bitmap
return bool

Property Details

DOUBLE_ROTATE public static property

public static bool DOUBLE_ROTATE
return bool

MaskColor public static property

public static Color MaskColor
return Color

MaxAspectRatio public static property

public static int MaxAspectRatio
return int

MinAspectRatio public static property

public static int MinAspectRatio
return int

MinDimension public static property

public static int MinDimension
return int

MinTransparencyRatio public static property

public static double MinTransparencyRatio
return double

log public static property

public static Logger log
return Logger