mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
Bazaar:Leptonica - Code restructuration
git-svn-id: svn://ultimatepp.org/upp/trunk@1570 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
5592e88a26
commit
51d82b5bad
35 changed files with 2390 additions and 2286 deletions
|
|
@ -2,108 +2,80 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
bool PixRaster::Invert(int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::Invert()
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, PIXRASTER_CLONE);
|
||||
PIX *dPix = pixInvert(NULL, sPix);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixInvert(NULL, pix);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::Invert()
|
||||
|
||||
bool PixRaster::AddConstantGray(int val, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::AddConstantGray(int val)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
Dup(page);
|
||||
PIX *sPix = GetPIX(PIXRASTER_LASTPAGE, PIXRASTER_CLONE);
|
||||
int res = pixAddConstantGray(sPix, val);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixCopy(NULL, pix);
|
||||
int res = pixAddConstantGray(dPix, val);
|
||||
if(res)
|
||||
{
|
||||
Drop();
|
||||
return false;
|
||||
pixDestroy(&dPix);
|
||||
return Pix();
|
||||
}
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::AddConstantGray()
|
||||
|
||||
bool PixRaster::MultConstantGray(int val, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::MultConstantGray(int val)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
Dup(page);
|
||||
PIX *sPix = GetPIX(PIXRASTER_LASTPAGE, PIXRASTER_CLONE);
|
||||
int res = pixMultConstantGray(sPix, val);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixCopy(NULL, pix);
|
||||
int res = pixMultConstantGray(dPix, val);
|
||||
if(res)
|
||||
{
|
||||
Drop();
|
||||
return false;
|
||||
pixDestroy(&dPix);
|
||||
return Pix();
|
||||
}
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::MultConstantGray()
|
||||
|
||||
bool PixRaster::AddGray(int page1, int page2)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::AddGray(Pix &pix2)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page1 = getTruePage(page1);
|
||||
page2 = getTruePage(page2);
|
||||
|
||||
PIX *sPix1 = pixaGetPix(pixa, page1, L_CLONE);
|
||||
PIX *sPix2 = pixaGetPix(pixa, page2, L_CLONE);
|
||||
Dup(page1);
|
||||
PIX *dPix = GetPIX(PIXRASTER_LASTPAGE, PIXRASTER_CLONE);
|
||||
PIX *res = pixAddGray(dPix, sPix1, sPix2);
|
||||
pixDestroy(&sPix1);
|
||||
pixDestroy(&sPix2);
|
||||
pixDestroy(&dPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixCopy(NULL, pix);
|
||||
PIX *res = pixAddGray(dPix, pix, pix2);
|
||||
if(!res)
|
||||
{
|
||||
Drop();
|
||||
return false;
|
||||
pixDestroy(&dPix);
|
||||
return Pix();
|
||||
}
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::AddGray()
|
||||
|
||||
bool PixRaster::SubtractGray(int page1, int page2)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::SubtractGray(Pix &pix2)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page1 = getTruePage(page1);
|
||||
page2 = getTruePage(page2);
|
||||
|
||||
PIX *sPix1 = pixaGetPix(pixa, page1, L_CLONE);
|
||||
PIX *sPix2 = pixaGetPix(pixa, page2, L_CLONE);
|
||||
PIX *dPix = pixSubtractGray(NULL, sPix1, sPix2);
|
||||
pixDestroy(&sPix1);
|
||||
pixDestroy(&sPix2);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
return Pix();
|
||||
PIX *dPix = pixCopy(NULL, pix);
|
||||
PIX *res = pixSubtractGray(dPix, pix, pix2);
|
||||
if(!res)
|
||||
{
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
|
||||
return Pix();
|
||||
}
|
||||
return Pix(&dPix);
|
||||
|
||||
} // END Pix::SubtractGray()
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -2,29 +2,21 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
bool PixRaster::CombineMasked(int destPage, int sourcePage, int maskPage)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::CombineMasked(Pix &aPix, Pix &maskPix)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
sourcePage = getTruePage(sourcePage);
|
||||
destPage = getTruePage(destPage);
|
||||
|
||||
Dup(destPage);
|
||||
PIX *dPix = GetPIX(PIXRASTER_LASTPAGE, PIXRASTER_CLONE);
|
||||
PIX *sPix = pixaGetPix(pixa, sourcePage, L_CLONE);
|
||||
PIX *mPix = pixaGetPix(pixa, maskPage, L_CLONE);
|
||||
int res = pixCombineMasked(dPix, sPix, mPix);
|
||||
pixDestroy(&sPix);
|
||||
pixDestroy(&dPix);
|
||||
pixDestroy(&mPix);
|
||||
PIX *dPix = pixCopy(NULL, pix);
|
||||
int res = pixCombineMasked(dPix, aPix, maskPix);
|
||||
if(res)
|
||||
{
|
||||
Drop();
|
||||
return false;
|
||||
pixDestroy(&dPix);
|
||||
return Pix();
|
||||
}
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::CombineMasked()
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -2,76 +2,52 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
bool PixRaster::ErodeGray(int hsize, int vsize, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::ErodeGray(int hsize, int vsize)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixErodeGray(sPix, hsize, vsize);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixErodeGray(pix, hsize, vsize);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::ErodeGray()
|
||||
|
||||
bool PixRaster::DilateGray(int hsize, int vsize, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::DilateGray(int hsize, int vsize)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixDilateGray(sPix, hsize, vsize);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixDilateGray(pix, hsize, vsize);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::DilateGray()
|
||||
|
||||
bool PixRaster::OpenGray(int hsize, int vsize, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::OpenGray(int hsize, int vsize)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixOpenGray(sPix, hsize, vsize);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixOpenGray(pix, hsize, vsize);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::OpenGray()
|
||||
|
||||
bool PixRaster::CloseGray(int hsize, int vsize, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::CloseGray(int hsize, int vsize)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixCloseGray(sPix, hsize, vsize);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixCloseGray(pix, hsize, vsize);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::CloseGray()
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -2,71 +2,37 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// top level page segmenting
|
||||
bool PixRaster::GetRegionsBinary(int page)
|
||||
PixRaster Pix::GetRegionsBinary()
|
||||
{
|
||||
PixRaster pixRaster;
|
||||
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
return PixRaster();
|
||||
|
||||
PIX *ht, *tl, *tb;
|
||||
PIX *pix = pixaGetPix(pixa, page, L_CLONE);
|
||||
int res = pixGetRegionsBinary(pix, &ht, &tl, &tb, 0);
|
||||
pixDestroy(&pix);
|
||||
if(res)
|
||||
return false;
|
||||
AddPIX(ht);
|
||||
AddPIX(tl);
|
||||
AddPIX(tb);
|
||||
pixDestroy(&ht);
|
||||
pixDestroy(&tl);
|
||||
pixDestroy(&tb);
|
||||
return PixRaster();
|
||||
Pix htPix(&ht);
|
||||
Pix tlPix(&tl);
|
||||
Pix tbPix(&tb);
|
||||
pixRaster.Add(htPix);
|
||||
pixRaster.Add(tlPix);
|
||||
pixRaster.Add(tbPix);
|
||||
|
||||
// seeks the ht page
|
||||
SeekPage(-2);
|
||||
pixRaster.SeekPage(-2);
|
||||
|
||||
return true;
|
||||
return pixRaster;
|
||||
|
||||
}
|
||||
} // END Pix::GetRegionsBinary()
|
||||
|
||||
/*
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// text baseline finding routine
|
||||
Array<Point> PixRaster::FindBaselines(int page)
|
||||
{
|
||||
PTA *pta;
|
||||
NUMA *numa;
|
||||
int res;
|
||||
l_int32 x, y;
|
||||
Array<Point> ptArray;
|
||||
|
||||
if(IsEmpty())
|
||||
return Array<Point>();
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *pix = pixaGetPix(pixa, page, L_CLONE);
|
||||
numa = pixFindBaselines(pix, &pta, 0);
|
||||
pixDestroy(&pix);
|
||||
if(!numa || !pta)
|
||||
return Array<Point>();
|
||||
for(int iPoint = 0; iPoint < ptaGetCount(pta); iPoint++)
|
||||
{
|
||||
res = ptaGetIPt(pta, iPoint, &x, &y);
|
||||
if(res)
|
||||
{
|
||||
numaDestroy(&numa);
|
||||
ptaDestroy(&pta);
|
||||
return Array<Point>();
|
||||
}
|
||||
ptArray.Add(Point(x, y));
|
||||
}
|
||||
numaDestroy(&numa);
|
||||
ptaDestroy(&pta);
|
||||
return ptArray;
|
||||
}
|
||||
*/
|
||||
|
||||
// text baseline finding routine
|
||||
Array<int> PixRaster::FindBaselines(int page)
|
||||
Array<int> Pix::FindBaselines()
|
||||
{
|
||||
NUMA *numa;
|
||||
int res;
|
||||
|
|
@ -75,11 +41,7 @@ Array<int> PixRaster::FindBaselines(int page)
|
|||
|
||||
if(IsEmpty())
|
||||
return Array<int>();
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *pix = pixaGetPix(pixa, page, L_CLONE);
|
||||
numa = pixFindBaselines(pix, NULL, 0);
|
||||
pixDestroy(&pix);
|
||||
if(!numa)
|
||||
return Array<int>();
|
||||
for(int iLine = 0; iLine < numaGetCount(numa); iLine++)
|
||||
|
|
@ -94,6 +56,7 @@ Array<int> PixRaster::FindBaselines(int page)
|
|||
}
|
||||
numaDestroy(&numa);
|
||||
return intArray;
|
||||
}
|
||||
|
||||
} // END Pix::FindBaseLines()
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -2,56 +2,41 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Rotates image (2-4-8 or 32 bpp) about center.
|
||||
bool PixRaster::RotateAM(double angle, BringInModes incolor, int page)
|
||||
Pix Pix::RotateAM(double angle, BringInModes incolor)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixRotateAM(sPix, angle, incolor);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixRotateAM(pix, angle, incolor);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
}
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
bool PixRaster::RotateAMColor(double angle, int incolor, int page)
|
||||
} // END Pix::RotateAM()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::RotateAMColor(double angle, int incolor)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixRotateAMColor(sPix, angle, incolor);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixRotateAMColor(pix, angle, incolor);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
}
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
bool PixRaster::RotateAMGray(double angle, int incolor, int page)
|
||||
} // END Pix::RotateAMColor()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::RotateAMGray(double angle, int incolor)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixRotateAMGray(sPix, angle, incolor);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixRotateAMGray(pix, angle, incolor);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
}
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
} // END Pix::RotateAMGray()
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -2,59 +2,46 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Simple top-level deskew interfaces
|
||||
bool PixRaster::Deskew(int ReductionFactor, int page)
|
||||
Pix Pix::Deskew(int ReductionFactor)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixDeskew(sPix, ReductionFactor);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixDeskew(pix, ReductionFactor);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::Deskew()
|
||||
|
||||
bool PixRaster::FindSkewAndDeskew(int ReductionFactor, double *skewAngle, double *confidenceFactor, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::FindSkewAndDeskew(int ReductionFactor, double *skewAngle, double *confidenceFactor)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
return Pix();
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
l_float32 dSkew, dConf;
|
||||
PIX *dPix = pixFindSkewAndDeskew(sPix, ReductionFactor, &dSkew, &dConf);
|
||||
pixDestroy(&sPix);
|
||||
PIX *dPix = pixFindSkewAndDeskew(pix, ReductionFactor, &dSkew, &dConf);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return Pix();
|
||||
if(skewAngle)
|
||||
*skewAngle = dSkew;
|
||||
if(confidenceFactor)
|
||||
*confidenceFactor = dConf;
|
||||
return true;
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::FindSkewAndDeskew()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Simple top-level skew angle finding interface
|
||||
bool PixRaster::FindSkew(double *pangle, double *pconf, int page)
|
||||
bool Pix::FindSkew(double *pangle, double *pconf)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
l_float32 dSkew, dConf;
|
||||
int res = pixFindSkew(sPix, &dSkew, &dConf);
|
||||
pixDestroy(&sPix);
|
||||
int res = pixFindSkew(pix, &dSkew, &dConf);
|
||||
if(res)
|
||||
return false;
|
||||
if(pangle)
|
||||
|
|
@ -63,43 +50,38 @@ bool PixRaster::FindSkew(double *pangle, double *pconf, int page)
|
|||
*pconf = dConf;
|
||||
return true;
|
||||
|
||||
}
|
||||
} // END Pix::FindSkew()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Basic angle-finding functions with all parameters
|
||||
bool PixRaster::FindSkewSweep(double *pangle, int reduction, double sweeprange, double sweepdelta, int page)
|
||||
bool Pix::FindSkewSweep(double *pangle, int reduction, double sweeprange, double sweepdelta)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
l_float32 dSkew;
|
||||
int res = pixFindSkewSweep(sPix, &dSkew, reduction, sweeprange, sweepdelta);
|
||||
pixDestroy(&sPix);
|
||||
int res = pixFindSkewSweep(pix, &dSkew, reduction, sweeprange, sweepdelta);
|
||||
if(res)
|
||||
return false;
|
||||
if(pangle)
|
||||
*pangle = dSkew;
|
||||
return true;
|
||||
|
||||
}
|
||||
} // END Pix::FindSkewSweep()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Angle-finding functions with all parameters
|
||||
bool PixRaster::FindSkewSweepAndSearch(
|
||||
bool Pix::FindSkewSweepAndSearch(
|
||||
double *pangle, double *pconf,
|
||||
int redsweep, int redsearch,
|
||||
double sweeprange, double sweepdelta,
|
||||
double minbsdelta,
|
||||
int page)
|
||||
double minbsdelta)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
l_float32 dSkew, dConf;
|
||||
int res = pixFindSkewSweepAndSearch(sPix, &dSkew, &dConf, redsweep, redsearch, sweeprange, sweepdelta, minbsdelta);
|
||||
pixDestroy(&sPix);
|
||||
int res = pixFindSkewSweepAndSearch(pix, &dSkew, &dConf, redsweep, redsearch, sweeprange, sweepdelta, minbsdelta);
|
||||
if(res)
|
||||
return false;
|
||||
if(pangle)
|
||||
|
|
@ -108,24 +90,19 @@ bool PixRaster::FindSkewSweepAndSearch(
|
|||
*pconf = dConf;
|
||||
return true;
|
||||
|
||||
}
|
||||
} // END Pix::FindSkewSweepAndSearch()
|
||||
|
||||
bool PixRaster::DeskewLocal(int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::DeskewLocal()
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
return Pix();
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixDeskewLocal(sPix, 0, 0, 0, 0.0, 0.0, 0.0);
|
||||
pixDestroy(&sPix);
|
||||
PIX *dPix = pixDeskewLocal(pix, 0, 0, 0, 0.0, 0.0, 0.0);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
pixDestroy(&dPix);
|
||||
return true;
|
||||
}
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
} // END Pix::DeskewLocal()
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -2,245 +2,167 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
bool PixRaster::DitherToBinary(int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::DitherToBinary()
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
return Pix();
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixDitherToBinary(sPix);
|
||||
pixDestroy(&sPix);
|
||||
PIX *dPix = pixDitherToBinary(pix);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::DitherToBinary()
|
||||
|
||||
bool PixRaster::DitherToBinarySpec(int lowerclip, int upperclip, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::DitherToBinarySpec(int lowerclip, int upperclip)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixDitherToBinarySpec(sPix, lowerclip, upperclip);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixDitherToBinarySpec(pix, lowerclip, upperclip);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::DitherToBinarySpec()
|
||||
|
||||
// threshold the image -- warning, operates ONLY on grayscale pixmaps
|
||||
// original image is unchanged - a new modified image at raster's end
|
||||
bool PixRaster::ThresholdToBinary(int threshold, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::ThresholdToBinary(int threshold)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixThresholdToBinary(sPix, threshold);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixThresholdToBinary(pix, threshold);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
}
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
bool PixRaster::VarThresholdToBinary(int thresholdPage, int page)
|
||||
} // END Pix::ThresholdToBinary()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::VarThresholdToBinary(Pix &thresholdPix)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
thresholdPage = getTruePage(thresholdPage);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *tPix = pixaGetPix(pixa, thresholdPage, L_CLONE);
|
||||
PIX *dPix = pixVarThresholdToBinary(sPix, tPix);
|
||||
pixDestroy(&sPix);
|
||||
pixDestroy(&tPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixVarThresholdToBinary(pix, thresholdPix);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::VarThresholdToBinary()
|
||||
|
||||
bool PixRaster::DitherToBinaryLUT(int lowerclip, int upperclip, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::DitherToBinaryLUT(int lowerclip, int upperclip)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixDitherToBinaryLUT(sPix, lowerclip, upperclip);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixDitherToBinaryLUT(pix, lowerclip, upperclip);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::DitherToBinaryLUT()
|
||||
|
||||
bool PixRaster::GenerateMaskByValue(int val, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::GenerateMaskByValue(int val)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixGenerateMaskByValue(sPix, val);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixGenerateMaskByValue(pix, val);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::GenerateMaskByValue()
|
||||
|
||||
bool PixRaster::GenerateMaskByBand(int lower, int upper, int inband, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::GenerateMaskByBand(int lower, int upper, int inband)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixGenerateMaskByBand(sPix, lower, upper, inband);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixGenerateMaskByBand(pix, lower, upper, inband);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::GenerateMaskByBand()
|
||||
|
||||
bool PixRaster::DitherTo2bpp(int cmapflag, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::DitherTo2bpp(int cmapflag)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixDitherTo2bpp(sPix, cmapflag);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixDitherTo2bpp(pix, cmapflag);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::DitherTo2bpp()
|
||||
|
||||
bool PixRaster::DitherTo2bppSpec(int lowerclip, int upperclip, int cmapflag, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::DitherTo2bppSpec(int lowerclip, int upperclip, int cmapflag)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixDitherTo2bppSpec(sPix, lowerclip, upperclip, cmapflag);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixDitherTo2bppSpec(pix, lowerclip, upperclip, cmapflag);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::DitherTo2bppSpec()
|
||||
|
||||
bool PixRaster::ThresholdTo2bpp(int nlevels, int cmapflag, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::ThresholdTo2bpp(int nlevels, int cmapflag)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixThresholdTo2bpp(sPix, nlevels, cmapflag);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixThresholdTo2bpp(pix, nlevels, cmapflag);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::ThresholdTo2bpp()
|
||||
|
||||
bool PixRaster::ThresholdTo4bpp(int nlevels, int cmapflag, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::ThresholdTo4bpp(int nlevels, int cmapflag)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixThresholdTo4bpp(sPix, nlevels, cmapflag);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixThresholdTo4bpp(pix, nlevels, cmapflag);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::ThresholdTo4bpp()
|
||||
|
||||
bool PixRaster::ThresholdOn8bpp(int nlevels, int cmapflag, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::ThresholdOn8bpp(int nlevels, int cmapflag)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixThresholdOn8bpp(sPix, nlevels, cmapflag);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixThresholdOn8bpp(pix, nlevels, cmapflag);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::ThresholdOn8bpp()
|
||||
|
||||
bool PixRaster::ThresholdGrayArb(const char *edgevals, int outdepth, int use_average, int setblack, int setwhite, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::ThresholdGrayArb(const char *edgevals, int outdepth, int use_average, int setblack, int setwhite)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixThresholdGrayArb(sPix, edgevals, outdepth, use_average, setblack, setwhite);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixThresholdGrayArb(pix, edgevals, outdepth, use_average, setblack, setwhite);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::ThresholdGrayArb()
|
||||
|
||||
Buffer<int> PixRaster::MakeGrayQuantIndexTable(int nlevels)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Buffer<int> Pix::MakeGrayQuantIndexTable(int nlevels)
|
||||
{
|
||||
Buffer<int>buf;
|
||||
|
||||
|
|
@ -254,9 +176,10 @@ Buffer<int> PixRaster::MakeGrayQuantIndexTable(int nlevels)
|
|||
}
|
||||
return buf;
|
||||
|
||||
}
|
||||
} // END Pix::MakeGrayQuantIndexTable()
|
||||
|
||||
Buffer<int> PixRaster::MakeGrayQuantTargetTable(int nlevels, int depth)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Buffer<int> Pix::MakeGrayQuantTargetTable(int nlevels, int depth)
|
||||
{
|
||||
Buffer<int>buf;
|
||||
|
||||
|
|
@ -270,81 +193,54 @@ Buffer<int> PixRaster::MakeGrayQuantTargetTable(int nlevels, int depth)
|
|||
}
|
||||
return buf;
|
||||
|
||||
}
|
||||
} // END Pix::MakeGrayQuantTargetTable()
|
||||
|
||||
bool PixRaster::GenerateMaskByBand32(unsigned refval, int delm, int delp, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::GenerateMaskByBand32(unsigned refval, int delm, int delp)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixGenerateMaskByBand32(sPix, refval, delm, delp);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixGenerateMaskByBand32(pix, refval, delm, delp);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::GenerateMaskByBand32()
|
||||
|
||||
bool PixRaster::GenerateMaskByDiscr32(unsigned refval1, unsigned refval2, int distflag, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::GenerateMaskByDiscr32(unsigned refval1, unsigned refval2, int distflag)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixGenerateMaskByDiscr32(sPix, refval1, refval2, distflag);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixGenerateMaskByDiscr32(pix, refval1, refval2, distflag);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::GenerateMaskByDiscr32()
|
||||
|
||||
bool PixRaster::GrayQuantFromHisto(int mPage, double minfract, int maxsize, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::GrayQuantFromHisto(Pix &mPix, double minfract, int maxsize)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
mPage = getTruePage(mPage);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *mPix = pixaGetPix(pixa, mPage, L_CLONE);
|
||||
PIX *dPix = pixGrayQuantFromHisto(NULL, sPix, mPix, minfract, maxsize);
|
||||
pixDestroy(&sPix);
|
||||
pixDestroy(&mPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixGrayQuantFromHisto(NULL, pix, mPix, minfract, maxsize);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::GrayQuantFromHisto()
|
||||
|
||||
bool PixRaster::ThresholdToValue(int threshval, int setval, int page)
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Pix Pix::ThresholdToValue(int threshval, int setval)
|
||||
{
|
||||
if(IsEmpty())
|
||||
return false;
|
||||
page = getTruePage(page);
|
||||
|
||||
PIX *sPix = pixaGetPix(pixa, page, L_CLONE);
|
||||
PIX *dPix = pixThresholdToValue(NULL, sPix, threshval, setval);
|
||||
pixDestroy(&sPix);
|
||||
return Pix();
|
||||
PIX *dPix = pixThresholdToValue(NULL, pix, threshval, setval);
|
||||
if(!dPix)
|
||||
return false;
|
||||
AddPIX(dPix, PIXRASTER_CLONE);
|
||||
pixDestroy(&dPix);
|
||||
SeekPage(PIXRASTER_LASTPAGE);
|
||||
return true;
|
||||
return Pix();
|
||||
return Pix(&dPix);
|
||||
|
||||
}
|
||||
} // END Pix::ThresholdToValue()
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -1,206 +0,0 @@
|
|||
Raster::Line PixRaster::GetLine(int line)
|
||||
{
|
||||
RGBA *rgba, *rgbaPtr;
|
||||
PIX *pix;
|
||||
int width;
|
||||
PIXCMAP *colormap;
|
||||
l_uint32 *pixPtr;
|
||||
l_int32 mask;
|
||||
byte shift;
|
||||
int iPix;
|
||||
dword grayVal;
|
||||
|
||||
// empty line on empty image
|
||||
if(!pixa || !pixaGetCount(pixa))
|
||||
return Raster::Line();
|
||||
|
||||
// gets current PIX handle
|
||||
pix = pixaGetPix(pixa, curPage, L_CLONE);
|
||||
|
||||
// if line out of bounds, return empty line
|
||||
if(line < 0 || line >= pixGetHeight(pix))
|
||||
{
|
||||
pixDestroy(&pix);
|
||||
return Raster::Line();
|
||||
}
|
||||
|
||||
// gets image width
|
||||
width = pixGetWidth(pix);
|
||||
|
||||
// if PIX is already in 32 bpp format, just return
|
||||
// a line with a pointer to data
|
||||
if(pixGetDepth(pix) >= 24)
|
||||
{
|
||||
rgba = (RGBA *)(pixGetData(pix) + width * line);
|
||||
pixDestroy(&pix);
|
||||
return Raster::Line(rgba, false);
|
||||
}
|
||||
|
||||
// allocates an RGBA buffer for data
|
||||
rgba = new RGBA[width];
|
||||
rgbaPtr = rgba;
|
||||
|
||||
// handle differently pixs with or without colormap
|
||||
colormap = pixGetColormap(pix);
|
||||
pixPtr = pixGetData(pix) + line * pixGetWpl(pix);
|
||||
if(colormap)
|
||||
{
|
||||
switch(pixGetDepth(pix))
|
||||
{
|
||||
case 1:
|
||||
for(iPix = 0, mask = 0x80000000; iPix < width; iPix++)
|
||||
{
|
||||
*rgbaPtr++ = ((RGBA *)colormap)[(*pixPtr & mask ? 1 : 0)];
|
||||
mask >>= 1;
|
||||
if(!mask)
|
||||
{
|
||||
mask = 0x80000000;
|
||||
pixPtr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for(iPix = 0, mask = 0xC0000000, shift = 30; iPix < width; iPix++)
|
||||
{
|
||||
*rgbaPtr++ = ((RGBA *)colormap)[(*pixPtr & mask) >> shift];
|
||||
mask >>= 2;
|
||||
shift -= 2;
|
||||
if(!mask)
|
||||
{
|
||||
mask = 0xC0000000;
|
||||
shift = 30;
|
||||
pixPtr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
for(iPix = 0, mask = 0xF0000000, shift = 28; iPix < width; iPix++)
|
||||
{
|
||||
*rgbaPtr++ = ((RGBA *)colormap)[(*pixPtr & mask) >> shift];
|
||||
mask >>= 4;
|
||||
shift -= 4;
|
||||
if(!mask)
|
||||
{
|
||||
mask = 0xF0000000;
|
||||
shift = 28;
|
||||
pixPtr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
for(iPix = 0, mask = 0xFF000000, shift = 24; iPix < width; iPix++)
|
||||
{
|
||||
*rgbaPtr++ = ((RGBA *)colormap)[(*pixPtr & mask) >> shift];
|
||||
mask >>= 8;
|
||||
shift -= 8;
|
||||
if(!mask)
|
||||
{
|
||||
mask = 0xFF000000;
|
||||
shift = 24;
|
||||
pixPtr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
memset(rgba, 4*width, 0);
|
||||
break;
|
||||
|
||||
} // switch
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(pixGetDepth(pix))
|
||||
{
|
||||
case 1:
|
||||
for(iPix = 0, mask = 0x80000000; iPix < width; iPix++)
|
||||
{
|
||||
*(dword *)rgbaPtr++ = *pixPtr & mask ? 0x00ffffff : 0x00000000;
|
||||
mask >>= 1;
|
||||
if(!mask)
|
||||
{
|
||||
mask = 0x80000000;
|
||||
pixPtr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for(iPix = 0, mask = 0xC0000000, shift = 30; iPix < width; iPix++)
|
||||
{
|
||||
grayVal = ((*pixPtr & mask) >> shift) << 6;
|
||||
*(dword *)rgbaPtr++ = grayVal | (grayVal << 8) | (grayVal << 16);
|
||||
mask >>= 2;
|
||||
shift -= 2;
|
||||
if(!mask)
|
||||
{
|
||||
mask = 0xC0000000;
|
||||
shift = 30;
|
||||
pixPtr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
for(iPix = 0, mask = 0xF0000000, shift = 28; iPix < width; iPix++)
|
||||
{
|
||||
grayVal = ((*pixPtr & mask) >> shift) << 4;
|
||||
*(dword *)rgbaPtr++ = grayVal | (grayVal << 8) | (grayVal << 16);
|
||||
mask >>= 4;
|
||||
shift -= 4;
|
||||
if(!mask)
|
||||
{
|
||||
mask = 0xF0000000;
|
||||
shift = 28;
|
||||
pixPtr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
for(iPix = 0, mask = 0xFF000000, shift = 24; iPix < width; iPix++)
|
||||
{
|
||||
grayVal = (*pixPtr & mask) >> shift;
|
||||
*(dword *)rgbaPtr++ = grayVal | (grayVal << 8) | (grayVal << 16);
|
||||
mask >>= 8;
|
||||
shift -= 8;
|
||||
if(!mask)
|
||||
{
|
||||
mask = 0xFF000000;
|
||||
shift = 24;
|
||||
pixPtr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 16:
|
||||
for(iPix = 0, mask = 0xFFFF0000, shift = 16; iPix < width; iPix++)
|
||||
{
|
||||
grayVal = ((*pixPtr & mask) >> shift) >> 4;
|
||||
*(dword *)rgbaPtr++ = grayVal | (grayVal << 8) | (grayVal << 16);
|
||||
mask >>= 16;
|
||||
shift -= 16;
|
||||
if(!mask)
|
||||
{
|
||||
mask = 0xFFFF0000;
|
||||
shift = 16;
|
||||
pixPtr++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
memset(rgba, 4*width, 0);
|
||||
break;
|
||||
|
||||
} // switch
|
||||
} // if colormap
|
||||
|
||||
pixDestroy(&pix);
|
||||
return Raster::Line(rgba, true);
|
||||
|
||||
} // END PixRaster::GetLine()
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -3,7 +3,11 @@
|
|||
|
||||
#include <Draw/Draw.h>
|
||||
|
||||
#define Pix _Pix
|
||||
#include "lib/allheaders.h"
|
||||
#undef Pix
|
||||
|
||||
#include "PolyMarker.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
|
|
@ -23,167 +27,184 @@ NAMESPACE_UPP
|
|||
#define PIXRASTER_END 0x8ffffffc
|
||||
#define PIXRASTER_BEGIN 0x00000000
|
||||
|
||||
// raster class wrapping Leptonica PIX and PIXA structures
|
||||
class PixRaster : public Raster
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// base class for Pix and PixRaster -- used mainly to have a common base class for PixRasterCtrl
|
||||
class PixBase : public Raster
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
typedef PixBase CLASSNAME;
|
||||
|
||||
// array of Leptonica PIXs
|
||||
// can contain just one PIX for single page images
|
||||
PIXA *pixa;
|
||||
virtual void SeekPage(int page) {};
|
||||
virtual int GetPageCount() { return 1; }
|
||||
virtual int GetActivePage() { return 0; }
|
||||
|
||||
// currently active page for multipage images
|
||||
int curPage;
|
||||
// gets underlying PIX object
|
||||
// WARNING -- Pix has ownership of it, so DON'T free nor destroy it
|
||||
virtual PIX *GetPIX(int page = PIXRASTER_CURPAGE) = 0;
|
||||
|
||||
// standard Raster functions -- they operate on active page
|
||||
virtual Size GetSize() { return GetSizeEx(PIXRASTER_CURPAGE); }
|
||||
virtual Raster::Info GetInfo() { return GetInfoEx(PIXRASTER_CURPAGE); }
|
||||
virtual Raster::Line GetLine(int line) { return GetLineEx(line, PIXRASTER_CURPAGE); }
|
||||
virtual int GetPaletteCount() { return GetPaletteCountEx(PIXRASTER_CURPAGE); }
|
||||
virtual const RGBA *GetPalette() { return GetPaletteEx(PIXRASTER_CURPAGE); }
|
||||
virtual const RasterFormat *GetFormat() { return GetFormatEx(PIXRASTER_CURPAGE); }
|
||||
virtual int GetWidth() { return GetSize().cx; }
|
||||
virtual int GetHeight() { return GetSize().cy; }
|
||||
virtual PolyMarkers *GetPolyMarkers() { return GetPolyMarkersEx(PIXRASTER_CURPAGE); }
|
||||
|
||||
|
||||
// extended Raster functions -- they allow to query
|
||||
// a given page inside raster
|
||||
virtual Size GetSizeEx(int page) = 0;
|
||||
virtual Info GetInfoEx(int page) = 0;
|
||||
virtual Line GetLineEx(int line, int page) = 0;
|
||||
virtual int GetPaletteCountEx(int page) = 0;
|
||||
virtual const RGBA *GetPaletteEx(int page) = 0;
|
||||
virtual const RasterFormat *GetFormatEx(int page) = 0;
|
||||
virtual int GetWidthEx(int page) { return GetSizeEx(page).cx; }
|
||||
virtual int GetHeightEx(int page) { return GetSizeEx(page).cy; }
|
||||
virtual PolyMarkers *GetPolyMarkersEx(int page) = 0;
|
||||
|
||||
virtual bool IsEmpty() = 0;
|
||||
operator bool() { return !IsEmpty(); }
|
||||
|
||||
virtual void Clear() = 0;
|
||||
|
||||
}; // END Class PixBase
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// class wrapping Leptonica PIX image -- it's a single page raster format
|
||||
class PixRaster;
|
||||
class Pix : public PixBase
|
||||
{
|
||||
// give PixRaster access to private members
|
||||
friend class PixRaster;
|
||||
|
||||
public:
|
||||
typedef Pix CLASSNAME;
|
||||
|
||||
private:
|
||||
|
||||
// the Leptonica PIX
|
||||
PIX *pix;
|
||||
|
||||
// raster format
|
||||
Array<RasterFormat *>formats;
|
||||
RasterFormat *rasterFormat;
|
||||
|
||||
// sets raster format depending on page's pix format
|
||||
void SetRasterFormat(int page);
|
||||
// local palette
|
||||
RGBA *localPalette;
|
||||
|
||||
// checks wether page format is valid
|
||||
bool IsRasterFormatValid(int page = PIXRASTER_CURPAGE);
|
||||
// polygon markers
|
||||
Array<PolyMarker>polyMarkers;
|
||||
|
||||
// destroys page format
|
||||
void DestroyRasterFormat(int page = PIXRASTER_CURPAGE);
|
||||
|
||||
// local copy of palettes, if any
|
||||
Array<RGBA *>localPalettes;
|
||||
|
||||
// synthesyze grayscale palettes
|
||||
void CreateGrayPalette2(int page);
|
||||
void CreateGrayPalette4(int page);
|
||||
void CreateGrayPalette16(int page);
|
||||
void CreateGrayPalette256(int page);
|
||||
|
||||
// convert PIX palette
|
||||
void ConvertPIXPalette(PIXCMAP *colormap, int page);
|
||||
|
||||
// destroys local palette
|
||||
void DestroyLocalPalette(int page = PIXRASTER_CURPAGE);
|
||||
|
||||
// checks wether local palette is valid
|
||||
bool IsLocalPaletteValid(int page = PIXRASTER_CURPAGE);
|
||||
|
||||
// raster loading/conversion routines
|
||||
PIX *LoadRASTER_RGBA(Raster &raster);
|
||||
|
||||
PIX *LoadRASTER_1(Raster &raster);
|
||||
PIX *LoadRASTER_2(Raster &raster);
|
||||
PIX *LoadRASTER_4(Raster &raster);
|
||||
PIX *LoadRASTER_8(Raster &raster);
|
||||
PIX *LoadRASTER_8ALPHA(Raster &raster);
|
||||
PIX *LoadRASTER_16(Raster &raster);
|
||||
PIX *LoadRASTER_24(Raster &raster);
|
||||
PIX *LoadRASTER_32(Raster &raster);
|
||||
|
||||
PIX *LoadRASTER_1_MSBFIRST(Raster &raster);
|
||||
PIX *LoadRASTER_2_MSBFIRST(Raster &raster);
|
||||
PIX *LoadRASTER_4_MSBFIRST(Raster &raster);
|
||||
PIX *LoadRASTER_8_MSBFIRST(Raster &raster);
|
||||
PIX *LoadRASTER_8ALPHA_MSBFIRST(Raster &raster);
|
||||
PIX *LoadRASTER_16_MSBFIRST(Raster &raster);
|
||||
PIX *LoadRASTER_24_MSBFIRST(Raster &raster);
|
||||
PIX *LoadRASTER_32_MSBFIRST(Raster &raster);
|
||||
|
||||
// gets real page
|
||||
int getTruePage(int page = PIXRASTER_CURPAGE);
|
||||
protected:
|
||||
|
||||
// internal destructor
|
||||
void Destroy(void);
|
||||
void Destroy();
|
||||
|
||||
// sets raster format depending on pix format
|
||||
void SetRasterFormat();
|
||||
|
||||
// synthesyze grayscale palettes
|
||||
void CreateGrayPalette2();
|
||||
void CreateGrayPalette4();
|
||||
void CreateGrayPalette16();
|
||||
void CreateGrayPalette256();
|
||||
|
||||
// convert PIX palette
|
||||
void ConvertPIXPalette(PIXCMAP *colormap);
|
||||
|
||||
// raster loading/conversion routines
|
||||
bool LoadRASTER_RGBA(Raster &raster);
|
||||
|
||||
bool LoadRASTER_1(Raster &raster);
|
||||
bool LoadRASTER_2(Raster &raster);
|
||||
bool LoadRASTER_4(Raster &raster);
|
||||
bool LoadRASTER_8(Raster &raster);
|
||||
bool LoadRASTER_8ALPHA(Raster &raster);
|
||||
bool LoadRASTER_16(Raster &raster);
|
||||
bool LoadRASTER_24(Raster &raster);
|
||||
bool LoadRASTER_32(Raster &raster);
|
||||
|
||||
bool LoadRASTER_1_MSBFIRST(Raster &raster);
|
||||
bool LoadRASTER_2_MSBFIRST(Raster &raster);
|
||||
bool LoadRASTER_4_MSBFIRST(Raster &raster);
|
||||
bool LoadRASTER_8_MSBFIRST(Raster &raster);
|
||||
bool LoadRASTER_8ALPHA_MSBFIRST(Raster &raster);
|
||||
bool LoadRASTER_16_MSBFIRST(Raster &raster);
|
||||
bool LoadRASTER_24_MSBFIRST(Raster &raster);
|
||||
bool LoadRASTER_32_MSBFIRST(Raster &raster);
|
||||
|
||||
public:
|
||||
|
||||
// pixmaps copy modes
|
||||
enum CopyModes { PIXRASTER_CLONE = L_CLONE, PIXRASTER_COPY = L_COPY, PIXRASTER_COPY_CLONE = L_COPY_CLONE, PIXRASTER_REF };
|
||||
// gets underlying PIX object
|
||||
// WARNING -- Pix has ownership of it, so DON'T free nor destroy it
|
||||
virtual PIX *GetPIX(int page = PIXRASTER_CURPAGE) { return pix; }
|
||||
operator PIX*() { return GetPIX(PIXRASTER_CURPAGE); }
|
||||
|
||||
// bring-in color modes
|
||||
enum BringInModes { PIXRASTER_BRING_IN_WHITE = L_BRING_IN_WHITE, PIXRASTER_BRING_IN_BLACK = L_BRING_IN_BLACK };
|
||||
|
||||
// constructor -- empty raster
|
||||
PixRaster();
|
||||
// loads Pix from another raster object
|
||||
void Load(Raster& raster, bool deepCopy = false, int page = PIXRASTER_CURPAGE);
|
||||
|
||||
// constructor -- takes a Leptonica Pix
|
||||
// PIX get cloned and its reference count increased or copied
|
||||
PixRaster(PIX *pix, CopyModes copyMode = PIXRASTER_CLONE);
|
||||
// empty constructor -- sets NULL PIX
|
||||
Pix();
|
||||
|
||||
// constructor -- takes an array of Leptonica Pix
|
||||
// PIXA gets cloned and its reference count increased
|
||||
PixRaster(PIXA *pixa, CopyModes copyMode = PIXRASTER_COPY_CLONE);
|
||||
// creates a PIX in given format and size
|
||||
Pix(int width, int height, int depth, RGBA *colorTable = NULL);
|
||||
|
||||
// destructor -- must free PIXA array
|
||||
~PixRaster() { Destroy() ; }
|
||||
// constructor -- takes a Leptonica PIX
|
||||
// TAKES OWNERSHIP of underlying PIX object which is NULLed
|
||||
Pix(PIX **_pix);
|
||||
|
||||
virtual void SeekPage(int page);
|
||||
virtual int GetPageCount();
|
||||
virtual int GetActivePage();
|
||||
// copy constructor -- reference increments underlying PIX
|
||||
Pix(Pix const &_pix);
|
||||
|
||||
// standard Raster functions -- they operate on active page
|
||||
virtual Size GetSize(void) { return GetSize(PIXRASTER_CURPAGE); }
|
||||
virtual Info GetInfo(void) { return GetInfo(PIXRASTER_CURPAGE); }
|
||||
virtual Line GetLine(int line) { return GetLine(line, PIXRASTER_CURPAGE); }
|
||||
virtual int GetPaletteCount() { return GetPaletteCount(PIXRASTER_CURPAGE); }
|
||||
virtual const RGBA *GetPalette() { return GetPalette(PIXRASTER_CURPAGE); }
|
||||
virtual const RasterFormat *GetFormat() { return GetFormat(PIXRASTER_CURPAGE); }
|
||||
virtual int GetWidth() { return GetSize().cx; }
|
||||
virtual int GetHeight() { return GetSize().cy; }
|
||||
// deep copy constructor -- deep copy of underlying PIX
|
||||
Pix(Pix const &_pix, int i);
|
||||
|
||||
// creation of Pix from a raster object
|
||||
Pix(Raster &raster, bool deepCopy = false, int page = PIXRASTER_CURPAGE);
|
||||
|
||||
// creation of Pix from file/stream
|
||||
Pix(FileIn &fs, int page = 0);
|
||||
Pix(String const &fileName, int page = 0);
|
||||
|
||||
// destructor
|
||||
~Pix();
|
||||
|
||||
// assignment -- increment reference of underlying PIX
|
||||
Pix &operator=(Pix &pix);
|
||||
|
||||
// deep copy -- deep copies underlying PIX
|
||||
Pix &operator <<=(Pix &pix);
|
||||
Pix &DeepCopy(Pix &pix);
|
||||
|
||||
// checks wether Pix is empty
|
||||
virtual bool IsEmpty() { return (pix == NULL); }
|
||||
|
||||
// empties the image
|
||||
virtual void Clear() { Destroy(); }
|
||||
|
||||
// extended Raster functions -- they allow to query
|
||||
// a given page inside raster
|
||||
virtual Size GetSize(int page);
|
||||
virtual Info GetInfo(int page);
|
||||
virtual Line GetLine(int line, int page);
|
||||
virtual int GetPaletteCount(int page);
|
||||
virtual const RGBA *GetPalette(int page);
|
||||
virtual const RasterFormat *GetFormat(int page);
|
||||
virtual int GetWidth(int page) { return GetSize(page).cx; }
|
||||
virtual int GetHeight(int page) { return GetSize(page).cy; }
|
||||
virtual Size GetSizeEx(int page);
|
||||
virtual Info GetInfoEx(int page);
|
||||
virtual Line GetLineEx(int line, int page);
|
||||
virtual int GetPaletteCountEx(int page);
|
||||
virtual const RGBA *GetPaletteEx(int page);
|
||||
virtual const RasterFormat *GetFormatEx(int page);
|
||||
|
||||
// check wether pixraster has images
|
||||
bool IsEmpty(void);
|
||||
|
||||
// gets PIX and PIX array from raster
|
||||
// by default objects get it's reference count increased, so they
|
||||
// must be freed by pixDestroy() - can be changed by copyMode parameter
|
||||
PIX *GetPIX(int page = PIXRASTER_CURPAGE, CopyModes copyMode = PIXRASTER_REF);
|
||||
PIXA *GetPIXA(CopyModes copyMode = PIXRASTER_REF);
|
||||
operator PIX*(void) { return GetPIX(PIXRASTER_CURPAGE, PIXRASTER_REF); }
|
||||
|
||||
// sets PIX and PIX array
|
||||
void SetPIX(PIX *pix, int page = PIXRASTER_CURPAGE, CopyModes copyMode = PIXRASTER_CLONE);
|
||||
void SetPIXA(PIXA *pixa, CopyModes copyMode = PIXRASTER_COPY_CLONE);
|
||||
|
||||
// adds a PIX or a PIX array
|
||||
void AddPIX(PIX *pix, CopyModes copyMode = PIXRASTER_CLONE);
|
||||
void AddPIXA(PIXA *_pixa, CopyModes copyMode = PIXRASTER_COPY_CLONE);
|
||||
|
||||
// inserts a PIX or a PIX array
|
||||
void InsertPIX(PIX *pix, int where = PIXRASTER_CURPAGE, CopyModes copyMode = PIXRASTER_COPY_CLONE);
|
||||
void InsertPIXA(PIXA *pixa, int where = PIXRASTER_CURPAGE, CopyModes copyMode = PIXRASTER_COPY_CLONE);
|
||||
|
||||
// removes a PIX or a series of PIX
|
||||
void RemovePIX(int startPage = PIXRASTER_CURPAGE, int count = 1);
|
||||
|
||||
// duplicates a page at the end of array (useful for stack-like operations)
|
||||
// NOTE: it seeks added page too
|
||||
void Dup(int page = PIXRASTER_CURPAGE);
|
||||
|
||||
// Drops last page(s) of array (ditto)
|
||||
// NOTE: it seeks last page too
|
||||
void Drop(int count = 1);
|
||||
|
||||
// loads Pix from another raster object
|
||||
void Load(Raster& raster, bool Append = false, CopyModes copyMode = PIXRASTER_CLONE);
|
||||
|
||||
// sets/appends a source raster
|
||||
void operator=(Raster &raster) { Load(raster, false, PIXRASTER_COPY); }
|
||||
void operator+=(Raster &raster) { Load(raster, true, PIXRASTER_COPY); }
|
||||
// gets polygon markers
|
||||
virtual PolyMarkers *GetPolyMarkers() { return &polyMarkers; }
|
||||
virtual PolyMarkers *GetPolyMarkersEx(int) { return &polyMarkers; }
|
||||
|
||||
// file I/O
|
||||
bool Load(FileIn &fs, bool Append = false);
|
||||
bool Load(String fileName, bool Append = false);
|
||||
bool Save(String fileName, int page = PIXRASTER_CURPAGE); // @@ to do - add compression and type handling
|
||||
bool SaveAll(String fileName);
|
||||
bool Load(FileIn &fs, int page = 0);
|
||||
bool Load(String fileName, int page = 0);
|
||||
bool Save(String fileName); // @@ to do - add compression and type handling
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////// LEPTONICA OPERATIONS //////////////////////////////////////////
|
||||
|
|
@ -192,53 +213,51 @@ class PixRaster : public Raster
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMAGE THRESHOLDING //
|
||||
|
||||
bool DitherToBinary(int page = PIXRASTER_CURPAGE);
|
||||
bool DitherToBinarySpec(int lowerclip, int upperclip, int page = PIXRASTER_CURPAGE);
|
||||
Pix DitherToBinary();
|
||||
Pix DitherToBinarySpec(int lowerclip, int upperclip);
|
||||
|
||||
// threshold the image -- warning, operates ONLY on grayscale pixmaps
|
||||
// original image is unchanged - a new modified image at raster's end
|
||||
bool ThresholdToBinary(int threshold, int page = PIXRASTER_CURPAGE);
|
||||
Pix ThresholdToBinary(int threshold);
|
||||
|
||||
bool VarThresholdToBinary(int thresholdPage, int page = PIXRASTER_CURPAGE);
|
||||
bool DitherToBinaryLUT(int lowerclip, int upperclip, int page = PIXRASTER_CURPAGE);
|
||||
bool GenerateMaskByValue(int val, int page = PIXRASTER_CURPAGE);
|
||||
bool GenerateMaskByBand(int lower, int upper, int inband, int page = PIXRASTER_CURPAGE);
|
||||
bool DitherTo2bpp(int cmapflag, int page = PIXRASTER_CURPAGE);
|
||||
bool DitherTo2bppSpec(int lowerclip, int upperclip, int cmapflag, int page = PIXRASTER_CURPAGE);
|
||||
bool ThresholdTo2bpp(int nlevels, int cmapflag, int page = PIXRASTER_CURPAGE);
|
||||
bool ThresholdTo4bpp(int nlevels, int cmapflag, int page = PIXRASTER_CURPAGE);
|
||||
bool ThresholdOn8bpp(int nlevels, int cmapflag, int page = PIXRASTER_CURPAGE);
|
||||
bool ThresholdGrayArb(const char *edgevals, int outdepth, int use_average, int setblack, int setwhite, int page = PIXRASTER_CURPAGE);
|
||||
Pix VarThresholdToBinary(Pix &thresholdPix);
|
||||
Pix DitherToBinaryLUT(int lowerclip, int upperclip);
|
||||
Pix GenerateMaskByValue(int val);
|
||||
Pix GenerateMaskByBand(int lower, int upper, int inband);
|
||||
Pix DitherTo2bpp(int cmapflag);
|
||||
Pix DitherTo2bppSpec(int lowerclip, int upperclip, int cmapflag);
|
||||
Pix ThresholdTo2bpp(int nlevels, int cmapflag);
|
||||
Pix ThresholdTo4bpp(int nlevels, int cmapflag);
|
||||
Pix ThresholdOn8bpp(int nlevels, int cmapflag);
|
||||
Pix ThresholdGrayArb(const char *edgevals, int outdepth, int use_average, int setblack, int setwhite);
|
||||
Buffer<int> MakeGrayQuantIndexTable(int nlevels);
|
||||
Buffer<int> MakeGrayQuantTargetTable(int nlevels, int depth);
|
||||
bool GenerateMaskByBand32(unsigned refval, int delm, int delp, int page = PIXRASTER_CURPAGE);
|
||||
bool GenerateMaskByDiscr32(unsigned refval1, unsigned refval2, int distflag, int page = PIXRASTER_CURPAGE);
|
||||
bool GrayQuantFromHisto(int mPage, double minfract, int maxsize, int page = PIXRASTER_CURPAGE);
|
||||
Pix GenerateMaskByBand32(unsigned refval, int delm, int delp);
|
||||
Pix GenerateMaskByDiscr32(unsigned refval1, unsigned refval2, int distflag);
|
||||
Pix GrayQuantFromHisto(Pix &mPix, double minfract, int maxsize);
|
||||
|
||||
bool ThresholdToValue(int threshval, int setval, int page = PIXRASTER_CURPAGE);
|
||||
Pix ThresholdToValue(int threshval, int setval);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// SKEW REMOVAL //
|
||||
|
||||
// Simple top-level deskew interfaces
|
||||
bool Deskew(int ReductionFactor = 1, int page = PIXRASTER_CURPAGE);
|
||||
bool FindSkewAndDeskew(int ReductionFactor, double *skewAngle = NULL, double *confidenceFactor = NULL, int page = PIXRASTER_CURPAGE);
|
||||
Pix Deskew(int ReductionFactor = 1);
|
||||
Pix FindSkewAndDeskew(int ReductionFactor, double *skewAngle = NULL, double *confidenceFactor = NULL);
|
||||
|
||||
// Simple top-level skew angle finding interface
|
||||
bool FindSkew(double *pangle, double *pconf = NULL, int page = PIXRASTER_CURPAGE);
|
||||
bool FindSkew(double *pangle, double *pconf = NULL);
|
||||
|
||||
// Basic angle-finding functions with all parameters
|
||||
bool FindSkewSweep(double *pangle, int reduction, double sweeprange, double sweepdelta, int page = PIXRASTER_CURPAGE);
|
||||
bool FindSkewSweep(double *pangle, int reduction, double sweeprange, double sweepdelta);
|
||||
|
||||
// Angle-finding functions with all parameters
|
||||
bool FindSkewSweepAndSearch(
|
||||
double *pangle, double *pconf,
|
||||
int redsweep, int redsearch,
|
||||
double sweeprange, double sweepdelta,
|
||||
double minbsdelta,
|
||||
int page = PIXRASTER_CURPAGE);
|
||||
double minbsdelta);
|
||||
|
||||
bool DeskewLocal(int page = PIXRASTER_CURPAGE);
|
||||
Pix DeskewLocal();
|
||||
|
||||
// NOTE : Leptonica has many more skew functions....
|
||||
|
||||
|
|
@ -246,40 +265,154 @@ class PixRaster : public Raster
|
|||
// ROTATION FUNCTIONS
|
||||
|
||||
// Rotates image (2-4-8 or 32 bpp) about center.
|
||||
bool RotateAM(double angle, BringInModes incolo = PIXRASTER_BRING_IN_WHITE, int page = PIXRASTER_CURPAGE);
|
||||
bool RotateAMColor(double angle, int colorval, int page = PIXRASTER_CURPAGE);
|
||||
bool RotateAMGray(double angle, int grayval, int page = PIXRASTER_CURPAGE);
|
||||
Pix RotateAM(double angle, BringInModes incolor = PIXRASTER_BRING_IN_WHITE);
|
||||
Pix RotateAMColor(double angle, int colorval);
|
||||
Pix RotateAMGray(double angle, int grayval);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// MORPHING FUNCTIONS
|
||||
|
||||
bool ErodeGray(int hsize, int vsize, int page = PIXRASTER_CURPAGE);
|
||||
bool DilateGray(int hsize, int vsize, int page = PIXRASTER_CURPAGE);
|
||||
bool OpenGray(int hsize, int vsize, int page = PIXRASTER_CURPAGE);
|
||||
bool CloseGray(int hsize, int vsize, int page = PIXRASTER_CURPAGE);
|
||||
Pix ErodeGray(int hsize, int vsize);
|
||||
Pix DilateGray(int hsize, int vsize);
|
||||
Pix OpenGray(int hsize, int vsize);
|
||||
Pix CloseGray(int hsize, int vsize);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// ARITHMETIC AND ALIKE FUNCTIONS
|
||||
|
||||
bool Invert(int page = PIXRASTER_CURPAGE);
|
||||
bool AddConstantGray(int val, int page = PIXRASTER_CURPAGE);
|
||||
bool MultConstantGray(int val, int page = PIXRASTER_CURPAGE);
|
||||
bool AddGray(int page1, int page2);
|
||||
bool SubtractGray(int page1, int page2);
|
||||
Pix Invert();
|
||||
Pix AddConstantGray(int val);
|
||||
Pix MultConstantGray(int val);
|
||||
Pix AddGray(Pix &pix2);
|
||||
Pix SubtractGray(Pix &pix2);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BLENDING/COMBINING FUNCTIONS
|
||||
|
||||
bool CombineMasked(int destPage, int sourcePage, int maskPage);
|
||||
Pix CombineMasked(Pix &aPix, Pix &maskPix);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// DOCUMENT PAGE SEGMENTING FUNCTIONS
|
||||
|
||||
// top level page segmenting
|
||||
bool GetRegionsBinary(int page = PIXRASTER_CURPAGE) ;
|
||||
PixRaster GetRegionsBinary() ;
|
||||
|
||||
// text baseline finding routine
|
||||
Array<int> FindBaselines(int page = PIXRASTER_CURPAGE);
|
||||
Array<int> FindBaselines();
|
||||
|
||||
}; // END Class Pix
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// raster class -- array of Pix objects
|
||||
class PixRaster : public PixBase
|
||||
{
|
||||
protected:
|
||||
|
||||
// array of Pixs
|
||||
Array<Pix>pages;
|
||||
|
||||
// currently active page for multipage images
|
||||
int curPage;
|
||||
|
||||
// gets real page
|
||||
int getTruePage(int page = PIXRASTER_CURPAGE);
|
||||
|
||||
public:
|
||||
|
||||
// gets PIX from PixRaster
|
||||
// WARNING -- Pix has ownership of it, so DON'T free nor destroy it
|
||||
PIX *GetPIX(int page = PIXRASTER_CURPAGE);
|
||||
operator PIX*() { return GetPIX(PIXRASTER_CURPAGE); }
|
||||
|
||||
// constructor -- empty raster
|
||||
PixRaster();
|
||||
|
||||
// constructor -- takes a Leptonica Pix
|
||||
// PixRaster TAKES OWNERSHIP of underlying PIX object which is NULLed
|
||||
PixRaster(PIX **pix);
|
||||
|
||||
// constructor -- takes an array of Leptonica Pix
|
||||
// PIXA gets destroyed and NULLed
|
||||
PixRaster(PIXA **pixa);
|
||||
|
||||
// creation of Pix from a raster object
|
||||
PixRaster(Raster &raster, bool deepCopy = false);
|
||||
|
||||
// destructor
|
||||
~PixRaster();
|
||||
|
||||
// loads Pix from another raster object
|
||||
void Load(Raster& raster, bool Append = false, bool deepCopy = false);
|
||||
|
||||
// sets/appends a source raster
|
||||
PixRaster &operator=(Raster &raster) { Load(raster, false, false); return *this; }
|
||||
PixRaster &operator+=(Raster &raster) { Load(raster, true, false); return *this; }
|
||||
|
||||
// deep copy of source raster
|
||||
PixRaster &operator <<=(Raster &raster) { Load(raster, false, true); return *this; }
|
||||
|
||||
// page handling
|
||||
virtual void SeekPage(int page);
|
||||
virtual int GetPageCount();
|
||||
virtual int GetActivePage();
|
||||
|
||||
// extended Raster functions -- they allow to query
|
||||
// a given page inside raster
|
||||
virtual Size GetSizeEx(int page);
|
||||
virtual Info GetInfoEx(int page);
|
||||
virtual Line GetLineEx(int line, int page);
|
||||
virtual int GetPaletteCountEx(int page);
|
||||
virtual const RGBA *GetPaletteEx(int page);
|
||||
virtual const RasterFormat *GetFormatEx(int page);
|
||||
|
||||
// gets polygon markers
|
||||
virtual PolyMarkers *GetPolyMarkers() { return GetPolyMarkersEx(PIXRASTER_CURPAGE); }
|
||||
virtual PolyMarkers *GetPolyMarkersEx(int page);
|
||||
|
||||
// check whether pixraster has images
|
||||
bool IsEmpty(void) { return !pages.GetCount(); };
|
||||
|
||||
// sets Pix
|
||||
void Set(Pix &_pix, int page = PIXRASTER_CURPAGE, bool deepCopy = false);
|
||||
|
||||
// adds a Pix or a PixRaster
|
||||
void Add(Pix &pix, bool deepCopy = false);
|
||||
void Add(PixRaster &pix, bool deepCopy = false);
|
||||
|
||||
// inserts a PIX or a PIX array
|
||||
void Insert(Pix &pix, int where = PIXRASTER_CURPAGE, bool deepCopy = false);
|
||||
void Insert(PixRaster &pixR, int where = PIXRASTER_CURPAGE, bool deepCopy = false);
|
||||
|
||||
// removes a PIX or a series of PIX
|
||||
void Remove(int startPage = PIXRASTER_CURPAGE, int count = 1);
|
||||
|
||||
// duplicates a page at the end of array (useful for stack-like operations)
|
||||
// NOTE1: deep copy of underlying PIX
|
||||
// NOTE2: it seeks added page too
|
||||
Pix &Dup(int page = PIXRASTER_CURPAGE);
|
||||
|
||||
// Drops last page(s) of array (ditto)
|
||||
// NOTE: it seeks last page too
|
||||
void Drop(int count = 1);
|
||||
|
||||
// Pix access operator
|
||||
Pix &operator[](int page) { return At(page); }
|
||||
|
||||
// access current page
|
||||
operator Pix&() { return At(PIXRASTER_CURPAGE); }
|
||||
|
||||
// array access
|
||||
Pix &At(int page);
|
||||
|
||||
// empties the image
|
||||
virtual void Clear() { pages.Clear(); }
|
||||
|
||||
// file I/O
|
||||
bool Load(FileIn &fs, bool Append = false);
|
||||
bool Load(String fileName, bool Append = false);
|
||||
bool Save(String fileName, int page = PIXRASTER_CURPAGE); // @@ to do - add compression and type handling
|
||||
bool SaveAll(String fileName);
|
||||
|
||||
|
||||
}; // END class PixRaster
|
||||
|
||||
|
|
|
|||
|
|
@ -173,6 +173,8 @@ file
|
|||
PixRaster.h,
|
||||
PixRasterLoad.cpp,
|
||||
PixRaster.cpp,
|
||||
PolyMarker.h,
|
||||
PolyMarker.cpp,
|
||||
TiffIo.cpp,
|
||||
UppLept.cpp,
|
||||
Lept-Skew.cpp,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// MACROS USED TO CORRECTLY HANDLE ENDIANNESS OF THE MACHINE
|
||||
#ifdef L_BIG_ENDIAN
|
||||
#define SHIFT_START 0
|
||||
|
|
@ -13,6 +14,7 @@ NAMESPACE_UPP
|
|||
#define SHIFT_STEP(shift) shift -= 8
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TRANSFER A BYTE
|
||||
static inline byte ReverseByte(byte sb)
|
||||
{
|
||||
|
|
@ -29,6 +31,7 @@ static inline byte ReverseByte(byte sb)
|
|||
return db;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// transfers a byte line -- straight bit order
|
||||
static void TransferLine_STRAIGHT(const byte *rasPnt, l_uint32 *pixPnt, int nBytes)
|
||||
{
|
||||
|
|
@ -52,6 +55,7 @@ static void TransferLine_STRAIGHT(const byte *rasPnt, l_uint32 *pixPnt, int nByt
|
|||
|
||||
} // END TransferLine_STRAIGHT()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// transfers a byte line -- reverse bit order
|
||||
static void TransferLine_REVERSE(const byte *rasPnt, l_uint32 *pixPnt, int nBytes)
|
||||
{
|
||||
|
|
@ -83,20 +87,26 @@ static void TransferLine_REVERSE(const byte *rasPnt, l_uint32 *pixPnt, int nByte
|
|||
|
||||
} // END TransferLine_REVERSE()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// raster loading/conversion routines
|
||||
PIX *PixRaster::LoadRASTER_RGBA(Raster &raster)
|
||||
bool Pix::LoadRASTER_RGBA(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
} // END PixRaster::LoadRASTER_RGBA()
|
||||
} // END Pix::LoadRASTER_RGBA()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_1(Raster &raster)
|
||||
bool Pix::LoadRASTER_1(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
// get source Raster dimensions
|
||||
int width = raster.GetWidth();
|
||||
int height = raster.GetHeight();
|
||||
|
||||
// create the PIX
|
||||
PIX *pix = pixCreateNoInit(width, height, 1);
|
||||
pix = pixCreateNoInit(width, height, 1);
|
||||
if(!pix)
|
||||
return false;
|
||||
|
||||
// get PIX width (in words) and pix data pointer
|
||||
int wpl = pixGetWpl(pix);
|
||||
|
|
@ -118,18 +128,22 @@ PIX *PixRaster::LoadRASTER_1(Raster &raster)
|
|||
// next dest line
|
||||
pixLine += wpl;
|
||||
}
|
||||
return pix;
|
||||
return true;
|
||||
|
||||
} // END PixRaster::LoadRASTER_1()
|
||||
} // END Pix::LoadRASTER_1()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_1_MSBFIRST(Raster &raster)
|
||||
bool Pix::LoadRASTER_1_MSBFIRST(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
// get source Rastet dimensions
|
||||
int width = raster.GetWidth();
|
||||
int height = raster.GetHeight();
|
||||
|
||||
// create the PIX
|
||||
PIX *pix = pixCreateNoInit(width, height, 1);
|
||||
pix = pixCreateNoInit(width, height, 1);
|
||||
if(!pix)
|
||||
return false;
|
||||
|
||||
// get PIX width (in words) and pix data pointer
|
||||
int wpl = pixGetWpl(pix);
|
||||
|
|
@ -151,19 +165,22 @@ PIX *PixRaster::LoadRASTER_1_MSBFIRST(Raster &raster)
|
|||
// next dest line
|
||||
pixLine += wpl;
|
||||
}
|
||||
return pix;
|
||||
return true;
|
||||
|
||||
} // END PixRaster::LoadRASTER_1_MSBFIRST()
|
||||
} // END Pix::LoadRASTER_1_MSBFIRST()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_2(Raster &raster)
|
||||
bool Pix::LoadRASTER_2(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
// get source Raster dimensions
|
||||
int width = raster.GetWidth();
|
||||
int height = raster.GetHeight();
|
||||
|
||||
// create the PIX
|
||||
PIX *pix = pixCreateNoInit(width, height,2);
|
||||
pix = pixCreateNoInit(width, height,2);
|
||||
if(!pix)
|
||||
return false;
|
||||
|
||||
// get PIX width (in words) and pix data pointer
|
||||
int wpl = pixGetWpl(pix);
|
||||
|
|
@ -185,19 +202,22 @@ PIX *PixRaster::LoadRASTER_2(Raster &raster)
|
|||
// next dest line
|
||||
pixLine += wpl;
|
||||
}
|
||||
return pix;
|
||||
return true;
|
||||
|
||||
} // END PixRaster::LoadRASTER_2()
|
||||
} // END Pix::LoadRASTER_2()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_2_MSBFIRST(Raster &raster)
|
||||
bool Pix::LoadRASTER_2_MSBFIRST(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
// get source Rastet dimensions
|
||||
int width = raster.GetWidth();
|
||||
int height = raster.GetHeight();
|
||||
|
||||
// create the PIX
|
||||
PIX *pix = pixCreateNoInit(width, height, 2);
|
||||
pix = pixCreateNoInit(width, height, 2);
|
||||
if(!pix)
|
||||
return false;
|
||||
|
||||
// get PIX width (in words) and pix data pointer
|
||||
int wpl = pixGetWpl(pix);
|
||||
|
|
@ -219,19 +239,22 @@ PIX *PixRaster::LoadRASTER_2_MSBFIRST(Raster &raster)
|
|||
// next dest line
|
||||
pixLine += wpl;
|
||||
}
|
||||
return pix;
|
||||
return true;
|
||||
|
||||
} // END PixRaster::LoadRASTER_2()
|
||||
} // END Pix::LoadRASTER_2()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_4(Raster &raster)
|
||||
bool Pix::LoadRASTER_4(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
// get source Raster dimensions
|
||||
int width = raster.GetWidth();
|
||||
int height = raster.GetHeight();
|
||||
|
||||
// create the PIX
|
||||
PIX *pix = pixCreateNoInit(width, height, 4);
|
||||
pix = pixCreateNoInit(width, height, 4);
|
||||
if(!pix)
|
||||
return false;
|
||||
|
||||
// get PIX width (in words) and pix data pointer
|
||||
int wpl = pixGetWpl(pix);
|
||||
|
|
@ -253,19 +276,22 @@ PIX *PixRaster::LoadRASTER_4(Raster &raster)
|
|||
// next dest line
|
||||
pixLine += wpl;
|
||||
}
|
||||
return pix;
|
||||
return true;
|
||||
|
||||
} // END PixRaster::LoadRASTER_4()
|
||||
} // END Pix::LoadRASTER_4()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_4_MSBFIRST(Raster &raster)
|
||||
bool Pix::LoadRASTER_4_MSBFIRST(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
// get source Rastet dimensions
|
||||
int width = raster.GetWidth();
|
||||
int height = raster.GetHeight();
|
||||
|
||||
// create the PIX
|
||||
PIX *pix = pixCreateNoInit(width, height, 4);
|
||||
pix = pixCreateNoInit(width, height, 4);
|
||||
if(!pix)
|
||||
return false;
|
||||
|
||||
// get PIX width (in words) and pix data pointer
|
||||
int wpl = pixGetWpl(pix);
|
||||
|
|
@ -290,18 +316,22 @@ PIX *PixRaster::LoadRASTER_4_MSBFIRST(Raster &raster)
|
|||
// next dest line
|
||||
pixLine += wpl;
|
||||
}
|
||||
return pix;
|
||||
return true;
|
||||
|
||||
} // END PixRaster::LoadRASTER_4()
|
||||
} // END Pix::LoadRASTER_4()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_8(Raster &raster)
|
||||
bool Pix::LoadRASTER_8(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
// get source Rastet dimensions
|
||||
int width = raster.GetWidth();
|
||||
int height = raster.GetHeight();
|
||||
|
||||
// create the PIX
|
||||
PIX *pix = pixCreateNoInit(width, height, 8);
|
||||
pix = pixCreateNoInit(width, height, 8);
|
||||
if(!pix)
|
||||
return false;
|
||||
|
||||
// get PIX width (in words) and pix data pointer
|
||||
int wpl = pixGetWpl(pix);
|
||||
|
|
@ -327,39 +357,49 @@ PIX *PixRaster::LoadRASTER_8(Raster &raster)
|
|||
// next dest line
|
||||
pixLine += wpl;
|
||||
}
|
||||
return pix;
|
||||
return true;
|
||||
|
||||
} // END PixRaster::LoadRASTER_8()
|
||||
} // END Pix::LoadRASTER_8()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_8ALPHA(Raster &raster)
|
||||
bool Pix::LoadRASTER_8ALPHA(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
Cerr() << "Upp Leptonica library : 8 bpp with alpha channel still not supported";
|
||||
NEVER();
|
||||
|
||||
} // END PixRaster::LoadRASTER_8ALPHA()
|
||||
} // END Pix::LoadRASTER_8ALPHA()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_16(Raster &raster)
|
||||
bool Pix::LoadRASTER_16(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
Cerr() << "Upp Leptonica library : 16 bpp still not supported";
|
||||
NEVER();
|
||||
|
||||
} // END PixRaster::LoadRASTER_16()
|
||||
} // END Pix::LoadRASTER_16()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_16_MSBFIRST(Raster &raster)
|
||||
bool Pix::LoadRASTER_16_MSBFIRST(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
Cerr() << "Upp Leptonica library : 16 bpp still not supported";
|
||||
NEVER();
|
||||
|
||||
} // END PixRaster::LoadRASTER_16()
|
||||
} // END Pix::LoadRASTER_16()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_24(Raster &raster)
|
||||
bool Pix::LoadRASTER_24(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
// get source Rastet dimensions
|
||||
int width = raster.GetWidth();
|
||||
int height = raster.GetHeight();
|
||||
|
||||
// create the PIX
|
||||
PIX *pix = pixCreateNoInit(width, height, 32);
|
||||
pix = pixCreateNoInit(width, height, 32);
|
||||
if(!pix)
|
||||
return false;
|
||||
|
||||
// get PIX width (in bytes) and pix data pointer
|
||||
int wpl = pixGetWpl(pix);
|
||||
|
|
@ -388,18 +428,22 @@ PIX *PixRaster::LoadRASTER_24(Raster &raster)
|
|||
// next dest line
|
||||
pixLine += wpl;
|
||||
}
|
||||
return pix;
|
||||
return true;
|
||||
|
||||
} // END PixRaster::LoadRASTER_24()
|
||||
} // END Pix::LoadRASTER_24()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_24_MSBFIRST(Raster &raster)
|
||||
bool Pix::LoadRASTER_24_MSBFIRST(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
// get source Rastet dimensions
|
||||
int width = raster.GetWidth();
|
||||
int height = raster.GetHeight();
|
||||
|
||||
// create the PIX
|
||||
PIX *pix = pixCreateNoInit(width, height, 24);
|
||||
pix = pixCreateNoInit(width, height, 24);
|
||||
if(!pix)
|
||||
return false;
|
||||
|
||||
// get PIX width (in bytes) and pix data pointer
|
||||
int wpl = pixGetWpl(pix);
|
||||
|
|
@ -415,18 +459,22 @@ PIX *PixRaster::LoadRASTER_24_MSBFIRST(Raster &raster)
|
|||
// next dest line
|
||||
pixLine += wpl;
|
||||
}
|
||||
return pix;
|
||||
return true;
|
||||
|
||||
} // END PixRaster::LoadRASTER_24()
|
||||
} // END Pix::LoadRASTER_24()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_32(Raster &raster)
|
||||
bool Pix::LoadRASTER_32(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
// get source Rastet dimensions
|
||||
int width = raster.GetWidth();
|
||||
int height = raster.GetHeight();
|
||||
|
||||
// create the PIX
|
||||
PIX *pix = pixCreateNoInit(width, height, 32);
|
||||
pix = pixCreateNoInit(width, height, 32);
|
||||
if(!pix)
|
||||
return false;
|
||||
|
||||
// get PIX width (in bytes) and pix data pointer
|
||||
int wpl = pixGetWpl(pix);
|
||||
|
|
@ -454,18 +502,22 @@ PIX *PixRaster::LoadRASTER_32(Raster &raster)
|
|||
// next dest line
|
||||
pixLine += wpl;
|
||||
}
|
||||
return pix;
|
||||
return true;
|
||||
|
||||
} // END PixRaster::LoadRASTER_32()
|
||||
} // END Pix::LoadRASTER_32()
|
||||
|
||||
PIX *PixRaster::LoadRASTER_32_MSBFIRST(Raster &raster)
|
||||
bool Pix::LoadRASTER_32_MSBFIRST(Raster &raster)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
// get source Rastet dimensions
|
||||
int width = raster.GetWidth();
|
||||
int height = raster.GetHeight();
|
||||
|
||||
// create the PIX
|
||||
PIX *pix = pixCreateNoInit(width, height, 32);
|
||||
pix = pixCreateNoInit(width, height, 32);
|
||||
if(!pix)
|
||||
return false;
|
||||
|
||||
// get PIX width (in bytes) and pix data pointer
|
||||
int wpl = pixGetWpl(pix);
|
||||
|
|
@ -481,8 +533,8 @@ PIX *PixRaster::LoadRASTER_32_MSBFIRST(Raster &raster)
|
|||
// next dest line
|
||||
pixLine += wpl;
|
||||
}
|
||||
return pix;
|
||||
return true;
|
||||
|
||||
} // END PixRaster::LoadRASTER_32()
|
||||
} // END Pix::LoadRASTER_32()
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
216
bazaar/PixRaster/PolyMarker.cpp
Normal file
216
bazaar/PixRaster/PolyMarker.cpp
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
#include "PolyMarker.h"
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
// constructors
|
||||
PolyMarker::PolyMarker()
|
||||
{
|
||||
kind = Empty;
|
||||
borderThickness = 0;
|
||||
borderColor = Black;
|
||||
borderLineType = 0;
|
||||
fillColor.a = 0;
|
||||
fillColor.r = 0;
|
||||
fillColor.g = 0;
|
||||
fillColor.b = 0;
|
||||
closed = false;
|
||||
}
|
||||
|
||||
PolyMarker::PolyMarker(const PolyMarker &pm)
|
||||
{
|
||||
kind = pm.GetKind();
|
||||
borderThickness = pm.GetBorderThickness();
|
||||
borderColor = pm.GetBorderColor();
|
||||
borderLineType = pm.GetBorderLineType();
|
||||
fillColor = pm.GetFillColor();
|
||||
closed = pm.IsClosed();
|
||||
|
||||
}
|
||||
|
||||
// test for point hit
|
||||
PolyMarker::HitKind PolyMarker::Hit(const Point &p, int minDist)
|
||||
{
|
||||
|
||||
switch(kind)
|
||||
{
|
||||
case Empty:
|
||||
return Miss;
|
||||
|
||||
case Rectangle:
|
||||
{
|
||||
Point p1 = points[0];
|
||||
Point p2 = points[1];
|
||||
int x1 = min(p1.x, p2.x);
|
||||
int y1 = min(p1.y, p2.y);
|
||||
int x2 = max(p1.x, p2.x);
|
||||
int y2 = max(p1.y, p2.y);
|
||||
if(abs(p1.x - p.x) <= minDist && abs(p1.y - p.y) <= minDist)
|
||||
return Vertex;
|
||||
if(abs(p2.x - p.x) <= minDist && abs(p2.y - p.y) <= minDist)
|
||||
return Vertex;
|
||||
if(abs(p1.x - p.x) < minDist && p.y >= y1 - minDist && p.y <= y2 + minDist)
|
||||
return Side;
|
||||
if(abs(p2.x - p.x) < minDist && p.y >= y1 - minDist && p.y <= y2 + minDist)
|
||||
return Side;
|
||||
if(abs(p1.y - p.y) < minDist && p.x >= x1 - minDist && p.x <= y2 + minDist)
|
||||
return Side;
|
||||
if(abs(p2.y - p.y) < minDist && p.x >= x1 - minDist && p.x <= y2 + minDist)
|
||||
return Side;
|
||||
if(p.x > x1 && p.x < x2 && p.y > y1 && p.y < y2)
|
||||
return Inside;
|
||||
return Miss;
|
||||
}
|
||||
|
||||
case Polygon:
|
||||
// FIXME -- support polygon
|
||||
default:
|
||||
NEVER();
|
||||
} // switch
|
||||
}
|
||||
|
||||
// gets vertex or side on point
|
||||
One<Point> const PolyMarker::VertexAt(const Point &p, int minDist)
|
||||
{
|
||||
switch(kind)
|
||||
{
|
||||
case Empty:
|
||||
return One<Point>();
|
||||
|
||||
case Rectangle:
|
||||
{
|
||||
Point p1 = points[0];
|
||||
Point p2 = points[1];
|
||||
int x1 = min(p1.x, p2.x);
|
||||
int y1 = min(p1.y, p2.y);
|
||||
int x2 = max(p1.x, p2.x);
|
||||
int y2 = max(p1.y, p2.y);
|
||||
if(abs(p1.x - p.x) <= minDist && abs(p1.y - p.y) <= minDist)
|
||||
return One<Point>(new Point(p1.x, p1.y));
|
||||
else if(abs(p2.x - p.x) <= minDist && abs(p1.y - p.y) <= minDist)
|
||||
return One<Point>(new Point(p2.x, p1.y));
|
||||
else if(abs(p2.x - p.x) <= minDist && abs(p2.y - p.y) <= minDist)
|
||||
return One<Point>(new Point(p2.x, p2.y));
|
||||
else if(abs(p1.x - p.x) <= minDist && abs(p2.y - p.y) <= minDist)
|
||||
return One<Point>(new Point(p1.x, p2.y));
|
||||
return One<Point>();
|
||||
}
|
||||
|
||||
case Polygon:
|
||||
{
|
||||
for(int i = 0; i < points.GetCount(); i++)
|
||||
{
|
||||
Point pi = points[i];
|
||||
if(abs(pi.x - p.x) <= minDist && abs(pi.y - p.y) <= minDist)
|
||||
return One<Point>(new Point(pi));
|
||||
}
|
||||
return One<Point>();
|
||||
}
|
||||
|
||||
default:
|
||||
return One<Point>();
|
||||
} // switch kind
|
||||
}
|
||||
|
||||
One<Rect> const PolyMarker::SideAt(const Point &p, int minDist)
|
||||
{
|
||||
switch(kind)
|
||||
{
|
||||
case Empty:
|
||||
return One<Rect>();
|
||||
|
||||
case Rectangle:
|
||||
{
|
||||
Point p1 = points[0];
|
||||
Point p2 = points[1];
|
||||
int x1 = min(p1.x, p2.x);
|
||||
int y1 = min(p1.y, p2.y);
|
||||
int x2 = max(p1.x, p2.x);
|
||||
int y2 = max(p1.y, p2.y);
|
||||
if(abs(p1.x - p.x) < minDist && p.y >= y1 - minDist && p.y <= y2 + minDist)
|
||||
return One<Rect>(new Rect(Point(p1.x, y1), Point(p1.x, y2)));
|
||||
else if(abs(p2.x - p.x) < minDist && p.y >= y1 - minDist && p.y <= y2 + minDist)
|
||||
return One<Rect>(new Rect(Point(p2.x, y1), Point(p2.x, y2)));
|
||||
else if(abs(p1.y - p.y) < minDist && p.x >= x1 - minDist && p.x <= x2 + minDist)
|
||||
return One<Rect>(new Rect(Point(x1, p1.y), Point(x2, p1.y)));
|
||||
else if(abs(p2.y - p.y) < minDist && p.x >= x1 - minDist && p.x <= x2 + minDist)
|
||||
return One<Rect>(new Rect(Point(x1, p2.y), Point(x2, p2.y)));
|
||||
return One<Rect>();
|
||||
}
|
||||
|
||||
case Polygon:
|
||||
// fixme : add support
|
||||
|
||||
default:
|
||||
return One<Rect>();
|
||||
|
||||
} // switch kind
|
||||
}
|
||||
|
||||
|
||||
// open/close the polygon (invalid for rectangle markers)
|
||||
bool PolyMarker::Open(void)
|
||||
{
|
||||
closed = false;
|
||||
|
||||
}
|
||||
|
||||
bool PolyMarker::Close(void)
|
||||
|
||||
{
|
||||
closed = true;
|
||||
|
||||
}
|
||||
|
||||
// adds a vertex to the polygon (invalid for rectangle markers)
|
||||
bool PolyMarker::AddVertex(const Point &p)
|
||||
{
|
||||
if(closed || kind == Rectangle)
|
||||
return false;
|
||||
points.Add(p);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool PolyMarker::AddVertex(const Array<Point> &ap)
|
||||
{
|
||||
if(closed || kind == Rectangle || !ap.GetCount())
|
||||
return false;
|
||||
for(int i = 0; i < ap.GetCount(); i++)
|
||||
points.Add(ap[i]);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PolyMarker::MakeRect(const Point &p1, const Point &p2)
|
||||
{
|
||||
points.Clear();
|
||||
points.Add(p1);
|
||||
points.Add(p1);
|
||||
kind = Rectangle;
|
||||
closed = true;
|
||||
}
|
||||
|
||||
// clears the marker
|
||||
void PolyMarker::Clear(void)
|
||||
{
|
||||
points.Clear();
|
||||
kind = Empty;
|
||||
closed = false;
|
||||
}
|
||||
|
||||
// gets a dragged PolyMarker giving start and end point
|
||||
PolyMarker PolyMarker::Drag(const Point &startP, const Point &endP)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// changes the PolyMarker at end of drag ops
|
||||
void PolyMarker::DoDrag(const Point &startP, const Point &endP)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// paint the PolyMarker on a given viewport
|
||||
void PolyMarker::Paint(const Rect &vport)
|
||||
{
|
||||
|
||||
}
|
||||
76
bazaar/PixRaster/PolyMarker.h
Normal file
76
bazaar/PixRaster/PolyMarker.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
#ifndef _PolyMarker_h_
|
||||
#define _PolyMarker_h_
|
||||
|
||||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
class PolyMarker
|
||||
{
|
||||
public:
|
||||
typedef PolyMarker CLASSNAME;
|
||||
|
||||
enum HitKind { Miss, Vertex, Side, Inside };
|
||||
enum PolyKind { Empty, Rectangle, Polygon };
|
||||
|
||||
protected:
|
||||
|
||||
PolyKind kind;
|
||||
Array<Point> points;
|
||||
int borderThickness;
|
||||
Color borderColor;
|
||||
int borderLineType;
|
||||
RGBA fillColor;
|
||||
bool closed;
|
||||
|
||||
public:
|
||||
|
||||
// constructors
|
||||
PolyMarker();
|
||||
PolyMarker(const PolyMarker &pm);
|
||||
|
||||
// test for point hit
|
||||
HitKind Hit(const Point &p, int minDist);
|
||||
|
||||
// gets nearest vertex or side to point
|
||||
One<Point> const VertexAt(const Point &p, int minDist);
|
||||
One<Rect> const SideAt(const Point &p, int minDist);
|
||||
|
||||
// open/close the polygon (invalid for rectangle markers)
|
||||
bool Open(void);
|
||||
bool Close(void);
|
||||
|
||||
// adds a vertex to the polygon (invalid for rectangle markers)
|
||||
bool AddVertex(const Point &p);
|
||||
bool AddVertex(const Array<Point> &ap);
|
||||
void MakeRect(const Point &p1, const Point &p2);
|
||||
|
||||
// clears the marker
|
||||
void Clear(void);
|
||||
|
||||
// member read access
|
||||
PolyKind GetKind(void) const { return kind; }
|
||||
bool IsClosed(void) const { return closed; }
|
||||
Color GetBorderColor(void) const { return borderColor; }
|
||||
int GetBorderLineType(void) const { return borderLineType; }
|
||||
int GetBorderThickness(void) const { return borderThickness; }
|
||||
RGBA GetFillColor(void) const { return fillColor; }
|
||||
Rect const &GetBoundingBox(void);
|
||||
Array<Point> const &GetPoints(void);
|
||||
|
||||
// gets a dragged PolyMarker giving start and end point
|
||||
PolyMarker Drag(const Point &startP, const Point &endP);
|
||||
|
||||
// changes the PolyMarker at end of drag ops
|
||||
void DoDrag(const Point &startP, const Point &endP);
|
||||
|
||||
// paint the PolyMarker on a given viewport
|
||||
void Paint(const Rect &vport);
|
||||
|
||||
} ; // END Class PolyMarker
|
||||
|
||||
typedef Array<PolyMarker> PolyMarkers;
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
#include "lib/allheaders.h"
|
||||
|
||||
#include "PixRaster.h"
|
||||
|
||||
#include <Draw/Draw.h>
|
||||
|
|
|
|||
|
|
@ -8,28 +8,28 @@ topic "Image arithmetic operations";
|
|||
[s0; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Arithmetic operations]]}}&]
|
||||
[s1; &]
|
||||
[s2;:PixRaster`:`:Invert`(int`): [@(0.0.255) bool]_[* Invert]([@(0.0.255) int]_[*@3 page]_`=_
|
||||
PIXRASTER`_CURPAGE)&]
|
||||
[s3;%% [%-*@3 page].&]
|
||||
[s2;:Pix`:`:Invert`(`): [@(0.0.255) Pix]_[* Invert]()&]
|
||||
[s3;%% Inverts image.&]
|
||||
[s4;%% &]
|
||||
[s1; &]
|
||||
[s2;:PixRaster`:`:AddConstantGray`(int`,int`): [@(0.0.255) bool]_[* AddConstantGray]([@(0.0.255) i
|
||||
nt]_[*@3 val], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3;%% [%-*@3 val] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:AddConstantGray`(int`): [@(0.0.255) Pix]_[* AddConstantGray]([@(0.0.255) int]_[*@3 v
|
||||
al])&]
|
||||
[s3;%% Adds a constant gray [%-*@3 val] value to image.&]
|
||||
[s4;%% &]
|
||||
[s1; &]
|
||||
[s2;:PixRaster`:`:MultConstantGray`(int`,int`): [@(0.0.255) bool]_[* MultConstantGray]([@(0.0.255) i
|
||||
nt]_[*@3 val], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3;%% [%-*@3 val] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:MultConstantGray`(int`): [@(0.0.255) Pix]_[* MultConstantGray]([@(0.0.255) int]_
|
||||
[*@3 val])&]
|
||||
[s3;%% Multiply all image pixels by a constant [%-*@3 val] value.&]
|
||||
[s4;%% &]
|
||||
[s1; &]
|
||||
[s2;:PixRaster`:`:AddGray`(int`,int`): [@(0.0.255) bool]_[* AddGray]([@(0.0.255) int]_[*@3 pa
|
||||
ge1], [@(0.0.255) int]_[*@3 page2])&]
|
||||
[s3;%% [%-*@3 page1] [%-*@3 page2].&]
|
||||
[s2;:Pix`:`:AddGray`(Pix`&`): [@(0.0.255) Pix]_[* AddGray]([@(0.0.255) Pix`&]_[*@3 pix2])&]
|
||||
[s3;%% Adds all grayscale pixels of [%-*@3 pix2] to current pix`'s
|
||||
ones.&]
|
||||
[s4;%% &]
|
||||
[s1; &]
|
||||
[s2;:PixRaster`:`:SubtractGray`(int`,int`): [@(0.0.255) bool]_[* SubtractGray]([@(0.0.255) i
|
||||
nt]_[*@3 page1], [@(0.0.255) int]_[*@3 page2])&]
|
||||
[s3;%% [%-*@3 page1] [%-*@3 page2].&]
|
||||
[s2;:Pix`:`:SubtractGray`(Pix`&`): [@(0.0.255) Pix]_[* SubtractGray]([@(0.0.255) Pix`&]_[*@3 p
|
||||
ix2])&]
|
||||
[s3;%% Subtracts [%-*@3 pix2] grayscale pixels from current pix`'s
|
||||
ones.&]
|
||||
[s4;%% &]
|
||||
[s0; ]
|
||||
|
|
@ -8,13 +8,11 @@ topic "Combining/blending functions";
|
|||
[s0;%- &]
|
||||
[ {{10000F(128)G(128)@1 [s0; [* Combining/blending functions]]}}&]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:CombineMasked`(int`,int`,int`):%- [@(0.0.255) bool]_[* CombineMasked]([@(0.0.255) i
|
||||
nt]_[*@3 destPage], [@(0.0.255) int]_[*@3 sourcePage], [@(0.0.255) int]_[*@3 maskPage])&]
|
||||
[s3; Creates an image from [%-*@3 destPage] with pixels replaced by
|
||||
[%-*@3 sourcePage]`'s ones if corresponding bits of [%-*@3 maskPage
|
||||
]are set.&]
|
||||
[s3; The combined image is appended at the end of PixRaster.&]
|
||||
[s2;:Pix`:`:CombineMasked`(Pix`&`,Pix`&`):%- [@(0.0.255) bool]_[* CombineMasked]([@(0.0.255) P
|
||||
ix`&]_[*@3 aPix], [@(0.0.255) Pix`&]_[*@3 maskPix])&]
|
||||
[s3; Replaces current Pix pixels from [%-*@3 aPix]`'s ones if corresponding
|
||||
bits of [%-*@3 maskPix ]are set.&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s3; Returns the combined Pix on success, an empty Pix otherwise.&]
|
||||
[s4; &]
|
||||
[s0; ]
|
||||
|
|
@ -8,11 +8,9 @@ topic "Morphing functions";
|
|||
[s0;%- &]
|
||||
[ {{10000F(128)G(128)@1 [s0; [* Morphing functions]]}}&]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:ErodeGray`(int`,int`,int`):%- [@(0.0.255) bool]_[* ErodeGray]([@(0.0.255) i
|
||||
nt]_[*@3 hsize], [@(0.0.255) int]_[*@3 vsize], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CU
|
||||
RPAGE)&]
|
||||
[s3; Apply the morphological [* erosion] operation on [%-*@3 page] grayscale
|
||||
image.&]
|
||||
[s2;:Pix`:`:ErodeGray`(int`,int`):%- [@(0.0.255) Pix]_[* ErodeGray]([@(0.0.255) int]_[*@3 hsi
|
||||
ze], [@(0.0.255) int]_[*@3 vsize])&]
|
||||
[s3; Apply the morphological [* erosion] operation on grayscale image.&]
|
||||
[s3; [%-*@3 hsize] and [%-*@3 vsize] are [* Sel] (structuring elements)
|
||||
sizes, and must be odd numbers (they`'re changed to biggest nearest
|
||||
odd number if not) If both [%-*@3 hsize] and [%-*@3 vsize] are equal
|
||||
|
|
@ -21,15 +19,13 @@ to 1, [* ErodeGray] just returns a cloned image.&]
|
|||
pixels depends on size of [* Sel]s&]
|
||||
[s3; Eroded image is appended at the end of PixRaster&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s3; Returns eroded [* Pix ]on success,an empty [* Pix ]otherwise.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:DilateGray`(int`,int`,int`):%- [@(0.0.255) bool]_[* DilateGray]([@(0.0.255) i
|
||||
nt]_[*@3 hsize], [@(0.0.255) int]_[*@3 vsize], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CU
|
||||
RPAGE)&]
|
||||
[s3; Apply the morphological [* dilation] operation on [%-*@3 page] grayscale
|
||||
image.&]
|
||||
[s2;:Pix`:`:DilateGray`(int`,int`):%- [@(0.0.255) Pix]_[* DilateGray]([@(0.0.255) int]_[*@3 h
|
||||
size], [@(0.0.255) int]_[*@3 vsize])&]
|
||||
[s3; Apply the morphological [* dilation] operation on grayscale image.&]
|
||||
[s3; [%-*@3 hsize] and [%-*@3 vsize] are [* Sel] (structuring elements)
|
||||
sizes, and must be odd numbers (they`'re changed to biggest nearest
|
||||
odd number if not) If both [%-*@3 hsize] and [%-*@3 vsize] are equal
|
||||
|
|
@ -38,15 +34,13 @@ to 1, [* DilateGray] just returns a cloned image.&]
|
|||
pixels depends on size of [* Sel]s&]
|
||||
[s3; Dilated image is appended at the end of PixRaster&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s3; Returns dilated [* Pix ]on success,an empty [* Pix ]otherwise.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:OpenGray`(int`,int`,int`):%- [@(0.0.255) bool]_[* OpenGray]([@(0.0.255) i
|
||||
nt]_[*@3 hsize], [@(0.0.255) int]_[*@3 vsize], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CU
|
||||
RPAGE)&]
|
||||
[s3; Apply the morphological [* opening] operation on [%-*@3 page] grayscale
|
||||
image.&]
|
||||
[s2;:Pix`:`:OpenGray`(int`,int`):%- [@(0.0.255) Pix]_[* OpenGray]([@(0.0.255) int]_[*@3 hsize
|
||||
], [@(0.0.255) int]_[*@3 vsize])&]
|
||||
[s3; Apply the morphological [* opening] operation on grayscale image.&]
|
||||
[s3; [%-*@3 hsize] and [%-*@3 vsize] are [* Sel] (structuring elements)
|
||||
sizes, and must be odd numbers (they`'re changed to biggest nearest
|
||||
odd number if not) If both [%-*@3 hsize] and [%-*@3 vsize] are equal
|
||||
|
|
@ -55,15 +49,13 @@ to 1, [* OpenGray] just returns a cloned image.&]
|
|||
one; the amount of added/eroded pixels depends on size of [* Sel]s&]
|
||||
[s3; Opened image is appended at the end of PixRaster&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s3; Returns opened [* Pix ]on success,an empty [* Pix ]otherwise.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:CloseGray`(int`,int`,int`):%- [@(0.0.255) bool]_[* CloseGray]([@(0.0.255) i
|
||||
nt]_[*@3 hsize], [@(0.0.255) int]_[*@3 vsize], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CU
|
||||
RPAGE)&]
|
||||
[s3; Apply the morphological [* closing] operation on [%-*@3 page] grayscale
|
||||
image.&]
|
||||
[s2;:Pix`:`:CloseGray`(int`,int`):%- [@(0.0.255) Pix]_[* CloseGray]([@(0.0.255) int]_[*@3 hsi
|
||||
ze], [@(0.0.255) int]_[*@3 vsize])&]
|
||||
[s3; Apply the morphological [* closing] operation on grayscale image.&]
|
||||
[s3; [%-*@3 hsize] and [%-*@3 vsize] are [* Sel] (structuring elements)
|
||||
sizes, and must be odd numbers (they`'re changed to biggest nearest
|
||||
odd number if not) If both [%-*@3 hsize] and [%-*@3 vsize] are equal
|
||||
|
|
@ -72,7 +64,7 @@ to 1, [* CloseGray] just returns a cloned image.&]
|
|||
]one; the amount of added/eroded pixels depends on size of [* Sel]s&]
|
||||
[s3; Closed image is appended at the end of PixRaster&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s3; Returns closed [* Pix ]on success,an empty [* Pix ]otherwise.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s0; ]
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
topic "";
|
||||
topic "Document analysis function";
|
||||
[ $$0,0#00000000000000000000000000000000:Default]
|
||||
[H6;0 $$1,0#05600065144404261032431302351956:begin]
|
||||
[i448;a25;kKO9;2 $$2,0#37138531426314131252341829483370:codeitem]
|
||||
|
|
@ -8,17 +8,22 @@ topic "";
|
|||
[s0;%- &]
|
||||
[ {{10000F(128)G(128)@1 [s0; [* Page segmentation/layout analysis functions]]}}&]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:GetRegionsBinary`(int`):%- [@(0.0.255) bool]_[* GetRegionsBinary]([@(0.0.255) i
|
||||
nt]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; Gets layout masks for image at [%-*@3 page]. Masks are appended
|
||||
at the end of PixRaster in this sequence :&]
|
||||
[s2;:Pix`:`:GetRegionsBinary`(`):%- [@(0.0.255) PixRaster]_[* GetRegionsBinary]()&]
|
||||
[s3; Gets layout masks for image. Masks are returned as a multipaged
|
||||
PixRaster in this sequence :&]
|
||||
[s3;i150;O0; Halftone mask-|-|1 bpp mask for halftone page parts&]
|
||||
[s3;i150;O0; Textline mask-|-|1 bpp mask for text lines inside page&]
|
||||
[s3;i150;O0; Textblock mask-|-|1 bpp mask for text blocks inside page&]
|
||||
[s3; Active PixRaster page is set to first (Halftone) of the three
|
||||
resulting masks.&]
|
||||
[s3; Active returned PixRaster page is set to first (Halftone) of
|
||||
the three resulting masks.&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s3; Returns [* Pixraster ]with masks on success, an empty [* PixRaster
|
||||
]otherwise.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s0; ]
|
||||
[s1;%- &]
|
||||
[s2;:Pix`:`:FindBaselines`(`):%- [_^Array^ Array]<[@(0.0.255) int]>_[* FindBaselines]()&]
|
||||
[s3; Finds all text baselines of image.&]
|
||||
[s4;%- &]
|
||||
[s3; Returns an [* array ]of [* y] coordinates on success, an empty [* array
|
||||
]otherwise.]
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
topic "class PixRaster";
|
||||
topic "class PixRaster : public PixBase";
|
||||
[ $$0,0#00000000000000000000000000000000:Default]
|
||||
[i448;a25;kKO9; $$1,0#37138531426314131252341829483380:structitem]
|
||||
[l288;2 $$2,0#27521748481378242620020725143825:desc]
|
||||
|
|
@ -6,60 +6,38 @@ topic "class PixRaster";
|
|||
[H6;0 $$4,0#05600065144404261032431302351956:begin]
|
||||
[*2 $$5,0#37138531426314131252341829483370:codeitem]
|
||||
[{_}
|
||||
[s1;:PixRaster`:`:class: [@(0.0.255) class]_[* PixRaster]_:_[@(0.0.255) public]_[*@3 Raster]&]
|
||||
[s1;:PixRaster`:`:class: [@(0.0.255) class]_[* PixRaster]_:_[@(0.0.255) public]_[*@3 PixBase]&]
|
||||
[s2;%% Multipaged Leptonica raster object.&]
|
||||
[s2;%% It contains an array of [* Pix] single`-page Leptonica raster
|
||||
objects&]
|
||||
[s2;%% &]
|
||||
[s3; &]
|
||||
[s0; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Public enums]]}}&]
|
||||
[s0;2 &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:PIXRASTER`_REF: [@(0.0.255) enum]_CopyModes&]
|
||||
[s2;%% &]
|
||||
[s2; Gives ownership of internal Leptonica PIX images and PIXA arrays
|
||||
when creating or copying PixRaster objects :&]
|
||||
[s0; &]
|
||||
[s5; -|PIXRASTER`_CLONE -|-|[* PIX and PIXA`'s reference count gets increased]&]
|
||||
[s5; -|PIXRASTER`_COPY-|-|-|[* PIX and PIXAs are deep cloned]&]
|
||||
[s5; -|PIXRASTER`_COPY`_CLONE-|-|[* PIX`'s reference count increased and
|
||||
PIXA deep cloned]&]
|
||||
[s5; -|PIXRASTER`_REF-|-|-|[* PIX and PIXAs are just referenced by pointer]&]
|
||||
[s0; &]
|
||||
[s0; [2 This enum is used mostly when dealing directly with Leptonica
|
||||
PIX and PIXA objects. PixRaster provides wrapping for most Leptonica
|
||||
functions, so user usually don`'t care of internal objects ownership.]&]
|
||||
[s0; [2 If you need to access internal objects keep in mind that cloned
|
||||
or referenced objects may change by means of other calls; in
|
||||
doubt use PIXRASTER`_COPY to get a full image copy.]&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:PIXRASTER`_BRING`_IN`_WHITE: [@(0.0.255) enum]_BringInModes&]
|
||||
[s2;%% &]
|
||||
[s2; Color filling mode in operations that adds parts to images,
|
||||
for example rotations :&]
|
||||
[s0; &]
|
||||
[s5; -|PIXRASTER`_BRING`_IN`_WHITE-|[* Fills new parts with white color]&]
|
||||
[s5; -|PIXRASTER`_BRING`_IN`_BLACK-|[* Fills new parts with black color]&]
|
||||
[s2;%% &]
|
||||
[s3; &]
|
||||
[s0;*%% &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Constructors and destructor]]}}&]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:PixRaster`(`): PixRaster()&]
|
||||
[s2;%% Constructs an empty PixRaster object.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:PixRaster`(PIX`*`,CopyModes`): PixRaster([_^PIX^ PIX]_`*[@3 pix],
|
||||
CopyModes_[@3 copyMode]_`=_PIXRASTER`_CLONE)&]
|
||||
[s5;:PixRaster`:`:PixRaster`(PIX`*`*`): PixRaster([_^PIX^ PIX]_`*`*[@3 pix])&]
|
||||
[s2;%% [%- Constructs a single page PixRaster from a Leptonica][%-*@3
|
||||
pix] image; ownership of image is assigned by [%-*@3 copyMode]
|
||||
parameter&]
|
||||
pix] image.&]
|
||||
[s2;%% PixRaster takes ownership of PIX object; to avoid misuse of
|
||||
it, [%-*@3 pix] is cleared.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:PixRaster`(PIXA`*`,CopyModes`): PixRaster([_^PIXA^ PIXA]_`*[@3 pixa],
|
||||
CopyModes_[@3 copyMode]_`=_PIXRASTER`_COPY`_CLONE)&]
|
||||
[s5;:PixRaster`:`:PixRaster`(PIXA`*`*`): PixRaster([_^PIXA^ PIXA]_`*`*[@3 pixa])&]
|
||||
[s2;%% Constructs a multipage PixRaster from a Leptonica [%-*@3 pixa]
|
||||
array of images; ownership of array and images is assigned by
|
||||
[%-*@3 copyMode] parameter&]
|
||||
array of images.&]
|
||||
[s2;%% PixRaster takes ownership of array; to avoid misuse of it,
|
||||
[%-*@3 pixa] is cleared.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:PixRaster`(Raster`&`,bool`): PixRaster([_^Raster^ Raster]_`&[@3 raster],
|
||||
[@(0.0.255) bool]_[@3 deepCopy]_`=_[@(0.0.255) false], [@(0.0.255) int]_[@3 page]_`=_PIXRA
|
||||
STER`_CURPAGE)&]
|
||||
[s2;%% Constructs PixRaster from a source [%-*@3 raster] with optional
|
||||
[%-*@3 deepCopy].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:`~PixRaster`(`): [@(0.0.255) `~]PixRaster()&]
|
||||
|
|
@ -67,73 +45,74 @@ array of images; ownership of array and images is assigned by
|
|||
[s3; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Internal handling of Leptonica objects]]}}&]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPIX`(int`,CopyModes`): [_^PIX^ PIX]_`*GetPIX([@(0.0.255) int]_[@3 page
|
||||
]_`=_PIXRASTER`_CURPAGE, CopyModes_[@3 copyMode]_`=_PIXRASTER`_REF)&]
|
||||
[s2;%% gets internal [* PIX] object from given [%-*@3 page] , defaulting
|
||||
to current one.&]
|
||||
[s2;%% [%-*@3 copyMode] sets the ownership of retrieved object, defaulting
|
||||
to simple reference.&]
|
||||
[s5;:PixRaster`:`:GetPIX`(int`): [_^PIX^ PIX]_`*GetPIX([@(0.0.255) int]_[@3 page]_`=_PIXRAS
|
||||
TER`_CURPAGE)&]
|
||||
[s2;%% Gets underlying Leptonica [* PIX ]object for [%-*@3 page].&]
|
||||
[s2;%% [* WARNING], [* Pix] owns [* PIX ]object, so don`'t free it.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPIXA`(CopyModes`): [_^PIXA^ PIXA]_`*GetPIXA(CopyModes_[@3 copyMode]_
|
||||
`=_PIXRASTER`_REF)&]
|
||||
[s2;%% gets internal PIXA image array; [%-*@3 copyMode] sets the ownership
|
||||
of retrieved array, defaulting to simple reference&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:operator PIX`*`(void`): operator_PIX`*([@(0.0.255) void])&]
|
||||
[s5;:PixRaster`:`:operator PIX`*`(`): operator_PIX`*()&]
|
||||
[s2;%% same as [^topic`:`/`/Leptonica`/src`/PixRaster`$en`-us`#PixRaster`:`:GetPIX`(int`,CopyModes`)^ G
|
||||
etPIX](PIXRASTER`_CURPAGE, PIXRASTER`_REF)&]
|
||||
etPIX](PIXRASTER`_CURPAGE)&]
|
||||
[s3; &]
|
||||
[s0; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Member images access]]}}&]
|
||||
[s0; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:SetPIX`(PIX`*`,int`,CopyModes`): [@(0.0.255) void]_SetPIX([_^PIX^ PIX]_
|
||||
`*[@3 pix], [@(0.0.255) int]_[@3 page]_`=_PIXRASTER`_CURPAGE, CopyModes_[@3 copyMode]_`=_
|
||||
PIXRASTER`_CLONE)&]
|
||||
[s2;%% sets [%-*@3 pix] at [%-*@3 page] with ownership given by [%-*@3 copyMode].
|
||||
Previous PIX gets it`'s reference decreased and is freed if necessary.&]
|
||||
[s5;:PixRaster`:`:Set`(Pix`&`,int`,bool`):%% [%-@(0.0.255) void][%- _Set(][%-_^PIX^ Pix][%- _
|
||||
`&][%-@3 pix][%- , ][%-@(0.0.255) int][%- _][%-@3 page][%- _`=_PIXRASTER`_CURPAGE,
|
||||
][%-@(0.0.255) bool] [%-@3 DeepCopy][%- `=_][%-@(0.0.255) false])&]
|
||||
[s2;%% sets [%-*@3 pix] at [%-*@3 page] with optional [%-*@3 DeepCopy].&]
|
||||
[s0;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:Add`(Pix`&`,bool`): [@(0.0.255) void]_Add([_^PIX^ Pix]_`&[@3 pix],
|
||||
[@(0.0.255) bool][%% ][@3 DeepCopy]`=_[@(0.0.255) false])&]
|
||||
[s2;%% Appends a [%-*@3 pix] to the end of PixRaster with optional
|
||||
[%-*@3 DeepCopy] .&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:SetPIXA`(PIXA`*`,CopyModes`): [@(0.0.255) void]_SetPIXA([_^PIXA^ PIXA]_
|
||||
`*[@3 pixa], CopyModes_[@3 copyMode]_`=_PIXRASTER`_COPY`_CLONE)&]
|
||||
[s2;%% replaces image array with [%-*@3 pixa] using ownership given
|
||||
by [%-*@3 copyMode]. Previous image array gets it`'s reference
|
||||
decreased and is freed if necessary.&]
|
||||
[s5;:PixRaster`:`:Add`(PixRaster`&`,bool`): [@(0.0.255) void]_Add([_^PIXA^ PixRaster]_`&[@3 p
|
||||
ixr], [@(0.0.255) bool][%% ][@3 DeepCopy]`=_[@(0.0.255) false])&]
|
||||
[s2;%% Appends [%-*@3 pixr] PixRaster at end of current one with optional
|
||||
[%-*@3 DeepCopy] &]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:AddPIX`(PIX`*`,CopyModes`): [@(0.0.255) void]_AddPIX([_^PIX^ PIX]_`*[@3 p
|
||||
ix], CopyModes_[@3 copyMode]_`=_PIXRASTER`_CLONE)&]
|
||||
[s2;%% Appends a [%-*@3 pix] to the end of PixRaster using ownership
|
||||
given by [%-*@3 copyMode].&]
|
||||
[s5;:PixRaster`:`:Insert`(Pix`&`,int`,bool`): [@(0.0.255) void]_Insert([_^PIX^ Pix]_`&[@3 p
|
||||
ix], [@(0.0.255) int]_[@3 where]_`=_PIXRASTER`_CURPAGE, [@(0.0.255) bool][%%
|
||||
][@3 DeepCopy]`=_[@(0.0.255) false])&]
|
||||
[s2;%% Inserts Pix [%-*@3 pix] at [%-*@3 where] position with optional
|
||||
[%-*@3 DeepCopy] &]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:AddPIXA`(PIXA`*`,CopyModes`): [@(0.0.255) void]_AddPIXA([_^PIXA^ PIXA]_
|
||||
`*[@3 pixa], CopyModes_[@3 copyMode]_`=_PIXRASTER`_COPY`_CLONE)&]
|
||||
[s2;%% Appends a [%-*@3 pixa] image array to the end of PixRaster using
|
||||
ownership given by [%-*@3 copyMode].Valid modes are only PIXRASTER`_COPY
|
||||
and PIXRASTER`_CLONE.&]
|
||||
[s5;:PixRaster`:`:Insert`(PixRaster`&`,int`,bool`): [@(0.0.255) void]_Insert([_^PIXA^ Pix
|
||||
Raster]_`&[@3 pixr], [@(0.0.255) int]_[@3 where]_`=_PIXRASTER`_CURPAGE,
|
||||
[@(0.0.255) bool][%% ][@3 DeepCopy]`=_[@(0.0.255) false])&]
|
||||
[s2;%% Inserts [%-*@3 pixr] PixRaster at [%-*@3 where] position with
|
||||
optional [%-*@3 DeepCopy] &]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:InsertPIX`(PIX`*`,int`,CopyModes`): [@(0.0.255) void]_InsertPIX([_^PIX^ P
|
||||
IX]_`*[@3 pix], [@(0.0.255) int]_[@3 where]_`=_PIXRASTER`_CURPAGE,
|
||||
CopyModes_[@3 copyMode]_`=_PIXRASTER`_COPY`_CLONE)&]
|
||||
[s2;%% Inserts a [%-*@3 pix] at [%-*@3 where] position using ownership
|
||||
given by [%-*@3 copyMode].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:InsertPIXA`(PIXA`*`,int`,CopyModes`): [@(0.0.255) void]_InsertPIXA([_^PIXA^ P
|
||||
IXA]_`*[@3 pixa], [@(0.0.255) int]_[@3 where]_`=_PIXRASTER`_CURPAGE,
|
||||
CopyModes_[@3 copyMode]_`=_PIXRASTER`_COPY`_CLONE)&]
|
||||
[s2;%% Inserts a [%-*@3 pixa] image array at [%-*@3 where] position using
|
||||
ownership given by [%-*@3 copyMode].Valid modes are only PIXRASTER`_COPY
|
||||
and PIXRASTER`_CLONE.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:RemovePIX`(int`,int`): [@(0.0.255) void]_RemovePIX([@(0.0.255) int]_[@3 s
|
||||
tartPage]_`=_PIXRASTER`_CURPAGE, [@(0.0.255) int]_[@3 count]_`=_[@3 1])&]
|
||||
[s2;%% Removes [%-*@3 count ]PIX images starting at [%-*@3 startPage
|
||||
[s5;:PixRaster`:`:Remove`(int`,int`): [@(0.0.255) void]_Remove([@(0.0.255) int]_[@3 startPa
|
||||
ge]_`=_PIXRASTER`_CURPAGE, [@(0.0.255) int]_[@3 count]_`=_[@3 1])&]
|
||||
[s2;%% Removes [%-*@3 count ]Pix images starting at [%-*@3 startPage
|
||||
]position.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:operator`[`]`(int`): [_^Pix^ Pix]_`&operator`[`]([@(0.0.255) int]_[@3 pag
|
||||
e])&]
|
||||
[s2;%% Access [* Pix] at [%-*@3 page].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:operator Pix`&`(`): operator_Pix`&()&]
|
||||
[s2;%% Access [* Pix ]at current page.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:At`(int`): [_^Pix^ Pix]_`&At([@(0.0.255) int]_[@3 page])&]
|
||||
[s2;%% Access [* Pix ]at [%-*@3 page].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:Clear`(`): [@(0.0.255) virtual] [@(0.0.255) void]_Clear()&]
|
||||
[s2;%% Clears PixRaster content.&]
|
||||
[s3; &]
|
||||
[s0; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Stack`-like operations]]}}&]
|
||||
[s4; &]
|
||||
|
|
@ -149,29 +128,161 @@ one.&]
|
|||
array and going backwards. Active page is set to last one.&]
|
||||
[s3;%% &]
|
||||
[s0; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Conversions support from other Raster derived objects]]}}&]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Page handling functions]]}}&]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:Load`(Raster`&`,bool`,CopyModes`): [@(0.0.255) void]_Load([_^Raster^ Ra
|
||||
ster][@(0.0.255) `&]_[@3 raster], [@(0.0.255) bool]_[@3 Append]_`=_[@(0.0.255) false],
|
||||
CopyModes_[@3 copyMode]_`=_PIXRASTER`_CLONE)&]
|
||||
[s5;:PixRaster`:`:SeekPage`(int`): [@(0.0.255) virtual] [@(0.0.255) void]_SeekPage([@(0.0.255) i
|
||||
nt]_[@3 page])&]
|
||||
[s2;%% Sets active [%-*@3 page].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPageCount`(`): [@(0.0.255) virtual] [@(0.0.255) int]_GetPageCount()&]
|
||||
[s2;%% Gets number of images on PixRaster&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetActivePage`(`): [@(0.0.255) virtual] [@(0.0.255) int]_GetActivePage(
|
||||
)&]
|
||||
[s2;%% Gets number of currently active page&]
|
||||
[s3; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Miscellaneous Raster functions]]}}&]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetSize`(void`): [@(0.0.255) virtual] [_^Size^ Size]_GetSize([@(0.0.255) v
|
||||
oid])&]
|
||||
[s2;%% Returns the size of Raster`'s active page in pixels.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetSizeEx`(int`): [@(0.0.255) virtual] [_^Size^ Size]_GetSizeEx([@(0.0.255) i
|
||||
nt]_[@3 page])&]
|
||||
[s2;%% Returns the size of Raster in pixels for [%-*@3 page].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetWidth`(`): [@(0.0.255) virtual] [@(0.0.255) int]_GetWidth()&]
|
||||
[s2;%% Returns the width of Raster in pixels for active page.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetWidthEx`(int`): [@(0.0.255) virtual] [@(0.0.255) int]_GetWidthEx([@(0.0.255) i
|
||||
nt]_[@3 page])&]
|
||||
[s2;%% Returns the width of Raster in pixels for [%-*@3 page].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetHeight`(`): [@(0.0.255) virtual] [@(0.0.255) int]_GetHeight()&]
|
||||
[s2;%% Returns the height of Raster in pixels for active page.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetHeightEx`(int`): [@(0.0.255) virtual] [@(0.0.255) int]_GetHeightEx([@(0.0.255) i
|
||||
nt]_[@3 page])&]
|
||||
[s2;%% Returns the height of Raster in pixels for [%-*@3 page].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetInfo`(void`): [@(0.0.255) virtual] [_^Raster`:`:Info^ Info]_GetInfo(
|
||||
[@(0.0.255) void])&]
|
||||
[s2;%% Returns the information about Raster`'s active page.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetInfoEx`(int`): [@(0.0.255) virtual] [_^Raster`:`:Info^ Info]_GetInfo
|
||||
Ex([@(0.0.255) int]_[@3 page])&]
|
||||
[s2;%% Returns the information about Raster for [%-*@3 page].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetLine`(int`): [@(0.0.255) virtual] [_^Raster`:`:Line^ Line]_GetLine([@(0.0.255) i
|
||||
nt]_[@3 line])&]
|
||||
[s2;%% Reads a single scanline [%-*@3 line] from the raster`'s active
|
||||
page. If possible, Raster should be optimized for reading scanlines
|
||||
in ascending order `- this what most processing functions (should)
|
||||
require.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetLineEx`(int`,int`): [@(0.0.255) virtual] [_^Raster`:`:Line^ Line]_Ge
|
||||
tLineEx([@(0.0.255) int]_[@3 line], [@(0.0.255) int]_[@3 page])&]
|
||||
[s2;%% Reads a single scanline [%-*@3 line] from [%-*@3 page] ot the
|
||||
raster. If possible, Raster should be optimized for reading scanlines
|
||||
in ascending order `- this what most processing functions (should)
|
||||
require.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPaletteCount`(`): [@(0.0.255) virtual] [@(0.0.255) int]_GetPaletteCo
|
||||
unt()&]
|
||||
[s2;%% Returns the size of palette for raster`'s active page. If
|
||||
there is no palette, returns 0&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPaletteCountEx`(int`): [@(0.0.255) virtual] [@(0.0.255) int]_GetPale
|
||||
tteCountEx([@(0.0.255) int]_[@3 page])&]
|
||||
[s2;%% Returns the size of palette for raster`'s [%-*@3 page]. If there
|
||||
is no palette, returns 0..&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPalette`(`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RGBA^ RGBA]_`*
|
||||
GetPalette()&]
|
||||
[s2;%% Returns active pages`'current palette, NULL if there is no
|
||||
palette.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPaletteEx`(int`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RGBA^ RGB
|
||||
A]_`*GetPaletteEx([@(0.0.255) int]_[@3 page])&]
|
||||
[s2;%% Returns [%-*@3 page][%- `'s ]current palette, NULL if there is
|
||||
no palette &]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetFormat`(`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RasterFormat^ R
|
||||
asterFormat]_`*GetFormat()&]
|
||||
[s2;%% Returns the format of Raster`'s active page, can return NULL
|
||||
if format is RGBA.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetFormatEx`(int`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RasterFormat^ R
|
||||
asterFormat]_`*GetFormatEx([@(0.0.255) int]_[@3 page])&]
|
||||
[s2;%% Returns the format of Raster`'s [%-*@3 page], can return NULL
|
||||
if format is RGBA.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:IsEmpty`(void`): [@(0.0.255) bool]_IsEmpty([@(0.0.255) void])&]
|
||||
[s2;%% Returns true if PixRaster has no images.&]
|
||||
[s3; &]
|
||||
[s0; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Polygon markers access]]}}&]
|
||||
[s0; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPolyMarkers`(`): [@(0.0.255) virtual] [_^PolyMarkers^ PolyMarkers]_`*
|
||||
GetPolyMarkers()&]
|
||||
[s2;%% Returns array of polygon markers for current raster page&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPolyMarkersEx`(int`): [@(0.0.255) virtual] [_^PolyMarkers^ PolyMarke
|
||||
rs]_`*GetPolyMarkersEx([@(0.0.255) int]_[@3 page])&]
|
||||
[s2;%% Returns array of polygon markers for raster [%-*@3 page].&]
|
||||
[s3;%% &]
|
||||
[s0; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Conversion and file I/O functions]]}}&]
|
||||
[s0; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:Load`(Raster`&`,bool`,bool`): [@(0.0.255) void]_Load([_^Raster^ Raster][@(0.0.255) `&
|
||||
]_[@3 raster], [@(0.0.255) bool]_[@3 Append]_`=_[@(0.0.255) false], [@(0.0.255) bool]_[@3 Dee
|
||||
pCopy]_`=_[@(0.0.255) false])&]
|
||||
[s2;%% Loads image array from [%-*@3 raster] object or [%-*@3 Append]
|
||||
them to current one. Ownership of added images is given by [%-*@3 copyMode].&]
|
||||
them to current one. Source images are referenced or deep copied
|
||||
depending on [%-*@3 DeepCopy] parameter.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:operator`=`(Raster`&`): [@(0.0.255) void]_operator`=([_^Raster^ Raster]_
|
||||
`&[@3 raster])&]
|
||||
[s2;%% Same as [*^topic`:`/`/Leptonica`/src`/PixRaster`$en`-us`#PixRaster`:`:Load`(Raster`&`,bool`,CopyModes`)^ L
|
||||
oad][* (][%-*@3 raster][* , ][%-*@(0.0.255) false][* , PIXRASTER`_COPY)]
|
||||
oad][* (][%-*@3 raster][* , ][%-*@(0.0.255) false][* , ][%-*@(0.0.255) false][* )]
|
||||
Sets PixRaster`'s content equal to [%-*@3 raster]`'s one.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:operator`+`=`(Raster`&`): [@(0.0.255) void]_operator`+`=([_^Raster^ Ras
|
||||
ter]_`&[@3 raster])&]
|
||||
[s2;%% Same as [*^topic`:`/`/Leptonica`/src`/PixRaster`$en`-us`#PixRaster`:`:Load`(Raster`&`,bool`,CopyModes`)^ L
|
||||
oad][* (][%-*@3 raster], [%-*@(0.0.255) true][* , PIXRASTER`_COPY)]
|
||||
Appends [%-*@3 raster]`'s content at the end of Pixraster`'s one&]
|
||||
[s0; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* File I/O]]}}&]
|
||||
oad][* (][%-*@3 raster], [%-*@(0.0.255) true][* , ][%-*@(0.0.255) false][* )]
|
||||
Appends [%-*@3 raster]`'s content at the end of PixRaster`'s one&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:operator`<`<`=`(Raster`&`): [_^PixRaster^ PixRaster]_`&[@(0.0.255) oper
|
||||
ator]_<<`=(Raster_`&[@3 raster])&]
|
||||
[s2;%% Same as [*^topic`:`/`/Leptonica`/src`/PixRaster`$en`-us`#PixRaster`:`:Load`(Raster`&`,bool`,CopyModes`)^ L
|
||||
oad][* (][%-*@3 raster][* , ][%-*@(0.0.255) false][* , ][%-*@(0.0.255) true][* )]
|
||||
Sets PixRaster`'s content equal to [%-*@3 raster]`'s one deep
|
||||
copying it.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:Load`(FileIn`&`,bool`): [@(0.0.255) bool]_Load([_^FileIn^ FileIn]_`&[@3 f
|
||||
|
|
@ -209,122 +320,4 @@ choosen file format must support multiple pages.&]
|
|||
[s0;%% &]
|
||||
[s2;%% Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s3;%% &]
|
||||
[s0; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Page handling functions]]}}&]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:SeekPage`(int`): [@(0.0.255) virtual] [@(0.0.255) void]_SeekPage([@(0.0.255) i
|
||||
nt]_[@3 page])&]
|
||||
[s2;%% Sets active [%-*@3 page].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPageCount`(`): [@(0.0.255) virtual] [@(0.0.255) int]_GetPageCount()&]
|
||||
[s2;%% Gets number of images on PixRaster&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetActivePage`(`): [@(0.0.255) virtual] [@(0.0.255) int]_GetActivePage(
|
||||
)&]
|
||||
[s2;%% Gets number of currently active page&]
|
||||
[s3; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Miscellaneous Raster functions]]}}&]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetSize`(void`): [@(0.0.255) virtual] [_^Size^ Size]_GetSize([@(0.0.255) v
|
||||
oid])&]
|
||||
[s2;%% Returns the size of Raster`'s active page in pixels.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetSize`(int`): [@(0.0.255) virtual] [_^Size^ Size]_GetSize([@(0.0.255) i
|
||||
nt]_[@3 page])&]
|
||||
[s2;%% Returns the size of Raster in pixels for [%-*@3 page].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetWidth`(`): [@(0.0.255) virtual] [@(0.0.255) int]_GetWidth()&]
|
||||
[s2;%% Returns the width of Raster in pixels for active page.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetWidth`(int`): [@(0.0.255) virtual] [@(0.0.255) int]_GetWidth([@(0.0.255) i
|
||||
nt]_[@3 page])&]
|
||||
[s2;%% Returns the width of Raster in pixels for [%-*@3 page].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetHeight`(`): [@(0.0.255) virtual] [@(0.0.255) int]_GetHeight()&]
|
||||
[s2;%% Returns the height of Raster in pixels for active page.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetHeight`(int`): [@(0.0.255) virtual] [@(0.0.255) int]_GetHeight([@(0.0.255) i
|
||||
nt]_[@3 page])&]
|
||||
[s2;%% Returns the height of Raster in pixels for [%-*@3 page].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetInfo`(void`): [@(0.0.255) virtual] [_^Raster`:`:Info^ Info]_GetInfo(
|
||||
[@(0.0.255) void])&]
|
||||
[s2;%% Returns the information about Raster`'s active page.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetInfo`(int`): [@(0.0.255) virtual] [_^Raster`:`:Info^ Info]_GetInfo([@(0.0.255) i
|
||||
nt]_[@3 page])&]
|
||||
[s2;%% Returns the information about Raster for [%-*@3 page].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetLine`(int`): [@(0.0.255) virtual] [_^Raster`:`:Line^ Line]_GetLine([@(0.0.255) i
|
||||
nt]_[@3 line])&]
|
||||
[s2;%% Reads a single scanline [%-*@3 line] from the raster`'s active
|
||||
page. If possible, Raster should be optimized for reading scanlines
|
||||
in ascending order `- this what most processing functions (should)
|
||||
require.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetLine`(int`,int`): [@(0.0.255) virtual] [_^Raster`:`:Line^ Line]_GetL
|
||||
ine([@(0.0.255) int]_[@3 line], [@(0.0.255) int]_[@3 page])&]
|
||||
[s2;%% Reads a single scanline [%-*@3 line] from [%-*@3 page] ot the
|
||||
raster. If possible, Raster should be optimized for reading scanlines
|
||||
in ascending order `- this what most processing functions (should)
|
||||
require.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPaletteCount`(`): [@(0.0.255) virtual] [@(0.0.255) int]_GetPaletteCo
|
||||
unt()&]
|
||||
[s2;%% Returns the size of palette for raster`'s active page. If
|
||||
there is no palette, returns 0&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPaletteCount`(int`): [@(0.0.255) virtual] [@(0.0.255) int]_GetPalett
|
||||
eCount([@(0.0.255) int]_[@3 page])&]
|
||||
[s2;%% Returns the size of palette for raster`'s [%-*@3 page]. If there
|
||||
is no palette, returns 0..&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPalette`(`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RGBA^ RGBA]_`*
|
||||
GetPalette()&]
|
||||
[s2;%% Returns active pages`'current palette, NULL if there is no
|
||||
palette.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetPalette`(int`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RGBA^ RGBA]_
|
||||
`*GetPalette([@(0.0.255) int]_[@3 page])&]
|
||||
[s2;%% Returns [%-*@3 page][%- `'s ]current palette, NULL if there is
|
||||
no palette &]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetFormat`(`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RasterFormat^ R
|
||||
asterFormat]_`*GetFormat()&]
|
||||
[s2;%% Returns the format of Raster`'s active page, can return NULL
|
||||
if format is RGBA.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:GetFormat`(int`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RasterFormat^ R
|
||||
asterFormat]_`*GetFormat([@(0.0.255) int]_[@3 page])&]
|
||||
[s2;%% Returns the format of Raster`'s [%-*@3 page], can return NULL
|
||||
if format is RGBA.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:PixRaster`:`:IsEmpty`(void`): [@(0.0.255) bool]_IsEmpty([@(0.0.255) void])&]
|
||||
[s2;%% Returns true if PixRaster has no images.&]
|
||||
[s3; &]
|
||||
[s0; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Leptonica functions wrappers]]}}&]
|
||||
[s0; &]
|
||||
[s2; [*^topic`:`/`/Leptonica`/src`/PixRaster`$en`-us`#PixRaster`:`:class^ Pixraster]
|
||||
provides wrappers to many Leptonica image handling functions;
|
||||
as the list is huge it has been divided by cathegories; see Leptonica
|
||||
wrappers index.&]
|
||||
[s0; ]
|
||||
|
|
@ -8,42 +8,37 @@ topic "Image rotation functions";
|
|||
[s0;%- &]
|
||||
[ {{10000F(128)G(128)@1 [s0; [* Image rotation functions]]}}&]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:RotateAM`(double`,BringInModes`,int`):%- [@(0.0.255) bool]_[* RotateAM](
|
||||
[@(0.0.255) double]_[*@3 angle], [@(0.0.255) BringInModes]_[*@3 incolor],
|
||||
[@(0.0.255) int]_[*@3 page])&]
|
||||
[s3; Rotates image at [%-*@3 page] around its center by [%-*@3 angle]
|
||||
in radians, positive clockwise; created image pixels are filled
|
||||
in black or white depending on [%-*@3 incolor] parameter.&]
|
||||
[s2;:Pix`:`:RotateAM`(double`,BringInModes`):%- [@(0.0.255) Pix]_[* RotateAM]([@(0.0.255) d
|
||||
ouble]_[*@3 angle], [@(0.0.255) BringInModes]_[*@3 incolor])&]
|
||||
[s3; Rotates image around its center by [%-*@3 angle] in radians, positive
|
||||
clockwise; created image pixels are filled in black or white
|
||||
depending on [%-*@3 incolor] parameter.&]
|
||||
[s3; Image must be in 2, 4, 8 or 32 bpp format, either paletted or
|
||||
grayscale. The rotated image is appended to PixRaster and active
|
||||
page is set to it.&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s3; Returns rotated [* Pix ]on success,an empty [* Pix ]otherwise.&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:RotateAMColor`(double`,int`,int`):%- [@(0.0.255) bool]_[* RotateAMColor
|
||||
]([@(0.0.255) double]_[*@3 angle], [@(0.0.255) int]_[*@3 colorval], [@(0.0.255) int]_[*@3 pag
|
||||
e]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; Rotates image at [%-*@3 page] around its center by [%-*@3 angle]
|
||||
in radians, positive clockwise; created image pixels are color
|
||||
filled with [%-*@3 colorval].&]
|
||||
[s2;:Pix`:`:RotateAMColor`(double`,int`):%- [@(0.0.255) Pix]_[* RotateAMColor]([@(0.0.255) d
|
||||
ouble]_[*@3 angle], [@(0.0.255) int]_[*@3 colorval])&]
|
||||
[s3; Rotates image around its center by [%-*@3 angle] in radians, positive
|
||||
clockwise; created image pixels are color filled with [%-*@3 colorval].&]
|
||||
[s3; Image must be in 2, 4, 8 or 32 bpp format, either paletted or
|
||||
grayscale. The rotated image is appended to PixRaster and active
|
||||
page is set to it.&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s3; Returns rotated [* Pix ]on success,an empty [* Pix ]otherwise.&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:RotateAMGray`(double`,int`,int`):%- [@(0.0.255) bool]_[* RotateAMGray](
|
||||
[@(0.0.255) double]_[*@3 angle], [@(0.0.255) int]_[*@3 grayval], [@(0.0.255) int]_[*@3 page]_
|
||||
`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; Rotates image at [%-*@3 page] around its center by [%-*@3 angle]
|
||||
in radians, positive clockwise; created image pixels are gray
|
||||
filled with [%-*@3 grayval].&]
|
||||
[s2;:Pix`:`:RotateAMGray`(double`,int`):%- [@(0.0.255) Pix]_[* RotateAMGray]([@(0.0.255) do
|
||||
uble]_[*@3 angle], [@(0.0.255) int]_[*@3 grayval])&]
|
||||
[s3; Rotates image around its center by [%-*@3 angle] in radians, positive
|
||||
clockwise; created image pixels are gray filled with [%-*@3 grayval].&]
|
||||
[s3; Image must be in 2, 4, 8 or 32 bpp format, either paletted or
|
||||
grayscale. The rotated image is appended to PixRaster and active
|
||||
page is set to it.&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s3; Returns rotated [* Pix ]on success,an empty [* Pix ]otherwise.&]
|
||||
[s4; &]
|
||||
[s0; ]
|
||||
|
|
@ -8,62 +8,56 @@ topic "Skew finding/removal functions";
|
|||
[s0;%- &]
|
||||
[ {{10000F(128)G(128)@1 [s0; [* Skew finding/removal functions]]}}&]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:Deskew`(int`,int`):%- [@(0.0.255) bool]_[* Deskew]([@(0.0.255) int]_[*@3 Re
|
||||
ductionFactor]_`=_1, [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; Try to find skew of [%-*@3 page] and remove it. If succeed, it
|
||||
creates a new de`-skewed image and appends it at the end of PixRaster.
|
||||
It uses [%-*@3 ReductionFactor] value while binary`-searching for
|
||||
the skew factor.&]
|
||||
[s2;:Pix`:`:Deskew`(int`):%- [@(0.0.255) Pix]_[* Deskew]([@(0.0.255) int]_[*@3 ReductionFacto
|
||||
r]_`=_1)&]
|
||||
[s3; Try to find skew of image and remove it. If succeed, it returns
|
||||
a new de`-skewed image It uses [%-*@3 ReductionFactor] value while
|
||||
binary`-searching for the skew factor.&]
|
||||
[s3; [* WARNINGS ]: it operates [* ONLY ]on [* 1bpp monochromatic] images;
|
||||
if the skew factor is too low or not found, it just returns a
|
||||
clone of source image.&]
|
||||
[s3; Deskewed image is appended at the end of PixRaster&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s3; Returns deskewed [* Pix ]on success, empty [* Pix ]otherwise.&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:FindSkewAndDeskew`(int`,double`*`,double`*`,int`):%- [@(0.0.255) bool
|
||||
]_[* FindSkewAndDeskew]([@(0.0.255) int]_[*@3 ReductionFactor], [@(0.0.255) double]_`*[*@3 s
|
||||
kewAngle]_`=_NULL, [@(0.0.255) double]_`*[*@3 confidenceFactor]_`=_NULL,
|
||||
[@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; Try to find skew of [%-*@3 page] and remove it. If succeed, it
|
||||
creates a new de`-skewed image and appends it at the end of PixRaster.
|
||||
It uses [%-*@3 ReductionFactor] value while binary`-searching for
|
||||
the skew factor. If [%-*@3 skewAngle] and [%-*@3 confidenceFactor]
|
||||
[s2;:Pix`:`:FindSkewAndDeskew`(int`,double`*`,double`*`):%- [@(0.0.255) Pix]_[* FindSkewA
|
||||
ndDeskew]([@(0.0.255) int]_[*@3 ReductionFactor], [@(0.0.255) double]_`*[*@3 skewAngle]_`=
|
||||
_NULL, [@(0.0.255) double]_`*[*@3 confidenceFactor]_`=_NULL)&]
|
||||
[s3; Try to find skew of image and remove it. If succeed, it returns
|
||||
a new de`-skewed image.&]
|
||||
[s3; It uses [%-*@3 ReductionFactor] value while binary`-searching
|
||||
for the skew factor. If [%-*@3 skewAngle] and [%-*@3 confidenceFactor]
|
||||
pointers are non`-NULL, it sets them to the skew angle and the
|
||||
confidence value found when de`-skewing&]
|
||||
[s3; Deskewed image is appended at the end of PixRaster&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s3; Returns deskewed [* Pix ]on success, empty [* Pix ]otherwise.&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:FindSkew`(double`*`,double`*`,int`):%- [@(0.0.255) bool]_[* FindSkew]([@(0.0.255) d
|
||||
ouble]_`*[*@3 pangle], [@(0.0.255) double]_`*[*@3 pconf]_`=_NULL, [@(0.0.255) int]_[*@3 pag
|
||||
e]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; Try to find skew of [%-*@3 page] and returns it`'s value in [%-*@3 pangle]
|
||||
[s2;:PixRaster`:`:FindSkew`(double`*`,double`*`):%- [@(0.0.255) bool]_[* FindSkew]([@(0.0.255) d
|
||||
ouble]_`*[*@3 pangle], [@(0.0.255) double]_`*[*@3 pconf]_`=_NULL)&]
|
||||
[s3; Try to find skew of image and returns it`'s value in [%-*@3 pangle]
|
||||
; confidence factor is returned in [%-*@3 pconf].&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:FindSkewSweep`(double`*`,int`,double`,double`,int`):%- [@(0.0.255) bo
|
||||
ol]_[* FindSkewSweep]([@(0.0.255) double]_`*[*@3 pangle], [@(0.0.255) int]_[*@3 reduction],
|
||||
[@(0.0.255) double]_[*@3 sweeprange], [@(0.0.255) double]_[*@3 sweepdelta],
|
||||
[@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s2;:Pix`:`:FindSkewSweep`(double`*`,int`,double`,double`,int`):%- [@(0.0.255) bool]_[* F
|
||||
indSkewSweep]([@(0.0.255) double]_`*[*@3 pangle], [@(0.0.255) int]_[*@3 reduction],
|
||||
[@(0.0.255) double]_[*@3 sweeprange], [@(0.0.255) double]_[*@3 sweepdelta])&]
|
||||
[s3; Basic full`-parameters skew finding function.Try to find skew
|
||||
of [%-*@3 page] and returns it`'s value in [%-*@3 pangle] ; Uses
|
||||
[%-*@3 reduction] factor in binary searching, a semi`-range of
|
||||
[%-*@3 sweeprange] skew angle and steps by [%-*@3 sweepdelta] value.&]
|
||||
of image and returns it`'s value in [%-*@3 pangle] ; Uses [%-*@3 reduction]
|
||||
factor in binary searching, a semi`-range of [%-*@3 sweeprange]
|
||||
skew angle and steps by [%-*@3 sweepdelta] value.&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:FindSkewSweepAndSearch`(double`*`,double`*`,int`,int`,double`,double`,double`,int`):%- [@(0.0.255) b
|
||||
[s2;:Pix`:`:FindSkewSweepAndSearch`(double`*`,double`*`,int`,int`,double`,double`,double`):%- [@(0.0.255) b
|
||||
ool]_[* FindSkewSweepAndSearch](_[@(0.0.255) double]_`*[*@3 pangle],
|
||||
[@(0.0.255) double]_`*[*@3 pconf], [@(0.0.255) int]_[*@3 redsweep], [@(0.0.255) int]_[*@3 red
|
||||
search], [@(0.0.255) double]_[*@3 sweeprange], [@(0.0.255) double]_[*@3 sweepdelta],
|
||||
[@(0.0.255) double]_[*@3 minbsdelta], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; Full parameters skew finding function.Try to find skew of [%-*@3 page]
|
||||
[@(0.0.255) double]_[*@3 minbsdelta])&]
|
||||
[s3; Full parameters skew finding function.Try to find skew of image
|
||||
and returns it`'s value in [%-*@3 pangle] and confidence value
|
||||
in [%-*@3 pconf].[%-*@3 redsweep] is the sweep reduction factor (1,
|
||||
2, 4 or 8), [%-*@3 redsearch] is the binary search reduction factor
|
||||
|
|
|
|||
|
|
@ -9,123 +9,108 @@ topic "Image thresholding functions";
|
|||
[ {{10000F(128)G(128)@1 [s0; [* Image thresholding functions]]}}&]
|
||||
[s1;%- &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:DitherToBinary`(int`):%- [@(0.0.255) bool]_[* DitherToBinary]([@(0.0.255) i
|
||||
nt]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 page].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:DitherToBinarySpec`(int`,int`,int`):%- [@(0.0.255) bool]_[* DitherToBin
|
||||
arySpec]([@(0.0.255) int]_[*@3 lowerclip], [@(0.0.255) int]_[*@3 upperclip],
|
||||
[@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 lowerclip] [%-*@3 upperclip] [%-*@3 page].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:ThresholdToBinary`(int`,int`):%- [@(0.0.255) bool]_[* ThresholdToBinary
|
||||
]([@(0.0.255) int]_[*@3 threshold], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; Creates a new 1bpp black/white image from source`'s grayscale
|
||||
[%-*@3 page] using [%-*@3 threshold] as limiting value. Newly created
|
||||
image is appended at the end of PixRaster, and currently active
|
||||
page is set to it.&]
|
||||
[s3; [* WARNING], it operates [* ONLY ]on grayscale source images.&]
|
||||
[s3; Thresholded image is appended at the end of PixRaster&]
|
||||
[s2;:Pix`:`:DitherToBinary`(`):%- [@(0.0.255) Pix]_[* DitherToBinary]()&]
|
||||
[s3; &]
|
||||
[s3; Returns [%-@(0.0.255) true] on success, [%-@(0.0.255) false] otherwise.&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:VarThresholdToBinary`(int`,int`):%- [@(0.0.255) bool]_[* VarThresholdTo
|
||||
Binary]([@(0.0.255) int]_[*@3 thresholdPage], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_C
|
||||
URPAGE)&]
|
||||
[s3; [%-*@3 thresholdPage] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:DitherToBinarySpec`(int`,int`):%- [@(0.0.255) Pix]_[* DitherToBinarySpec]([@(0.0.255) i
|
||||
nt]_[*@3 lowerclip], [@(0.0.255) int]_[*@3 upperclip])&]
|
||||
[s3; [%-*@3 lowerclip] [%-*@3 upperclip] &]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:DitherToBinaryLUT`(int`,int`,int`):%- [@(0.0.255) bool]_[* DitherToBina
|
||||
ryLUT]([@(0.0.255) int]_[*@3 lowerclip], [@(0.0.255) int]_[*@3 upperclip],
|
||||
[@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 lowerclip] [%-*@3 upperclip] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:ThresholdToBinary`(int`):%- [@(0.0.255) Pix]_[* ThresholdToBinary]([@(0.0.255) i
|
||||
nt]_[*@3 threshold])&]
|
||||
[s3; Creates a new 1bpp black/white image from source`'s grayscale
|
||||
using [%-*@3 threshold] as limiting value.&]
|
||||
[s3; [* WARNING], it operates [* ONLY ]on grayscale source images.&]
|
||||
[s3; &]
|
||||
[s3; Returns thresholded [* Pix ]on success, an empty [* Pix ]on failure
|
||||
.&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:GenerateMaskByValue`(int`,int`):%- [@(0.0.255) bool]_[* GenerateMaskByV
|
||||
alue]([@(0.0.255) int]_[*@3 val], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 val] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:VarThresholdToBinary`(Pix`&`):%- [@(0.0.255) Pix]_[* VarThresholdToBinary]([@(0.0.255) P
|
||||
ix`&]_[*@3 thresholdPix])&]
|
||||
[s3; [%-*@3 thresholdPix].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:GenerateMaskByBand`(int`,int`,int`,int`):%- [@(0.0.255) bool]_[* Genera
|
||||
teMaskByBand]([@(0.0.255) int]_[*@3 lower], [@(0.0.255) int]_[*@3 upper],
|
||||
[@(0.0.255) int]_[*@3 inband], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 lower] [%-*@3 upper] [%-*@3 inband] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:DitherToBinaryLUT`(int`,int`):%- [@(0.0.255) Pix]_[* DitherToBinaryLUT]([@(0.0.255) i
|
||||
nt]_[*@3 lowerclip], [@(0.0.255) int]_[*@3 upperclip])&]
|
||||
[s3; [%-*@3 lowerclip] [%-*@3 upperclip].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:DitherTo2bpp`(int`,int`):%- [@(0.0.255) bool]_[* DitherTo2bpp]([@(0.0.255) i
|
||||
nt]_[*@3 cmapflag], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 cmapflag] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:GenerateMaskByValue`(int`):%- [@(0.0.255) Pix]_[* GenerateMaskByValue]([@(0.0.255) i
|
||||
nt]_[*@3 val])&]
|
||||
[s3; [%-*@3 val].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:DitherTo2bppSpec`(int`,int`,int`,int`):%- [@(0.0.255) bool]_[* DitherTo
|
||||
2bppSpec]([@(0.0.255) int]_[*@3 lowerclip], [@(0.0.255) int]_[*@3 upperclip],
|
||||
[@(0.0.255) int]_[*@3 cmapflag], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 lowerclip] [%-*@3 upperclip] [%-*@3 cmapflag] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:GenerateMaskByBand`(int`,int`,int`):%- [@(0.0.255) Pix]_[* GenerateMaskByBand
|
||||
]([@(0.0.255) int]_[*@3 lower], [@(0.0.255) int]_[*@3 upper], [@(0.0.255) int]_[*@3 inband])&]
|
||||
[s3; [%-*@3 lower] [%-*@3 upper] [%-*@3 inband].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:ThresholdTo2bpp`(int`,int`,int`):%- [@(0.0.255) bool]_[* ThresholdTo2bp
|
||||
p]([@(0.0.255) int]_[*@3 nlevels], [@(0.0.255) int]_[*@3 cmapflag], [@(0.0.255) int]_[*@3 pag
|
||||
e]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 nlevels] [%-*@3 cmapflag] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:DitherTo2bpp`(int`):%- [@(0.0.255) Pix]_[* DitherTo2bpp]([@(0.0.255) int]_[*@3 cm
|
||||
apflag])&]
|
||||
[s3; [%-*@3 cmapflag].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:ThresholdTo4bpp`(int`,int`,int`):%- [@(0.0.255) bool]_[* ThresholdTo4bp
|
||||
p]([@(0.0.255) int]_[*@3 nlevels], [@(0.0.255) int]_[*@3 cmapflag], [@(0.0.255) int]_[*@3 pag
|
||||
e]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 nlevels] [%-*@3 cmapflag] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:DitherTo2bppSpec`(int`,int`,int`):%- [@(0.0.255) Pix]_[* DitherTo2bppSpec]([@(0.0.255) i
|
||||
nt]_[*@3 lowerclip], [@(0.0.255) int]_[*@3 upperclip], [@(0.0.255) int]_[*@3 cmapflag])&]
|
||||
[s3; [%-*@3 lowerclip] [%-*@3 upperclip] [%-*@3 cmapflag].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:ThresholdOn8bpp`(int`,int`,int`):%- [@(0.0.255) bool]_[* ThresholdOn8bp
|
||||
p]([@(0.0.255) int]_[*@3 nlevels], [@(0.0.255) int]_[*@3 cmapflag], [@(0.0.255) int]_[*@3 pag
|
||||
e]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 nlevels] [%-*@3 cmapflag] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:ThresholdTo2bpp`(int`,int`):%- [@(0.0.255) Pix]_[* ThresholdTo2bpp]([@(0.0.255) i
|
||||
nt]_[*@3 nlevels], [@(0.0.255) int]_[*@3 cmapflag])&]
|
||||
[s3; [%-*@3 nlevels] [%-*@3 cmapflag].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:ThresholdGrayArb`(const char`*`,int`,int`,int`,int`,int`):%- [@(0.0.255) b
|
||||
ool]_[* ThresholdGrayArb]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 edgevals],
|
||||
[s2;:Pix`:`:ThresholdTo4bpp`(int`,int`):%- [@(0.0.255) Pix]_[* ThresholdTo4bpp]([@(0.0.255) i
|
||||
nt]_[*@3 nlevels], [@(0.0.255) int]_[*@3 cmapflag])&]
|
||||
[s3; [%-*@3 nlevels] [%-*@3 cmapflag].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:Pix`:`:ThresholdOn8bpp`(int`,int`):%- [@(0.0.255) Pix]_[* ThresholdOn8bpp]([@(0.0.255) i
|
||||
nt]_[*@3 nlevels], [@(0.0.255) int]_[*@3 cmapflag])&]
|
||||
[s3; [%-*@3 nlevels] [%-*@3 cmapflag].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:Pix`:`:ThresholdGrayArb`(const char`*`,int`,int`,int`,int`):%- [@(0.0.255) Pix]_[* T
|
||||
hresholdGrayArb]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 edgevals],
|
||||
[@(0.0.255) int]_[*@3 outdepth], [@(0.0.255) int]_[*@3 use`_average],
|
||||
[@(0.0.255) int]_[*@3 setblack], [@(0.0.255) int]_[*@3 setwhite], [@(0.0.255) int]_[*@3 page]_
|
||||
`=_PIXRASTER`_CURPAGE)&]
|
||||
[@(0.0.255) int]_[*@3 setblack], [@(0.0.255) int]_[*@3 setwhite])&]
|
||||
[s3; [%-*@3 edgevals] [%-*@3 outdepth] [%-*@3 use`_average] [%-*@3 setblack]
|
||||
[%-*@3 setwhite] [%-*@3 page].&]
|
||||
[%-*@3 setwhite].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:MakeGrayQuantIndexTable`(int`):%- [_^Buffer^ Buffer]<[@(0.0.255) int]>_
|
||||
[* MakeGrayQuantIndexTable]([@(0.0.255) int]_[*@3 nlevels])&]
|
||||
[s2;:Pix`:`:MakeGrayQuantIndexTable`(int`):%- [_^Buffer^ Buffer]<[@(0.0.255) int]>_[* MakeG
|
||||
rayQuantIndexTable]([@(0.0.255) int]_[*@3 nlevels])&]
|
||||
[s3; [%-*@3 nlevels].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:MakeGrayQuantTargetTable`(int`,int`):%- [_^Buffer^ Buffer]<[@(0.0.255) i
|
||||
nt]>_[* MakeGrayQuantTargetTable]([@(0.0.255) int]_[*@3 nlevels], [@(0.0.255) int]_[*@3 dep
|
||||
th])&]
|
||||
[s2;:Pix`:`:MakeGrayQuantTargetTable`(int`,int`):%- [_^Buffer^ Buffer]<[@(0.0.255) int]>_
|
||||
[* MakeGrayQuantTargetTable]([@(0.0.255) int]_[*@3 nlevels], [@(0.0.255) int]_[*@3 depth])&]
|
||||
[s3; [%-*@3 nlevels] [%-*@3 depth].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:GenerateMaskByBand32`(unsigned`,int`,int`,int`):%- [@(0.0.255) bool]_
|
||||
[* GenerateMaskByBand32]([@(0.0.255) unsigned]_[*@3 refval], [@(0.0.255) int]_[*@3 delm],
|
||||
[@(0.0.255) int]_[*@3 delp], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 refval] [%-*@3 delm] [%-*@3 delp] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:GenerateMaskByBand32`(unsigned`,int`,int`):%- [@(0.0.255) Pix]_[* GenerateMas
|
||||
kByBand32]([@(0.0.255) unsigned]_[*@3 refval], [@(0.0.255) int]_[*@3 delm],
|
||||
[@(0.0.255) int]_[*@3 delp])&]
|
||||
[s3; [%-*@3 refval] [%-*@3 delm] [%-*@3 delp].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:GenerateMaskByDiscr32`(unsigned`,unsigned`,int`,int`):%- [@(0.0.255) b
|
||||
ool]_[* GenerateMaskByDiscr32]([@(0.0.255) unsigned]_[*@3 refval1],
|
||||
[@(0.0.255) unsigned]_[*@3 refval2], [@(0.0.255) int]_[*@3 distflag],
|
||||
[@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 refval1] [%-*@3 refval2] [%-*@3 distflag] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:GenerateMaskByDiscr32`(unsigned`,unsigned`,int`):%- [@(0.0.255) Pix]_[* Gener
|
||||
ateMaskByDiscr32]([@(0.0.255) unsigned]_[*@3 refval1], [@(0.0.255) unsigned]_[*@3 refval2
|
||||
], [@(0.0.255) int]_[*@3 distflag])&]
|
||||
[s3; [%-*@3 refval1] [%-*@3 refval2] [%-*@3 distflag].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:GrayQuantFromHisto`(int`,double`,int`,int`):%- [@(0.0.255) bool]_[* Gra
|
||||
yQuantFromHisto]([@(0.0.255) int]_[*@3 mPage], [@(0.0.255) double]_[*@3 minfract],
|
||||
[@(0.0.255) int]_[*@3 maxsize], [@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 mPage] [%-*@3 minfract] [%-*@3 maxsize] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:GrayQuantFromHisto`(Pix`&`,double`,int`):%- [@(0.0.255) Pix]_[* GrayQuantFrom
|
||||
Histo]([@(0.0.255) Pix `&][*@3 mPaix], [@(0.0.255) double]_[*@3 minfract],
|
||||
[@(0.0.255) int]_[*@3 maxsize])&]
|
||||
[s3; [%-*@3 mPix] [%-*@3 minfract] [%-*@3 maxsize].&]
|
||||
[s4; &]
|
||||
[s1;%- &]
|
||||
[s2;:PixRaster`:`:ThresholdToValue`(int`,int`,int`):%- [@(0.0.255) bool]_[* ThresholdToVa
|
||||
lue]([@(0.0.255) int]_[*@3 threshval], [@(0.0.255) int]_[*@3 setval],
|
||||
[@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
|
||||
[s3; [%-*@3 threshval] [%-*@3 setval] [%-*@3 page].&]
|
||||
[s2;:Pix`:`:ThresholdToValue`(int`,int`):%- [@(0.0.255) Pix]_[* ThresholdToValue]([@(0.0.255) i
|
||||
nt]_[*@3 threshval], [@(0.0.255) int]_[*@3 setval])&]
|
||||
[s3; [%-*@3 threshval] [%-*@3 setval].&]
|
||||
[s4; &]
|
||||
[s0;%- ]
|
||||
[s0; ]
|
||||
|
|
@ -112,7 +112,7 @@ void PixRasterBaseCtrl::PaintCache()
|
|||
Array<Rect> rects;
|
||||
|
||||
// if no associated PixRaster object, do nothing
|
||||
if(!pixRasterCtrl || !pixRasterCtrl->GetPixRaster())
|
||||
if(!pixRasterCtrl || !pixRasterCtrl->GetPixBase())
|
||||
return;
|
||||
|
||||
// backups old imageCache positions inside the full tiff image
|
||||
|
|
@ -169,16 +169,16 @@ void PixRasterBaseCtrl::PaintCache()
|
|||
}
|
||||
|
||||
// gets associated PixRaster object
|
||||
PixRaster *pixRaster = pixRasterCtrl->GetPixRaster();
|
||||
PixBase *pixBase = pixRasterCtrl->GetPixBase();
|
||||
|
||||
// scans the PixRaster pages to see if some of them fits in
|
||||
// rectangles that must be repainted
|
||||
int currentTop = 0;
|
||||
int currentPage = pixRaster->GetActivePage();
|
||||
for(int i = 0 ; i < pixRaster->GetPageCount() ; i++)
|
||||
int currentPage = pixBase->GetActivePage();
|
||||
for(int i = 0 ; i < pixBase->GetPageCount() ; i++)
|
||||
{
|
||||
// sets the active page
|
||||
pixRaster->SeekPage(i);
|
||||
pixBase->SeekPage(i);
|
||||
|
||||
// translates current top of page in view coordinates
|
||||
int viewCurrentTop = iscale(currentTop, imageScale, 1000);
|
||||
|
|
@ -187,8 +187,8 @@ void PixRasterBaseCtrl::PaintCache()
|
|||
Rect viewPageRect(
|
||||
-cacheLeft,
|
||||
-cacheTop + viewCurrentTop,
|
||||
iscale(pixRaster->GetSize().cx, imageScale, 1000) - cacheLeft,
|
||||
iscale(pixRaster->GetSize().cy, imageScale, 1000) - cacheTop + viewCurrentTop
|
||||
iscale(pixBase->GetSize().cx, imageScale, 1000) - cacheLeft,
|
||||
iscale(pixBase->GetSize().cy, imageScale, 1000) - cacheTop + viewCurrentTop
|
||||
);
|
||||
|
||||
// now scans the rectangles that must be repainted
|
||||
|
|
@ -214,7 +214,7 @@ void PixRasterBaseCtrl::PaintCache()
|
|||
|
||||
// rescales the image area
|
||||
ImageEncoder t;
|
||||
Rescale(t, rect.GetSize(), *pixRaster, tiffRect);
|
||||
Rescale(t, rect.GetSize(), *pixBase, tiffRect);
|
||||
|
||||
// and copies insiede the cache area
|
||||
Image img = Image(t);
|
||||
|
|
@ -223,15 +223,22 @@ void PixRasterBaseCtrl::PaintCache()
|
|||
imageCache.Copy(Point(rect.left, rect.top), Rect(0, 0, img.GetWidth(), img.GetHeight()), img);
|
||||
}
|
||||
}
|
||||
currentTop += pixRaster->GetHeight() + iscale(10, 1000, imageScale);
|
||||
currentTop += pixBase->GetHeight() + iscale(10, 1000, imageScale);
|
||||
}
|
||||
|
||||
// restore PixRaster's active page
|
||||
pixRaster->SeekPage(currentPage);
|
||||
pixBase->SeekPage(currentPage);
|
||||
|
||||
|
||||
} // END PixRasterBaseCtrl::PaintCache()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// repaint polygon markers over the images
|
||||
void PixRasterBaseCtrl::PaintMarkers(void)
|
||||
{
|
||||
|
||||
} // END PixRasterBaseCtrl::PaintMarkers()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// paint routine
|
||||
void PixRasterBaseCtrl::Paint(Draw &d)
|
||||
|
|
@ -240,7 +247,7 @@ void PixRasterBaseCtrl::Paint(Draw &d)
|
|||
d.DrawRect(GetSize(), SColorFace());
|
||||
|
||||
// if no associated PixRaster, does nothing
|
||||
if(!pixRasterCtrl->GetPixRaster())
|
||||
if(!pixRasterCtrl->GetPixBase())
|
||||
return;
|
||||
|
||||
// paints image inside cache, if needed
|
||||
|
|
@ -270,7 +277,7 @@ void PixRasterBaseCtrl::Layout(void)
|
|||
static bool inside = false;
|
||||
|
||||
// if no associated PixRaster or no pages to display, hides scrollbar and return
|
||||
if(!pixRasterCtrl->GetPixRaster() || !pixRasterCtrl->GetPageCount())
|
||||
if(!pixRasterCtrl->GetPixBase() || !pixRasterCtrl->GetPageCount())
|
||||
{
|
||||
hScrollBar.Hide();
|
||||
vScrollBar.Hide();
|
||||
|
|
@ -292,21 +299,21 @@ void PixRasterBaseCtrl::Layout(void)
|
|||
int vScrollMax = vScrollBar.GetTotal();
|
||||
|
||||
// gets the PixRaster object
|
||||
PixRaster *pixRaster = pixRasterCtrl->GetPixRaster();
|
||||
PixBase *pixBase = pixRasterCtrl->GetPixBase();
|
||||
|
||||
// calculates max width and height
|
||||
// and total Tiff height, for all pages, with no gaps by now
|
||||
int rasterWidth = 0;
|
||||
int rasterHeight = 0;
|
||||
int maxHeight = 0;
|
||||
int pageCount = pixRaster->GetPageCount();
|
||||
int pageCount = pixBase->GetPageCount();
|
||||
for(int i = 0 ; i < pageCount ; i++)
|
||||
{
|
||||
// sets current page
|
||||
pixRaster->SeekPage(i);
|
||||
pixBase->SeekPage(i);
|
||||
|
||||
// gets page size
|
||||
Size sz = pixRaster->GetSize(i);
|
||||
Size sz = pixBase->GetSizeEx(i);
|
||||
|
||||
// updates width, maximum height and total height
|
||||
if(sz.cx > rasterWidth)
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ class PixRasterBaseCtrl : public Ctrl
|
|||
// repaint images on image cache
|
||||
virtual void PaintCache(void);
|
||||
|
||||
// repaint polygon markers over the images
|
||||
virtual void PaintMarkers(void);
|
||||
|
||||
// mouse wheel handler
|
||||
virtual void MouseWheel(Point p, int zdelta, dword keyflags);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@
|
|||
#include "PixRasterViewCtrl.h"
|
||||
|
||||
// initialize the control
|
||||
void PixRasterCtrl::Create(PixRaster *_pixRaster)
|
||||
void PixRasterCtrl::Create(PixBase *_pixBase)
|
||||
{
|
||||
// sets the PixRaster object
|
||||
pixRaster = _pixRaster;
|
||||
// sets the PixBase object
|
||||
pixBase = _pixBase;
|
||||
|
||||
// creates child controls and inserts them in splitter
|
||||
thumbs = new PixRasterThumbsCtrl(this);
|
||||
|
|
@ -27,9 +27,9 @@ void PixRasterCtrl::Create(PixRaster *_pixRaster)
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// constructors
|
||||
PixRasterCtrl::PixRasterCtrl(PixRaster *_pixRaster)
|
||||
PixRasterCtrl::PixRasterCtrl(PixBase *_pixBase)
|
||||
{
|
||||
Create(_pixRaster);
|
||||
Create(_pixBase);
|
||||
|
||||
} // END Constructor class PixRasterCtrl
|
||||
|
||||
|
|
@ -52,10 +52,10 @@ PixRasterCtrl::~PixRasterCtrl()
|
|||
} // END Destructor class PixRasterCtrl
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// sets the PixRaster object
|
||||
void PixRasterCtrl::SetPixRaster(PixRaster *_pixRaster)
|
||||
// sets the PixBase object
|
||||
void PixRasterCtrl::SetPixBase(PixBase *_pixBase)
|
||||
{
|
||||
pixRaster = _pixRaster;
|
||||
pixBase = _pixBase;
|
||||
|
||||
// signals image change to thumbs and view
|
||||
thumbs->Layout();
|
||||
|
|
@ -82,8 +82,8 @@ bool PixRasterCtrl::ShowThumbnails(bool s)
|
|||
// gets page count
|
||||
int PixRasterCtrl::GetPageCount()
|
||||
{
|
||||
if(pixRaster)
|
||||
return pixRaster->GetPageCount();
|
||||
if(pixBase)
|
||||
return pixBase->GetPageCount();
|
||||
else
|
||||
return 0;
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ void PixRasterCtrl::SetPage(int page)
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// reloads ctrl content -- needed when changing images in
|
||||
// associated PixRaster control
|
||||
// associated PixBase control
|
||||
void PixRasterCtrl::Reload(void)
|
||||
{
|
||||
thumbs->Layout();
|
||||
|
|
|
|||
|
|
@ -27,18 +27,18 @@ class PixRasterCtrl : public Ctrl
|
|||
Splitter hSplitter;
|
||||
|
||||
// PixRaster object associated to the control
|
||||
PixRaster *pixRaster;
|
||||
PixBase *pixBase;
|
||||
|
||||
// thumbnail panel flag
|
||||
bool hasThumbnails;
|
||||
|
||||
// initialize the control
|
||||
void Create(PixRaster *_pixRaster);
|
||||
void Create(PixBase *_pixBase);
|
||||
|
||||
public :
|
||||
|
||||
// constructors
|
||||
PixRasterCtrl(PixRaster *pixRaster);
|
||||
PixRasterCtrl(PixBase *pixBase);
|
||||
PixRasterCtrl();
|
||||
|
||||
// destructor
|
||||
|
|
@ -70,10 +70,10 @@ class PixRasterCtrl : public Ctrl
|
|||
int GetPageCount();
|
||||
|
||||
// sets the PixRaster object
|
||||
void SetPixRaster(PixRaster *_pixRaster);
|
||||
void SetPixBase(PixBase *_pixBase);
|
||||
|
||||
// gets the PixRaster object
|
||||
PixRaster *GetPixRaster() { return pixRaster; }
|
||||
PixBase *GetPixBase() { return pixBase; }
|
||||
|
||||
// sets current page
|
||||
void SetPage(int page);
|
||||
|
|
|
|||
|
|
@ -13,3 +13,4 @@ file
|
|||
PixRasterViewCtrl.cpp,
|
||||
PixRasterCtrl.h,
|
||||
PixRasterCtrl.cpp;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,20 +42,20 @@ void PixRasterThumbsCtrl::LeftDown(Point p, dword keyflags)
|
|||
int gapSize = iscale(10, 1000, imageScale);
|
||||
|
||||
// gets the PixRaster object
|
||||
PixRaster *pixRaster = pixRasterCtrl->GetPixRaster();
|
||||
PixBase *pixBase = pixRasterCtrl->GetPixBase();
|
||||
|
||||
// iterates through page positions to find the requested one
|
||||
int top = 0;
|
||||
for(int iPage = 0; iPage < pixRaster->GetPageCount(); iPage++)
|
||||
for(int iPage = 0; iPage < pixBase->GetPageCount(); iPage++)
|
||||
{
|
||||
int bottom = top + pixRaster->GetHeight(iPage);
|
||||
int bottom = top + pixBase->GetHeightEx(iPage);
|
||||
|
||||
if(clickPos >= top && clickPos <= bottom)
|
||||
{
|
||||
pixRasterCtrl->SetPage(iPage);
|
||||
break;
|
||||
}
|
||||
top += pixRaster->GetHeight(iPage) + gapSize;
|
||||
top += pixBase->GetHeightEx(iPage) + gapSize;
|
||||
}
|
||||
|
||||
} // END PixRasterThumbsCtrl::LeftDown()
|
||||
|
|
|
|||
|
|
@ -163,20 +163,20 @@ int PixRasterViewCtrl::GetZoomFactor(void)
|
|||
void PixRasterViewCtrl::SetPage(int page)
|
||||
{
|
||||
// gets the PixRaster object
|
||||
PixRaster *pixRaster = pixRasterCtrl->GetPixRaster();
|
||||
PixBase *pixBase = pixRasterCtrl->GetPixBase();
|
||||
|
||||
// calculate gaps to be exactly 10 pixels in every zoom factor
|
||||
int gapSize = iscale(10, 1000, imageScale);
|
||||
|
||||
// iterate thru pages to find requested page position
|
||||
int rasterPos = 0;
|
||||
int pageCount = pixRaster->GetPageCount();
|
||||
int pageCount = pixBase->GetPageCount();
|
||||
if(page > pageCount)
|
||||
page = pageCount;
|
||||
for(int i = 0 ; i < page ; i++)
|
||||
{
|
||||
// gets page size
|
||||
Size sz = pixRaster->GetSize(i);
|
||||
Size sz = pixBase->GetSizeEx(i);
|
||||
|
||||
rasterPos += sz.cy + gapSize;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _GatoFax_icpp_init_stub
|
||||
#define _GatoFax_icpp_init_stub
|
||||
#ifndef _PixRasterCtrl_icpp_init_stub
|
||||
#define _PixRasterCtrl_icpp_init_stub
|
||||
#include "CtrlLib/init"
|
||||
#include "plugin/tif/init"
|
||||
#include "PixRaster/init"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,18 +1,28 @@
|
|||
#include "TestLeptonica.h"
|
||||
|
||||
static void BaseLine(PixRaster &pixRaster)
|
||||
static void BaseLine(Pix & source, PixRaster &pixRaster)
|
||||
{
|
||||
CHECKR(pixRaster.DeskewLocal(), "Deskew error");
|
||||
Array<int> intArray = pixRaster.FindBaselines();
|
||||
pixRaster.Add(source);
|
||||
|
||||
Pix deskewed = source.DeskewLocal();
|
||||
CHECKR(deskewed, "Deskew error");
|
||||
pixRaster.Add(deskewed);
|
||||
|
||||
Array<int> intArray = deskewed.FindBaselines();
|
||||
CHECKR(intArray.GetCount(), "FindBaselines error");
|
||||
PIX *pix = pixRaster;
|
||||
int width = pixRaster.GetWidth();
|
||||
|
||||
// deep copy source
|
||||
Pix copied(deskewed, 1);
|
||||
|
||||
PIX *pix = copied;
|
||||
int width = copied.GetWidth();
|
||||
for(int iLine = 0; iLine < intArray.GetCount(); iLine++)
|
||||
{
|
||||
int y = intArray[iLine];
|
||||
for(int x = 0; x < width; x++)
|
||||
pixSetPixel(pix, x, y, 1);
|
||||
}
|
||||
pixRaster.Add(copied);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +30,8 @@ void TestLeptonica::onBaseLine()
|
|||
{
|
||||
String fileName;
|
||||
FileSelector fs;
|
||||
PIX *pix;
|
||||
|
||||
Pix source;
|
||||
|
||||
if(!PromptYesNo(
|
||||
"[= [* Text baseline analysis demo]&&"
|
||||
|
|
@ -42,11 +53,12 @@ void TestLeptonica::onBaseLine()
|
|||
}
|
||||
|
||||
// Loads pixraster from source raster
|
||||
CHECKR(pixRaster.Load(s), "Error loading image");
|
||||
CHECKR(source.Load(s), "Error loading image");
|
||||
s.Close();
|
||||
|
||||
// apply line removal algothithm
|
||||
BaseLine(pixRaster);
|
||||
pixRaster.Clear();
|
||||
BaseLine(source, pixRaster);
|
||||
|
||||
// refresh the PixRasterCtrl control with the new image contents
|
||||
pixRasterCtrl.Reload();
|
||||
|
|
|
|||
|
|
@ -1,72 +1,83 @@
|
|||
#include "TestLeptonica.h"
|
||||
|
||||
static void RemoveLines(PixRaster &pixRaster)
|
||||
static void RemoveLines(Pix &source, PixRaster &dest)
|
||||
{
|
||||
// gets source image page
|
||||
int source = pixRaster.GetActivePage();
|
||||
dest.Add(source);
|
||||
|
||||
// threshold the image
|
||||
CHECKR(pixRaster.ThresholdToBinary(170), "Error thresholding the image");
|
||||
int thresholded = pixRaster.GetActivePage();
|
||||
Pix thresholded = source.ThresholdToBinary(170);
|
||||
CHECKR(thresholded, "Error thresholding the image");
|
||||
dest.Add(thresholded);
|
||||
|
||||
// find image skew of thresholded image
|
||||
double angle;
|
||||
CHECKR(pixRaster.FindSkew(&angle, NULL, thresholded), "Error finding skew value");
|
||||
CHECKR(thresholded.FindSkew(&angle, NULL), "Error finding skew value");
|
||||
|
||||
// rotate original image using found threshold value
|
||||
double deg2rad = M_PI / 180.0;
|
||||
CHECKR(pixRaster.RotateAMGray(deg2rad * angle, 255, source), "Error rotating image");
|
||||
int rotated = pixRaster.GetActivePage();
|
||||
Pix rotated = source.RotateAMGray(deg2rad * angle, 255);
|
||||
CHECKR(rotated, "Error rotating image");
|
||||
dest.Add(rotated);
|
||||
|
||||
// extract the lines to be removed
|
||||
CHECKR(pixRaster.CloseGray(51, 1, rotated), "CloseGray error");
|
||||
int closed = pixRaster.GetActivePage();
|
||||
Pix closed = rotated.CloseGray(51, 1);
|
||||
CHECKR(closed, "CloseGray error");
|
||||
dest.Add(closed);
|
||||
|
||||
// solidify the lines to be removed
|
||||
CHECKR(pixRaster.ErodeGray(1, 5, closed), "ErodeGray error");
|
||||
int eroded = pixRaster.GetActivePage();
|
||||
Pix eroded = closed.ErodeGray(1, 5);
|
||||
CHECKR(eroded, "ErodeGray error");
|
||||
dest.Add(eroded);
|
||||
|
||||
// clean the background of those lines
|
||||
CHECKR(pixRaster.ThresholdToValue(210, 255, eroded), "ThresholdToValue error");
|
||||
int thresh2 = pixRaster.GetActivePage();
|
||||
Pix thresh2 = eroded.ThresholdToValue(210, 255);
|
||||
CHECKR(thresh2, "ThresholdToValue error");
|
||||
dest.Add(thresh2);
|
||||
|
||||
CHECKR(pixRaster.ThresholdToValue(200, 0, thresh2), "ThresholdToValue error");
|
||||
int thresh3 = pixRaster.GetActivePage();
|
||||
Pix thresh3 = thresh2.ThresholdToValue(200, 0);
|
||||
CHECKR(thresh3, "ThresholdToValue error");
|
||||
dest.Add(thresh3);
|
||||
|
||||
// get paint-through mask for changed pixels
|
||||
CHECKR(pixRaster.ThresholdToBinary(210, thresh3), "ThresholdToBinary error");
|
||||
int thresh4 = pixRaster.GetActivePage();
|
||||
Pix thresh4 = thresh3.ThresholdToBinary(210);
|
||||
CHECKR(thresh4, "ThresholdToBinary error");
|
||||
dest.Add(thresh4);
|
||||
|
||||
// invert the gray line image in order to whiten
|
||||
// the lines in the origina image
|
||||
CHECKR(pixRaster.Invert(thresh3), "Invert error");
|
||||
int inverted = pixRaster.GetActivePage();
|
||||
Pix inverted = thresh3.Invert();
|
||||
CHECKR(inverted, "Invert error");
|
||||
dest.Add(inverted);
|
||||
|
||||
// add inverted line image to original (deskewed) one
|
||||
// so all horizontal black lines will be erased
|
||||
// unrderlying parts of image are erase too
|
||||
CHECKR(pixRaster.AddGray(rotated, inverted), "AddGray error");
|
||||
int grayAdded = pixRaster.GetActivePage();
|
||||
Pix grayAdded = rotated.AddGray(inverted);
|
||||
CHECKR(grayAdded, "AddGray error");
|
||||
dest.Add(grayAdded);
|
||||
|
||||
// "opens" the image with wite stripes, so the stripes
|
||||
// gets closed my surrounding pixels. As this changes
|
||||
// also the rest of image, we will use that one just for
|
||||
// filling the stripes. That's done by aid of mask created before...
|
||||
CHECKR(pixRaster.OpenGray(1, 9, grayAdded), "OpenGray error");
|
||||
int opened2 = pixRaster.GetActivePage();
|
||||
Pix opened2 = grayAdded.OpenGray(1, 9);
|
||||
CHECKR(opened2, "OpenGray error");
|
||||
dest.Add(opened2);
|
||||
|
||||
// now to get the final result, we must combine the image with black stripes
|
||||
// removed with the one with grays opened to fill the stripes; we use the mask
|
||||
// created before to fill just the stripes and leave the rest of image unchanged
|
||||
CHECKR(pixRaster.CombineMasked(grayAdded, opened2, thresh4), "CombineMasked error");
|
||||
int final = pixRaster.GetActivePage();
|
||||
Pix final = grayAdded.CombineMasked(opened2, thresh4);
|
||||
CHECKR(final, "CombineMasked error");
|
||||
dest.Add(final);
|
||||
}
|
||||
|
||||
void TestLeptonica::onLineRemoval()
|
||||
{
|
||||
String fileName;
|
||||
FileSelector fs;
|
||||
PIX *pix;
|
||||
|
||||
Pix source;
|
||||
|
||||
if(!PromptYesNo(
|
||||
"[= [* Line removal demo]&&"
|
||||
|
|
@ -88,11 +99,12 @@ void TestLeptonica::onLineRemoval()
|
|||
}
|
||||
|
||||
// Loads pixraster from source raster
|
||||
CHECKR(pixRaster.Load(s), "Error loading image");
|
||||
CHECKR(source.Load(s), "Error loading image");
|
||||
s.Close();
|
||||
|
||||
// apply line removal algothithm
|
||||
RemoveLines(pixRaster);
|
||||
pixRaster.Clear();
|
||||
RemoveLines(source, pixRaster);
|
||||
|
||||
// refresh the PixRasterCtrl control with the new image contents
|
||||
pixRasterCtrl.Reload();
|
||||
|
|
|
|||
|
|
@ -1,15 +1,19 @@
|
|||
#include "TestLeptonica.h"
|
||||
|
||||
static void PageLayout(PixRaster &pixRaster)
|
||||
static void PageLayout(Pix &source, PixRaster &pixRaster)
|
||||
{
|
||||
CHECKR(pixRaster.GetRegionsBinary(), "Error getting page layout");
|
||||
pixRaster.Add(source);
|
||||
PixRaster regions = source.GetRegionsBinary();
|
||||
CHECKR(regions, "Error getting page layout");
|
||||
pixRaster.Add(regions);
|
||||
}
|
||||
|
||||
void TestLeptonica::onPageLayout()
|
||||
{
|
||||
String fileName;
|
||||
FileSelector fs;
|
||||
PIX *pix;
|
||||
|
||||
Pix source;
|
||||
|
||||
if(!PromptYesNo(
|
||||
"[= [* Page layout analysis demo]&&"
|
||||
|
|
@ -31,11 +35,12 @@ void TestLeptonica::onPageLayout()
|
|||
}
|
||||
|
||||
// Loads pixraster from source raster
|
||||
CHECKR(pixRaster.Load(s), "Error loading image");
|
||||
CHECKR(source.Load(s), "Error loading image");
|
||||
s.Close();
|
||||
|
||||
// apply line removal algothithm
|
||||
PageLayout(pixRaster);
|
||||
pixRaster.Clear();
|
||||
PageLayout(source, pixRaster);
|
||||
|
||||
// refresh the PixRasterCtrl control with the new image contents
|
||||
pixRasterCtrl.Reload();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ TestLeptonica::TestLeptonica()
|
|||
CtrlLayout(*this, "Leptonica library example suite");
|
||||
|
||||
// sets PixRaster in PixRasterCtrl
|
||||
pixRasterCtrl.SetPixRaster(&pixRaster);
|
||||
pixRasterCtrl.SetPixBase(&pixRaster);
|
||||
pixRasterCtrl.ShowThumbnails(true);
|
||||
|
||||
// connects button handlers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue