mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-15 22:02:51 -06:00
PixRaster : added some more function wrappers
git-svn-id: svn://ultimatepp.org/upp/trunk@2595 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
1b6abbdbe4
commit
6241f2e7dd
5 changed files with 117 additions and 0 deletions
|
|
@ -19,4 +19,23 @@ Pix Pix::CombineMasked(Pix &aPix, Pix &maskPix)
|
|||
|
||||
} // END Pix::CombineMasked()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// extracts a rectangular area from PIX
|
||||
Pix Pix::ClipRectangle(Rect r)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return Pix();
|
||||
|
||||
BOX box;
|
||||
box.x = r.left;
|
||||
box.y = r.top;
|
||||
box.w = r.right - r.left;
|
||||
box.h = r.bottom - r.top;
|
||||
|
||||
PIX *dPix = pixClipRectangle(pix, &box, NULL);
|
||||
if(!dPix)
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -50,4 +50,54 @@ Pix Pix::CloseGray(int hsize, int vsize)
|
|||
|
||||
} // END Pix::CloseGray()
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::ErodeBrick(int hsize, int vsize)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return Pix();
|
||||
PIX *dPix = pixErodeBrick(NULL, pix, hsize, vsize);
|
||||
if(!dPix)
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
} // END Pix::ErodeBrick()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::DilateBrick(int hsize, int vsize)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return Pix();
|
||||
PIX *dPix = pixDilateBrick(NULL, pix, hsize, vsize);
|
||||
if(!dPix)
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
} // END Pix::DilateBrick()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::OpenBrick(int hsize, int vsize)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return Pix();
|
||||
PIX *dPix = pixOpenBrick(NULL, pix, hsize, vsize);
|
||||
if(!dPix)
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
} // END Pix::OpenBrick()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::CloseBrick(int hsize, int vsize)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return Pix();
|
||||
PIX *dPix = pixCloseBrick(NULL, pix, hsize, vsize);
|
||||
if(!dPix)
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
} // END Pix::CloseBrick()
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -59,4 +59,17 @@ Array<int> Pix::FindBaselines()
|
|||
|
||||
} // END Pix::FindBaseLines()
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// foreground bounding box locating routine
|
||||
// scans from a given border through image center to locate
|
||||
// first non-background pixel.
|
||||
// scanFlag is one of L_FROM_LEFT, L_FROM_RIGHT, L_FROM_TOP, L_FROM_BOTTOM
|
||||
// returns true on success, false otherwise
|
||||
bool Pix::ScanForForeground(int &loc, enum ScanModes scanMode)
|
||||
{
|
||||
int res = pixScanForForeground(pix, NULL, (l_int32)scanMode, (l_int32 *)&loc);
|
||||
return (res == 0);
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -39,4 +39,17 @@ Pix Pix::RotateAMGray(double angle, int incolor)
|
|||
|
||||
} // END Pix::RotateAMGray()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Rotates image (any kind) about center.
|
||||
Pix Pix::Rotate(double angle, int type, int incolor, int width, int height)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return Pix();
|
||||
PIX *dPix = pixRotate(pix, angle, type, incolor, width, height);
|
||||
if(!dPix)
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
} // END Pix::Rotate()
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -146,6 +146,12 @@ class Pix : public PixBase
|
|||
// bring-in color modes
|
||||
enum BringInModes { PIXRASTER_BRING_IN_WHITE = L_BRING_IN_WHITE, PIXRASTER_BRING_IN_BLACK = L_BRING_IN_BLACK };
|
||||
|
||||
// rotate modes
|
||||
enum RotateModes { PIXRASTER_ROTATE_AREA_MAP = L_ROTATE_AREA_MAP, PIXRASTER_ROTATE_SHEAR = L_ROTATE_SHEAR, PIXRASTER_ROTATE_SAMPLING = L_ROTATE_SAMPLING };
|
||||
|
||||
// scan direction modes
|
||||
enum ScanModes { PIXRASTER_FROM_LEFT = L_FROM_LEFT, PIXRASTER_FROM_RIGHT = L_FROM_RIGHT, PIXRASTER_FROM_TOP = L_FROM_TOP, PIXRASTER_FROM_BOTTOM = L_FROM_BOTTOM };
|
||||
|
||||
// loads Pix from another raster object
|
||||
void Load(Raster& raster, bool deepCopy = false, int page = PIXRASTER_CURPAGE);
|
||||
|
||||
|
|
@ -268,6 +274,7 @@ class Pix : public PixBase
|
|||
Pix RotateAM(double angle, BringInModes incolor = PIXRASTER_BRING_IN_WHITE);
|
||||
Pix RotateAMColor(double angle, int colorval);
|
||||
Pix RotateAMGray(double angle, int grayval);
|
||||
Pix Rotate(double angle, int type = PIXRASTER_ROTATE_SHEAR, int incolor = PIXRASTER_BRING_IN_WHITE, int width = 0, int height = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// MORPHING FUNCTIONS
|
||||
|
|
@ -277,6 +284,11 @@ class Pix : public PixBase
|
|||
Pix OpenGray(int hsize, int vsize);
|
||||
Pix CloseGray(int hsize, int vsize);
|
||||
|
||||
Pix ErodeBrick(int hsize, int vsize);
|
||||
Pix DilateBrick(int hsize, int vsize);
|
||||
Pix OpenBrick(int hsize, int vsize);
|
||||
Pix CloseBrick(int hsize, int vsize);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ARITHMETIC AND ALIKE FUNCTIONS
|
||||
|
||||
|
|
@ -290,6 +302,9 @@ class Pix : public PixBase
|
|||
// BLENDING/COMBINING FUNCTIONS
|
||||
|
||||
Pix CombineMasked(Pix &aPix, Pix &maskPix);
|
||||
|
||||
// extracts a rectangular area from PIX
|
||||
Pix ClipRectangle(Rect r);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// DOCUMENT PAGE SEGMENTING FUNCTIONS
|
||||
|
|
@ -300,6 +315,13 @@ class Pix : public PixBase
|
|||
// text baseline finding routine
|
||||
Array<int> FindBaselines();
|
||||
|
||||
// foreground bounding box locating routine
|
||||
// scans from a given border through image center to locate
|
||||
// first non-background pixel.
|
||||
// scanFlag is one of PIXRASTER_FROM_LEFT, PIXRASTER_FROM_RIGHT, PIXRASTER_FROM_TOP, PIXRASTER_FROM_BOTTOM
|
||||
// returns true on success, false otherwise
|
||||
bool ScanForForeground(int &loc, enum ScanModes scanMode);
|
||||
|
||||
}; // END Class Pix
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue