本文整理汇总了C++中pixClipRectangle函数的典型用法代码示例。如果您正苦于以下问题:C++ pixClipRectangle函数的具体用法?C++ pixClipRectangle怎么用?C++ pixClipRectangle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pixClipRectangle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pixaCreateFromBoxa
/*!
* pixaCreateFromBoxa()
*
* Input: pixs
* boxa
* &cropwarn (<optional return> TRUE if the boxa extent
* is larger than pixs.
* Return: pixad, or null on error
*
* Notes:
* (1) This simply extracts from pixs the region corresponding to each
* box in the boxa.
* (2) The 3rd arg is optional. If the extent of the boxa exceeds the
* size of the pixa, so that some boxes are either clipped
* or entirely outside the pix, a warning is returned as TRUE.
* (3) pixad will have only the properly clipped elements, and
* the internal boxa will be correct.
*/
PIXA *
pixaCreateFromBoxa(PIX *pixs,
BOXA *boxa,
l_int32 *pcropwarn)
{
l_int32 i, n, w, h, wbox, hbox, cropwarn;
BOX *box, *boxc;
PIX *pixd;
PIXA *pixad;
PROCNAME("pixaCreateFromBoxa");
if (!pixs)
return (PIXA *)ERROR_PTR("pixs not defined", procName, NULL);
if (!boxa)
return (PIXA *)ERROR_PTR("boxa not defined", procName, NULL);
n = boxaGetCount(boxa);
if ((pixad = pixaCreate(n)) == NULL)
return (PIXA *)ERROR_PTR("pixad not made", procName, NULL);
boxaGetExtent(boxa, &wbox, &hbox, NULL);
pixGetDimensions(pixs, &w, &h, NULL);
cropwarn = FALSE;
if (wbox > w || hbox > h)
cropwarn = TRUE;
if (pcropwarn)
*pcropwarn = cropwarn;
for (i = 0; i < n; i++) {
box = boxaGetBox(boxa, i, L_COPY);
if (cropwarn) { /* if box is outside pixs, pixd is NULL */
pixd = pixClipRectangle(pixs, box, &boxc); /* may be NULL */
if (pixd) {
pixaAddPix(pixad, pixd, L_INSERT);
pixaAddBox(pixad, boxc, L_INSERT);
}
boxDestroy(&box);
}
else {
pixd = pixClipRectangle(pixs, box, NULL);
pixaAddPix(pixad, pixd, L_INSERT);
pixaAddBox(pixad, box, L_INSERT);
}
}
return pixad;
}
开发者ID:AngusHardie,项目名称:TesseractOCR-For-Mac,代码行数:66,代码来源:pixabasic.c
示例2: ignore_alpha_at_edge
int ignore_alpha_at_edge(png_byte *alpha, unsigned char* indata, int w, int h, PIX *in, PIX **out)
{
int i, j, index, start_y, end_y;
int find_end_x = CCX_FALSE;
BOX* cropWindow;
for (j = 1; j < w-1; j++)
{
for (i = 0; i < h; i++)
{
index = indata[i * w + (j)];
if(alpha[index] != 0)
{
if(find_end_x == CCX_FALSE)
{
start_y = j;
find_end_x = CCX_TRUE;
}
else
{
end_y = j;
}
}
}
}
cropWindow = boxCreate(start_y, 0, (w - (start_y + ( w - end_y) )), h - 1);
*out = pixClipRectangle(in, cropWindow, NULL);
boxDestroy(&cropWindow);
return 0;
}
开发者ID:ioanas96,项目名称:ccextractor,代码行数:30,代码来源:ocr.c
示例3: GetBinaryImage
/**
* Returns an image of the current object at the given level in greyscale
* if available in the input. To guarantee a binary image use BinaryImage.
* NOTE that in order to give the best possible image, the bounds are
* expanded slightly over the binary connected component, by the supplied
* padding, so the top-left position of the returned image is returned
* in (left,top). These will most likely not match the coordinates
* returned by BoundingBox.
* Use pixDestroy to delete the image after use.
*/
Pix* PageIterator::GetImage(PageIteratorLevel level, int padding,
int* left, int* top) const {
int right, bottom;
if (!BoundingBox(level, left, top, &right, &bottom))
return NULL;
Pix* pix = tesseract_->pix_grey();
if (pix == NULL)
return GetBinaryImage(level);
// Expand the box.
*left = MAX(*left - padding, 0);
*top = MAX(*top - padding, 0);
right = MIN(right + padding, rect_width_);
bottom = MIN(bottom + padding, rect_height_);
Box* box = boxCreate(*left, *top, right - *left, bottom - *top);
Pix* grey_pix = pixClipRectangle(pix, box, NULL);
boxDestroy(&box);
if (level == RIL_BLOCK) {
Pix* mask = it_->block()->block->render_mask();
Pix* expanded_mask = pixCreate(right - *left, bottom - *top, 1);
pixRasterop(expanded_mask, padding, padding,
pixGetWidth(mask), pixGetHeight(mask),
PIX_SRC, mask, 0, 0);
pixDestroy(&mask);
pixDilateBrick(expanded_mask, expanded_mask, 2*padding + 1, 2*padding + 1);
pixInvert(expanded_mask, expanded_mask);
pixSetMasked(grey_pix, expanded_mask, 255);
pixDestroy(&expanded_mask);
}
return grey_pix;
}
开发者ID:0xkasun,项目名称:Dummy_Tes,代码行数:41,代码来源:pageiterator.cpp
示例4: pixaClipToPix
/*!
* pixaClipToPix()
*
* Input: pixas
* pixs
* Return: pixad, or null on error
*
* Notes:
* (1) This is intended for use in situations where pixas
* was originally generated from the input pixs.
* (2) Returns a pixad where each pix in pixas is ANDed
* with its associated region of the input pixs. This
* region is specified by the the box that is associated
* with the pix.
* (3) In a typical application of this function, pixas has
* a set of region masks, so this generates a pixa of
* the parts of pixs that correspond to each region
* mask component, along with the bounding box for
* the region.
*/
PIXA *
pixaClipToPix(PIXA *pixas,
PIX *pixs)
{
l_int32 i, n;
BOX *box;
PIX *pix, *pixc;
PIXA *pixad;
PROCNAME("pixaClipToPix");
if (!pixas)
return (PIXA *)ERROR_PTR("pixas not defined", procName, NULL);
if (!pixs)
return (PIXA *)ERROR_PTR("pixs not defined", procName, NULL);
n = pixaGetCount(pixas);
if ((pixad = pixaCreate(n)) == NULL)
return (PIXA *)ERROR_PTR("pixad not made", procName, NULL);
for (i = 0; i < n; i++) {
pix = pixaGetPix(pixas, i, L_CLONE);
box = pixaGetBox(pixas, i, L_COPY);
pixc = pixClipRectangle(pixs, box, NULL);
pixAnd(pixc, pixc, pix);
pixaAddPix(pixad, pixc, L_INSERT);
pixaAddBox(pixad, box, L_INSERT);
pixDestroy(&pix);
}
return pixad;
}
开发者ID:ONLYOFFICE,项目名称:core,代码行数:52,代码来源:pixafunc1.cpp
示例5: Java_com_googlecode_leptonica_android_Clip_nativeClipRectangle
jint Java_com_googlecode_leptonica_android_Clip_nativeClipRectangle(JNIEnv *env, jclass clazz, jint nativePix, jint nativeBox) {
LOGV("%s",__FUNCTION__);
PIX *pixs = (PIX *) nativePix;
BOX *box = (BOX *) nativeBox;
PIX *pixd;
pixd = pixClipRectangle(pixs,box,NULL);
return (jint) pixd;
}
开发者ID:ArunPandiyan,项目名称:textfairy,代码行数:9,代码来源:utilities.cpp
示例6: Java_com_googlecode_leptonica_android_Clip_nativeClipRectangle
jlong Java_com_googlecode_leptonica_android_Clip_nativeClipRectangle(JNIEnv *env, jclass clazz,
jlong nativePix, jlong nativeBox) {
PIX *pixs = (PIX *) nativePix;
BOX *box = (BOX *) nativeBox;
PIX *pixd;
pixd = pixClipRectangle(pixs,box,NULL);
return (jlong) pixd;
}
开发者ID:0ximDigital,项目名称:appsScanner,代码行数:9,代码来源:utilities.cpp
示例7: NumTouchingIntersections
// Returns the number of components in the intersection_pix touched by line_box.
static int NumTouchingIntersections(Box* line_box, Pix* intersection_pix) {
if (intersection_pix == NULL) return 0;
Pix* rect_pix = pixClipRectangle(intersection_pix, line_box, NULL);
Boxa* boxa = pixConnComp(rect_pix, NULL, 8);
pixDestroy(&rect_pix);
if (boxa == NULL) return false;
int result = boxaGetCount(boxa);
boxaDestroy(&boxa);
return result;
}
开发者ID:xmarston,项目名称:BillRecognizer,代码行数:11,代码来源:linefind.cpp
示例8: if
// Helper gets the image of a rectangle, using the block.re_rotation() if
// needed to get to the image, and rotating the result back to horizontal
// layout. (CJK characters will be on their left sides) The vertical text flag
// is set in the returned ImageData if the text was originally vertical, which
// can be used to invoke a different CJK recognition engine. The revised_box
// is also returned to enable calculation of output bounding boxes.
ImageData* Tesseract::GetRectImage(const TBOX& box, const BLOCK& block,
int padding, TBOX* revised_box) const {
TBOX wbox = box;
wbox.pad(padding, padding);
*revised_box = wbox;
// Number of clockwise 90 degree rotations needed to get back to tesseract
// coords from the clipped image.
int num_rotations = 0;
if (block.re_rotation().y() > 0.0f)
num_rotations = 1;
else if (block.re_rotation().x() < 0.0f)
num_rotations = 2;
else if (block.re_rotation().y() < 0.0f)
num_rotations = 3;
// Handle two cases automatically: 1 the box came from the block, 2 the box
// came from a box file, and refers to the image, which the block may not.
if (block.bounding_box().major_overlap(*revised_box))
revised_box->rotate(block.re_rotation());
// Now revised_box always refers to the image.
// BestPix is never colormapped, but may be of any depth.
Pix* pix = BestPix();
int width = pixGetWidth(pix);
int height = pixGetHeight(pix);
TBOX image_box(0, 0, width, height);
// Clip to image bounds;
*revised_box &= image_box;
if (revised_box->null_box()) return NULL;
Box* clip_box = boxCreate(revised_box->left(), height - revised_box->top(),
revised_box->width(), revised_box->height());
Pix* box_pix = pixClipRectangle(pix, clip_box, NULL);
if (box_pix == NULL) return NULL;
boxDestroy(&clip_box);
if (num_rotations > 0) {
Pix* rot_pix = pixRotateOrth(box_pix, num_rotations);
pixDestroy(&box_pix);
box_pix = rot_pix;
}
// Convert sub-8-bit images to 8 bit.
int depth = pixGetDepth(box_pix);
if (depth < 8) {
Pix* grey;
grey = pixConvertTo8(box_pix, false);
pixDestroy(&box_pix);
box_pix = grey;
}
bool vertical_text = false;
if (num_rotations > 0) {
// Rotated the clipped revised box back to internal coordinates.
FCOORD rotation(block.re_rotation().x(), -block.re_rotation().y());
revised_box->rotate(rotation);
if (num_rotations != 2)
vertical_text = true;
}
return new ImageData(vertical_text, box_pix);
}
开发者ID:hoiqs,项目名称:tesseract-ocr,代码行数:61,代码来源:linerec.cpp
示例9: recogRescoreDidResult
/*!
* \brief recogRescoreDidResult()
*
* \param[in] recog with LUT's pre-computed
* \param[out] ppixdb [optional] debug result; can be null
* \return 0 if OK, 1 on error
*
* <pre>
* Notes:
* (1) This does correlation matching with all templates using the
* viterbi path segmentation.
* </pre>
*/
static l_int32
recogRescoreDidResult(L_RECOG *recog,
PIX **ppixdb)
{
l_int32 i, n, w2, h1, templ, x, xloc, dely, index;
char *text;
l_float32 score;
BOX *box1;
PIX *pixs, *pix1;
L_RDID *did;
PROCNAME("recogRescoreDidResult");
if (ppixdb) *ppixdb = NULL;
if (!recog)
return ERROR_INT("recog not defined", procName, 1);
if ((did = recogGetDid(recog)) == NULL)
return ERROR_INT("did not defined", procName, 1);
if (did->fullarrays == 0)
return ERROR_INT("did full arrays not made", procName, 1);
if ((n = numaGetCount(did->naxloc)) == 0)
return ERROR_INT("no elements in path", procName, 1);
pixs = did->pixs;
h1 = pixGetHeight(pixs);
for (i = 0; i < n; i++) {
numaGetIValue(did->natempl, i, &templ);
numaGetIValue(did->naxloc, i, &xloc);
numaGetIValue(did->nadely, i, &dely);
pixaGetPixDimensions(recog->pixa_u, templ, &w2, NULL, NULL);
/* TODO: try to fix xloc - 4, etc. */
x = L_MAX(xloc, 0);
box1 = boxCreate(x, dely, w2, h1);
pix1 = pixClipRectangle(pixs, box1, NULL);
recogIdentifyPix(recog, pix1, NULL);
recogTransferRchToDid(recog, x, dely);
if (ppixdb) {
rchExtract(recog->rch, &index, &score, &text,
NULL, NULL, NULL, NULL);
fprintf(stderr, "text = %s, index = %d, score = %5.3f\n",
text, index, score);
}
pixDestroy(&pix1);
boxDestroy(&box1);
LEPT_FREE(text);
}
/* numaWriteStream(stderr, recog->did->nadely_r); */
if (ppixdb)
*ppixdb = recogShowPath(recog, 1);
return 0;
}
开发者ID:ConfusedReality,项目名称:pkg_images_leptonica,代码行数:67,代码来源:recogdid.c
示例10: getBlobBoxImCoords
void M_Utils::dispBlobOCRRes(BLOBNBOX* blob, PIX* im,
Tesseract* ocrengine) {
BOX* box_ = getBlobBoxImCoords(blob, im);
PIX* bboxim = pixClipRectangle(im, box_, NULL);
pixDisplay(bboxim, 100, 100);
BLOB_CHOICE* ocr_res = runBlobOCR(blob, ocrengine);
const char* const unicode_res = getBlobChoiceUnicode(ocr_res, ocrengine);
cout << "OCR result: " << unicode_res << endl;
cout << "certainty: " << ocr_res->certainty() << endl;
waitForInput();
}
开发者ID:Andy0898,项目名称:Project_Isagoge,代码行数:11,代码来源:M_Utils.cpp
示例11: switch
/**
* Returns a binary image of the current object at the given level.
* The position and size match the return from BoundingBoxInternal, and so this
* could be upscaled with respect to the original input image.
* Use pixDestroy to delete the image after use.
* The following methods are used to generate the images:
* RIL_BLOCK: mask the page image with the block polygon.
* RIL_TEXTLINE: Clip the rectangle of the line box from the page image.
* TODO(rays) fix this to generate and use a line polygon.
* RIL_WORD: Clip the rectangle of the word box from the page image.
* RIL_SYMBOL: Render the symbol outline to an image for cblobs (prior
* to recognition) or the bounding box otherwise.
* A reconstruction of the original image (using xor to check for double
* representation) should be reasonably accurate,
* apart from removed noise, at the block level. Below the block level, the
* reconstruction will be missing images and line separators.
* At the symbol level, kerned characters will be invade the bounding box
* if rendered after recognition, making an xor reconstruction inaccurate, but
* an or construction better. Before recognition, symbol-level reconstruction
* should be good, even with xor, since the images come from the connected
* components.
*/
Pix* PageIterator::GetBinaryImage(PageIteratorLevel level) const {
int left, top, right, bottom;
if (!BoundingBoxInternal(level, &left, &top, &right, &bottom))
return NULL;
Pix* pix = NULL;
switch (level) {
case RIL_BLOCK:
case RIL_PARA:
int bleft, btop, bright, bbottom;
BoundingBoxInternal(RIL_BLOCK, &bleft, &btop, &bright, &bbottom);
pix = it_->block()->block->render_mask();
// AND the mask and the image.
pixRasterop(pix, 0, 0, pixGetWidth(pix), pixGetHeight(pix),
PIX_SRC & PIX_DST, tesseract_->pix_binary(),
bleft, btop);
if (level == RIL_PARA) {
// RIL_PARA needs further attention:
// clip the paragraph from the block mask.
Box* box = boxCreate(left - bleft, top - btop,
right - left, bottom - top);
Pix* pix2 = pixClipRectangle(pix, box, NULL);
boxDestroy(&box);
pixDestroy(&pix);
pix = pix2;
}
break;
case RIL_TEXTLINE:
case RIL_WORD:
case RIL_SYMBOL:
if (level == RIL_SYMBOL && cblob_it_ != NULL &&
cblob_it_->data()->area() != 0)
return cblob_it_->data()->render();
// Just clip from the bounding box.
Box* box = boxCreate(left, top, right - left, bottom - top);
pix = pixClipRectangle(tesseract_->pix_binary(), box, NULL);
boxDestroy(&box);
break;
}
return pix;
}
开发者ID:0xkasun,项目名称:Dummy_Tes,代码行数:62,代码来源:pageiterator.cpp
示例12: main
int main(int argc,
char **argv)
{
char *dirin, *dirout, *infile, *outfile, *tail;
l_int32 i, nfiles, border, x, y, w, h, xb, yb, wb, hb;
BOX *box1, *box2;
BOXA *boxa1, *boxa2;
PIX *pixs, *pixt1, *pixd;
SARRAY *safiles;
static char mainName[] = "croptext";
if (argc != 4)
return ERROR_INT("Syntax: croptext dirin border dirout", mainName, 1);
dirin = argv[1];
border = atoi(argv[2]);
dirout = argv[3];
setLeptDebugOK(1);
safiles = getSortedPathnamesInDirectory(dirin, NULL, 0, 0);
nfiles = sarrayGetCount(safiles);
for (i = 0; i < nfiles; i++) {
infile = sarrayGetString(safiles, i, L_NOCOPY);
splitPathAtDirectory(infile, NULL, &tail);
outfile = genPathname(dirout, tail);
pixs = pixRead(infile);
pixt1 = pixMorphSequence(pixs, "r11 + c10.40 + o5.5 + x4", 0);
boxa1 = pixConnComp(pixt1, NULL, 8);
if (boxaGetCount(boxa1) == 0) {
fprintf(stderr, "Warning: no components on page %s\n", tail);
continue;
}
boxa2 = boxaSort(boxa1, L_SORT_BY_AREA, L_SORT_DECREASING, NULL);
box1 = boxaGetBox(boxa2, 0, L_CLONE);
boxGetGeometry(box1, &x, &y, &w, &h);
xb = L_MAX(0, x - border);
yb = L_MAX(0, y - border);
wb = w + 2 * border;
hb = h + 2 * border;
box2 = boxCreate(xb, yb, wb, hb);
pixd = pixClipRectangle(pixs, box2, NULL);
pixWrite(outfile, pixd, IFF_TIFF_G4);
pixDestroy(&pixs);
pixDestroy(&pixt1);
pixDestroy(&pixd);
boxaDestroy(&boxa1);
boxaDestroy(&boxa2);
}
return 0;
}
开发者ID:chewi,项目名称:leptonica,代码行数:52,代码来源:croptext.c
示例13: getImagePhash_px
unsigned long long getImagePhash_px( PIX *pix_orig, char *tmpFilename ) {
int free_8 = 0;
// Convert colour images down to grey
PIX *pix8;
if( pixGetDepth(pix_orig) > 8 ) {
pix8 = pixScaleRGBToGrayFast( pix_orig, 1, COLOR_GREEN );
if( pix8 == NULL ) {
printf("Covertion to 8bit, did not go well.");
return 0;
}
free_8 = 1;
}
else {
// already gray
free_8 = 0;
pix8 = pix_orig;
}
int width = pixGetWidth( pix8 );
int height = pixGetHeight( pix8 );
BOX* box = boxCreate(1, 1, width-2, height-2);
PIX* pixc = pixClipRectangle(pix8, box, NULL);
if(free_8 == 1) {
pixDestroy( &pix8 );
}
PIX *pix8s = pixScale(pixc, 0.2, 0.2);
pixDestroy( &pixc );
// Convert image down to binary (no gray)
/* PIX *pix1 = pixThresholdToBinary( pix8s, 200 );
if( pix1 == NULL ) {
printf( "Covertion to 1bit, did not go well.");
pixDestroy( &pix8s );
return 0;
}
pixDestroy( &pix8s );
*/
// Save the file for pHash processnig
pixWrite( tmpFilename, pix8s, IFF_JFIF_JPEG);
pixDestroy( &pix8s );
unsigned long long ret = calculateImagePhash( tmpFilename );
//unlink(tmpFilename);
return ret;
}
开发者ID:Rventric,项目名称:opendias,代码行数:50,代码来源:phash_test.c
示例14: main
int main(int argc,
char **argv)
{
BOX *box;
PIX *pixt1, *pixt2, *pix1, *pix2, *pix3;
L_REGPARAMS *rp;
if (regTestSetup(argc, argv, &rp))
return 1;
pixt1 = pixRead("feyn.tif"); /* 300 ppi */
box = boxCreate(19, 774, 2247, 2025);
pix1 = pixClipRectangle(pixt1, box, NULL);
pixDestroy(&pixt1);
pixt1 = pixRead("lucasta.150.jpg");
pixt2 = pixConvertTo1(pixt1, 128); /* 150 ppi */
pix2 = pixScale(pixt2, 2.2, 2.2); /* 300 ppi */
pixDestroy(&pixt1);
pixDestroy(&pixt2);
pixt1 = pixRead("zanotti-78.jpg");
pixt2 = pixConvertTo1(pixt1, 128); /* 150 ppi */
pix3 = pixScale(pixt2, 2.0, 2.0); /* 300 ppi */
pixDestroy(&pixt1);
pixDestroy(&pixt2);
boxDestroy(&box);
/* Make word boxes using pixWordMaskByDilation() */
MakeWordBoxes1(pix1, 20, rp); /* 0 */
MakeWordBoxes1(pix2, 20, rp); /* 1 */
MakeWordBoxes1(pix3, 20, rp); /* 2 */
/* Make word boxes using the higher-level functions
* pixGetWordsInTextlines() and pixGetWordBoxesInTextlines() */
MakeWordBoxes2(pix1, 1, rp); /* 3, 4 */
MakeWordBoxes2(pix2, 1, rp); /* 5, 6 */
MakeWordBoxes2(pix3, 1, rp); /* 7, 8 */
/* Make word boxes using the higher-level functions
* pixGetWordsInTextlines() and pixGetWordBoxesInTextlines() */
MakeWordBoxes2(pix1, 2, rp); /* 9, 10 */
MakeWordBoxes2(pix2, 2, rp); /* 11, 12 */
MakeWordBoxes2(pix3, 2, rp); /* 13, 14 */
pixDestroy(&pix1);
pixDestroy(&pix2);
pixDestroy(&pix3);
return regTestCleanup(rp);
}
开发者ID:0ximDigital,项目名称:appsScanner,代码行数:48,代码来源:wordboxes_reg.c
示例15: pixGetWidth
// Returns a pix of the original sample image. The pix is padded all round
// by padding wherever possible.
// The returned Pix must be pixDestroyed after use.
// If the input page_pix is nullptr, nullptr is returned.
Pix* TrainingSample::GetSamplePix(int padding, Pix* page_pix) const {
if (page_pix == nullptr)
return nullptr;
int page_width = pixGetWidth(page_pix);
int page_height = pixGetHeight(page_pix);
TBOX padded_box = bounding_box();
padded_box.pad(padding, padding);
// Clip the padded_box to the limits of the page
TBOX page_box(0, 0, page_width, page_height);
padded_box &= page_box;
Box* box = boxCreate(page_box.left(), page_height - page_box.top(),
page_box.width(), page_box.height());
Pix* sample_pix = pixClipRectangle(page_pix, box, nullptr);
boxDestroy(&box);
return sample_pix;
}
开发者ID:Shreeshrii,项目名称:tesseract,代码行数:20,代码来源:trainingsample.cpp
示例16: main
main(int argc,
char **argv)
{
char buf[256];
l_int32 i, j, k, index, conn, depth, bc;
BOX *box;
PIX *pix, *pixs, *pixd;
PIXA *pixa;
L_REGPARAMS *rp;
if (regTestSetup(argc, argv, &rp))
return 1;
pix = pixRead("feyn.tif");
box = boxCreate(383, 338, 1480, 1050);
pixs = pixClipRectangle(pix, box, NULL);
regTestWritePixAndCheck(rp, pixs, IFF_PNG); /* 0 */
for (i = 0; i < 2; i++) {
conn = 4 + 4 * i;
for (j = 0; j < 2; j++) {
depth = 8 + 8 * j;
for (k = 0; k < 2; k++) {
bc = k + 1;
index = 4 * i + 2 * j + k;
fprintf(stderr, "Set %d\n", index);
if (DEBUG) {
fprintf(stderr, "%d: conn = %d, depth = %d, bc = %d\n",
rp->index + 1, conn, depth, bc);
}
pixa = pixaCreate(0);
pixSaveTiled(pixs, pixa, 1, 1, 20, 8);
TestDistance(pixa, pixs, conn, depth, bc, rp);
pixd = pixaDisplay(pixa, 0, 0);
pixDisplayWithTitle(pixd, 0, 0, NULL, rp->display);
pixaDestroy(&pixa);
pixDestroy(&pixd);
}
}
}
boxDestroy(&box);
pixDestroy(&pix);
pixDestroy(&pixs);
regTestCleanup(rp);
return 0;
}
开发者ID:slohman,项目名称:October2012Workspace,代码行数:47,代码来源:distance_reg.c
示例17: pixClone
// Get a clone/copy of the source image rectangle.
// The returned Pix must be pixDestroyed.
// This function will be used in the future by the page layout analysis, and
// the layout analysis that uses it will only be available with Leptonica,
// so there is no raw equivalent.
Pix* ImageThresholder::GetPixRect() {
if (pix_ != NULL) {
if (IsFullImage()) {
// Just clone the whole thing.
return pixClone(pix_);
} else {
// Crop to the given rectangle.
Box* box = boxCreate(rect_left_, rect_top_, rect_width_, rect_height_);
Pix* cropped = pixClipRectangle(pix_, box, NULL);
boxDestroy(&box);
return cropped;
}
}
// The input is raw, so we have to make a copy of it.
Pix* raw_pix;
RawRectToPix(&raw_pix);
return raw_pix;
}
开发者ID:ErfanHasmin,项目名称:scope-ocr,代码行数:23,代码来源:thresholder.cpp
示例18: pixFindMinRunsOrthogonal
/*!
* pixFindMinRunsOrthogonal()
*
* Input: pixs (1 bpp)
* angle (in radians)
* depth (of pixd: 8 or 16 bpp)
* Return: pixd (8 or 16 bpp), or null on error
*
* Notes:
* (1) This computes, for each fg pixel in pixs, the minimum of
* the runlengths going through that pixel in two orthogonal
* directions: at @angle and at (90 + @angle).
* (2) We use rotation by shear because the forward and backward
* rotations by the same angle are exact inverse operations.
* As a result, the nonzero pixels in pixd correspond exactly
* to the fg pixels in pixs. This is not the case with
* sampled rotation, due to spatial quantization. Nevertheless,
* the result suffers from lack of exact correspondence
* between original and rotated pixels, also due to spatial
* quantization, causing some boundary pixels to be
* shifted from bg to fg or v.v.
*/
static PIX *
pixFindMinRunsOrthogonal(PIX *pixs,
l_float32 angle,
l_int32 depth)
{
l_int32 w, h, diag, xoff, yoff;
PIX *pixb, *pixr, *pixh, *pixv, *pixg1, *pixg2, *pixd;
BOX *box;
PROCNAME("pixFindMinRunsOrthogonal");
if (!pixs || pixGetDepth(pixs) != 1)
return (PIX *)ERROR_PTR("pixs undefined or not 1 bpp", procName, NULL);
/* Rasterop into the center of a sufficiently large image
* so we don't lose pixels for any rotation angle. */
pixGetDimensions(pixs, &w, &h, NULL);
diag = (l_int32)(sqrt((l_float64)(w * w + h * h)) + 2.5);
xoff = (diag - w) / 2;
yoff = (diag - h) / 2;
pixb = pixCreate(diag, diag, 1);
pixRasterop(pixb, xoff, yoff, w, h, PIX_SRC, pixs, 0, 0);
/* Rotate about the 'center', get the min of orthogonal transforms,
* rotate back, and crop the part corresponding to pixs. */
pixr = pixRotateShear(pixb, diag / 2, diag / 2, angle, L_BRING_IN_WHITE);
pixh = pixRunlengthTransform(pixr, 1, L_HORIZONTAL_RUNS, depth);
pixv = pixRunlengthTransform(pixr, 1, L_VERTICAL_RUNS, depth);
pixg1 = pixMinOrMax(NULL, pixh, pixv, L_CHOOSE_MIN);
pixg2 = pixRotateShear(pixg1, diag / 2, diag / 2, -angle, L_BRING_IN_WHITE);
box = boxCreate(xoff, yoff, w, h);
pixd = pixClipRectangle(pixg2, box, NULL);
pixDestroy(&pixb);
pixDestroy(&pixr);
pixDestroy(&pixh);
pixDestroy(&pixv);
pixDestroy(&pixg1);
pixDestroy(&pixg2);
boxDestroy(&box);
return pixd;
}
开发者ID:Brigadier1-9,项目名称:node-dv,代码行数:64,代码来源:runlength.c
示例19: CountPixelsAdjacentToLine
// Returns the number of black pixels found in the box made by adding the line
// width to both sides of the line bounding box. (Increasing the smallest
// dimension of the bounding box.)
static int CountPixelsAdjacentToLine(int line_width, Box* line_box,
Pix* nonline_pix) {
l_int32 x, y, box_width, box_height;
boxGetGeometry(line_box, &x, &y, &box_width, &box_height);
if (box_width > box_height) {
// horizontal line.
int bottom = MIN(pixGetHeight(nonline_pix), y + box_height + line_width);
y = MAX(0, y - line_width);
box_height = bottom - y;
} else {
// Vertical line.
int right = MIN(pixGetWidth(nonline_pix), x + box_width + line_width);
x = MAX(0, x - line_width);
box_width = right - x;
}
Box* box = boxCreate(x, y, box_width, box_height);
Pix* rect_pix = pixClipRectangle(nonline_pix, box, NULL);
boxDestroy(&box);
l_int32 result;
pixCountPixels(rect_pix, &result, NULL);
pixDestroy(&rect_pix);
return result;
}
开发者ID:xmarston,项目名称:BillRecognizer,代码行数:26,代码来源:linefind.cpp
示例20: LEP_LOG
//------------------------------------------------------------------------------
//Ортогональный поворот исходного изображения и обрезка его до
//крайней правой нижней части с размером (dX x dY)
//------------------------------------------------------------------------------
PIX* LeptPrepareFile::getCroppingRotatePix(PIX *pix, l_int32 degree, l_int32 dX, l_int32 dY)
{
PIX *pixRotated, *pixCrop;
BOX *boxCrop;
l_int32 quads;
LEP_LOG("enter");
SetNULL(3, (void **)&pixRotated, &pixCrop, &boxCrop);
try
{
LEP_STR_THROW(!pix, "Изображение не найдено");
quads = degree / 90;
pixRotated = pixRotateOrth(pix, quads);
LEP_STR_THROW(!pixRotated, "Ошибка поворота");
boxCrop = boxCreate(pixRotated->w - dX,
pixRotated->h - dY,
dX, dY);
LEP_STR_THROW(!boxCrop, "Ошибка создания box");
pixCrop = pixClipRectangle(pixRotated, boxCrop, NULL);
LEP_STR_THROW(!pixCrop, "Ошибка обрезки");
}catch (string error)
{
LEP_ERROR(error);
};
if (pixRotated) pixDestroy(&pixRotated);
if (boxCrop) boxDestroy(&boxCrop);
LEP_LOG("exit");
return pixCrop;
}
开发者ID:VLunev,项目名称:LeptonicaRecog,代码行数:41,代码来源:LeptPrepareFile.cpp
注:本文中的pixClipRectangle函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论