Ejemplo n.º 1
0
        // jp2kiostub.c (71, 6)
        // pixWriteStreamJp2k(fp, pix, quality, nlevels, hint, debug) as int
        // pixWriteStreamJp2k(FILE *, PIX *, l_int32, l_int32, l_int32, l_int32) as l_ok
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixWriteStreamJp2k/*"/>
        ///   <returns></returns>
        public static int pixWriteStreamJp2k(
            FILE fp,
            Pix pix,
            int quality,
            int nlevels,
            int hint,
            Enumerations.DebugOnOff debug)
        {
            if (fp == null)
            {
                throw new ArgumentNullException("fp cannot be Nothing");
            }

            if (pix == null)
            {
                throw new ArgumentNullException("pix cannot be Nothing");
            }

            IntPtr fpPtr = IntPtr.Zero; if (fp != null)
            {
                fpPtr = fp.Pointer;
            }
            IntPtr pixPtr = IntPtr.Zero; if (pix != null)
            {
                pixPtr = pix.Pointer;
            }
            int _Result = Natives.pixWriteStreamJp2k(fp.Pointer, pix.Pointer, quality, nlevels, hint, (int)debug);

            return(_Result);
        }
Ejemplo n.º 2
0
        // recogtrain.c (1488, 1)
        // recogTrainFromBoot(recogboot, pixas, minscore, threshold, debug) as Pixa
        // recogTrainFromBoot(L_RECOG *, PIXA *, l_float32, l_int32, l_int32) as PIXA *
        ///  <summary>
        /// (1) This takes %pixas of unscaled single characters and %recboot,
        /// a bootstrep recognizer (BSR) that has been set up with parameters
        /// scaleh: scale all templates to this height
        /// linew: width of normalized strokes, or 0 if using
        /// the input image
        /// It modifies the pix in %pixas accordingly and correlates
        /// with the templates in the BSR.  It returns those input
        /// images in %pixas whose best correlation with the BSR is at
        /// or above %minscore.  The returned pix have added text labels
        /// for the text string of the class to which the best
        /// correlated template belongs.<para/>
        ///
        /// (2) Identification occurs in scaled mode (typically with h = 40),
        /// optionally using a width-normalized line images derived
        /// from those in %pixas.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogTrainFromBoot/*"/>
        ///  <param name="recogboot">[in] - labeled boot recognizer</param>
        ///  <param name="pixas">[in] - set of unlabeled input characters</param>
        ///  <param name="minscore">[in] - min score for accepting the example e.g., 0.75</param>
        ///  <param name="threshold">[in] - for binarization, if needed</param>
        ///  <param name="debug">[in] - 1 for debug output saved to recogboot 0 otherwise</param>
        ///   <returns>pixad   labeled version of input pixas, trained on a BSR, or NULL on error</returns>
        public static Pixa recogTrainFromBoot(
            L_Recog recogboot,
            Pixa pixas,
            Single minscore,
            int threshold,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (recogboot == null)
            {
                throw new ArgumentNullException("recogboot cannot be Nothing");
            }

            if (pixas == null)
            {
                throw new ArgumentNullException("pixas cannot be Nothing");
            }

            IntPtr _Result = Natives.recogTrainFromBoot(recogboot.Pointer, pixas.Pointer, minscore, threshold, (int)debug);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Pixa(_Result));
        }
Ejemplo n.º 3
0
        // jp2kiostub.c (63, 6)
        // pixWriteJp2k(filename, pix, quality, nlevels, hint, debug) as int
        // pixWriteJp2k(const char *, PIX *, l_int32, l_int32, l_int32, l_int32) as l_ok
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixWriteJp2k/*"/>
        ///   <returns></returns>
        public static int pixWriteJp2k(
            String filename,
            Pix pix,
            int quality,
            int nlevels,
            int hint,
            Enumerations.DebugOnOff debug)
        {
            if (filename == null)
            {
                throw new ArgumentNullException("filename cannot be Nothing");
            }

            if (pix == null)
            {
                throw new ArgumentNullException("pix cannot be Nothing");
            }

            IntPtr pixPtr = IntPtr.Zero; if (pix != null)
            {
                pixPtr = pix.Pointer;
            }
            int _Result = Natives.pixWriteJp2k(filename, pix.Pointer, quality, nlevels, hint, (int)debug);

            return(_Result);
        }
Ejemplo n.º 4
0
        // recogident.c (401, 1)
        // recogCorrelationBestRow(recog, pixs, pboxa, pnascore, pnaindex, psachar, debug) as int
        // recogCorrelationBestRow(L_RECOG *, PIX *, BOXA **, NUMA **, NUMA **, SARRAY **, l_int32) as l_ok
        ///  <summary>
        /// (1) Supervises character matching for (in general) a c.c with
        /// multiple touching characters.  Finds the best match greedily.
        /// Rejects small parts that are left over after splitting.<para/>
        ///
        /// (2) Matching is to the average, and without character scaling.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogCorrelationBestRow/*"/>
        ///  <param name="recog">[in] - with LUT's pre-computed</param>
        ///  <param name="pixs">[in] - typically of multiple touching characters, 1 bpp</param>
        ///  <param name="pboxa">[out] - bounding boxs of best fit character</param>
        ///  <param name="pnascore">[out][optional] - correlation scores</param>
        ///  <param name="pnaindex">[out][optional] - indices of classes</param>
        ///  <param name="psachar">[out][optional] - array of character strings</param>
        ///  <param name="debug">[in] - 1 for results written to pixadb_split</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogCorrelationBestRow(
            L_Recog recog,
            Pix pixs,
            out Boxa pboxa,
            out Numa pnascore,
            out Numa pnaindex,
            out Sarray psachar,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr pboxaPtr    = IntPtr.Zero;
            IntPtr pnascorePtr = IntPtr.Zero;
            IntPtr pnaindexPtr = IntPtr.Zero;
            IntPtr psacharPtr  = IntPtr.Zero;
            int    _Result     = Natives.recogCorrelationBestRow(recog.Pointer, pixs.Pointer, out pboxaPtr, out pnascorePtr, out pnaindexPtr, out psacharPtr, (int)debug);

            if (pboxaPtr == IntPtr.Zero)
            {
                pboxa = null;
            }
            else
            {
                pboxa = new Boxa(pboxaPtr);
            };
            if (pnascorePtr == IntPtr.Zero)
            {
                pnascore = null;
            }
            else
            {
                pnascore = new Numa(pnascorePtr);
            };
            if (pnaindexPtr == IntPtr.Zero)
            {
                pnaindex = null;
            }
            else
            {
                pnaindex = new Numa(pnaindexPtr);
            };
            if (psacharPtr == IntPtr.Zero)
            {
                psachar = null;
            }
            else
            {
                psachar = new Sarray(psacharPtr);
            };

            return(_Result);
        }
Ejemplo n.º 5
0
        // recogtrain.c (212, 1)
        // recogTrainLabeled(recog, pixs, box, text, debug) as int
        // recogTrainLabeled(L_RECOG *, PIX *, BOX *, char *, l_int32) as l_ok
        ///  <summary>
        /// (1) Training is restricted to the addition of a single
        /// character in an arbitrary (e.g., UTF8) charset<para/>
        ///
        /// (2) If box != null, it should represent the location in %pixs
        /// of the character image.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogTrainLabeled/*"/>
        ///  <param name="recog">[in] - in training mode</param>
        ///  <param name="pixs">[in] - if depth  is greater  1, will be thresholded to 1 bpp</param>
        ///  <param name="box">[in][optional] - cropping box</param>
        ///  <param name="text">[in][optional] - if null, use text field in pix</param>
        ///  <param name="debug">[in] - 1 to display images of samples not captured</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogTrainLabeled(
            L_Recog recog,
            Pix pixs,
            Box box     = null,
            String text = "",
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr boxPtr = IntPtr.Zero;    if (box != null)
            {
                boxPtr = box.Pointer;
            }
            int _Result = Natives.recogTrainLabeled(recog.Pointer, pixs.Pointer, boxPtr, text, (int)debug);

            return(_Result);
        }
Ejemplo n.º 6
0
        // jp2kiostub.c (87, 6)
        // pixWriteMemJp2k(pdata, psize, pix, quality, nlevels, hint, debug) as int
        // pixWriteMemJp2k(l_uint8 **, size_t *, PIX *, l_int32, l_int32, l_int32, l_int32) as l_ok
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixWriteMemJp2k/*"/>
        ///   <returns></returns>
        public static int pixWriteMemJp2k(
            object pdata,
            object psize,
            Pix pix,
            int quality,
            int nlevels,
            int hint,
            Enumerations.DebugOnOff debug)
        {
            if (pdata == null)
            {
                throw new ArgumentNullException("pdata cannot be Nothing");
            }

            if (psize == null)
            {
                throw new ArgumentNullException("psize cannot be Nothing");
            }

            if (pix == null)
            {
                throw new ArgumentNullException("pix cannot be Nothing");
            }

            IntPtr pixPtr = IntPtr.Zero; if (pix != null)
            {
                pixPtr = pix.Pointer;
            }
            int _Result = Natives.pixWriteMemJp2k(pdata, psize, pix.Pointer, quality, nlevels, hint, (int)debug);

            return(_Result);
        }
Ejemplo n.º 7
0
        // recogtrain.c (1911, 1)
        // recogMakeBootDigitTemplates(debug) as Pixa
        // recogMakeBootDigitTemplates(l_int32) as PIXA *
        ///  <summary>
        /// (1) See recogMakeBootDigitRecog().
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogMakeBootDigitTemplates/*"/>
        ///  <param name="debug">[in] - 1 for display of templates</param>
        ///   <returns>pixa   of templates or NULL on error</returns>
        public static Pixa recogMakeBootDigitTemplates(
            Enumerations.DebugOnOff debug)
        {
            IntPtr _Result = Natives.recogMakeBootDigitTemplates((int)debug);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Pixa(_Result));
        }
Ejemplo n.º 8
0
        // flipdetect.c (431, 1)
        // makeOrientDecision(upconf, leftconf, minupconf, minratio, porient, debug) as int
        // makeOrientDecision(l_float32, l_float32, l_float32, l_float32, l_int32 *, l_int32) as l_ok
        ///  <summary>
        /// (1) This can be run after pixOrientDetect()<para/>
        ///
        /// (2) Both upconf and leftconf must be nonzero otherwise the
        /// orientation cannot be determined.<para/>
        ///
        /// (3) The abs values of the input confidences are compared to
        /// minupconf.<para/>
        ///
        /// (4) The abs value of the largest of (upconf/leftconf) and
        /// (leftconf/upconf) is compared with minratio.<para/>
        ///
        /// (5) Input 0.0 for the default values for minupconf and minratio.<para/>
        ///
        /// (6) The return value of orient is interpreted thus:
        /// L_TEXT_ORIENT_UNKNOWN:  not enough evidence to determine
        /// L_TEXT_ORIENT_UP: text rightside-up
        /// L_TEXT_ORIENT_LEFT: landscape, text up facing left
        /// L_TEXT_ORIENT_DOWN: text upside-down
        /// L_TEXT_ORIENT_RIGHT:  landscape, text up facing right
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/makeOrientDecision/*"/>
        ///  <param name="upconf">[in] - nonzero</param>
        ///  <param name="leftconf">[in] - nonzero</param>
        ///  <param name="minupconf">[in] - minimum value for which a decision can be made</param>
        ///  <param name="minratio">[in] - minimum conf ratio required for a decision</param>
        ///  <param name="porient">[out] - text orientation enum {0,1,2,3,4}</param>
        ///  <param name="debug">[in] - 1 for debug output 0 otherwise</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int makeOrientDecision(
            Single upconf,
            Single leftconf,
            Single minupconf,
            Single minratio,
            out int porient,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            int _Result = Natives.makeOrientDecision(upconf, leftconf, minupconf, minratio, out porient, (int)debug);

            return(_Result);
        }
Ejemplo n.º 9
0
        // ccthin.c (341, 1)
        // selaMakeThinSets(index, debug) as Sela
        // selaMakeThinSets(l_int32, l_int32) as SELA *
        ///  <summary>
        /// (1) These are specific sets of HMTs to be used in parallel for
        /// for thinning from each of four directions.<para/>
        ///
        /// (2) The sets are indexed as follows:
        /// For thinning (e.g., run to completion):
        /// index = 1 sel_4_1, sel_4_2, sel_4_3
        /// index = 2 sel_4_1, sel_4_5, sel_4_6
        /// index = 3 sel_4_1, sel_4_7, sel_4_7_rot
        /// index = 4 sel_48_1, sel_48_1_rot, sel_48_2
        /// index = 5 sel_8_2, sel_8_3, sel_8_5, sel_8_6
        /// index = 6 sel_8_2, sel_8_3, sel_48_2
        /// index = 7 sel_8_1, sel_8_5, sel_8_6
        /// index = 8 sel_8_2, sel_8_3, sel_8_8, sel_8_9
        /// index = 9 sel_8_5, sel_8_6, sel_8_7, sel_8_7_rot
        /// For thickening (e.g., just a few iterations):
        /// index = 10  sel_4_2, sel_4_3
        /// index = 11  sel_8_4<para/>
        ///
        /// (3) For a very smooth skeleton, use set 1 for 4 connected and
        /// set 5 for 8 connected thins.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/selaMakeThinSets/*"/>
        ///  <param name="index">[in] - into specific sets</param>
        ///  <param name="debug">[in] - 1 to output display of sela</param>
        ///   <returns>sela, or NULL on error</returns>
        public static Sela selaMakeThinSets(
            int index,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            IntPtr _Result = Natives.selaMakeThinSets(index, (int)debug);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Sela(_Result));
        }
Ejemplo n.º 10
0
        // recogtrain.c (2045, 1)
        // recogDebugAverages(precog, debug) as int
        // recogDebugAverages(L_RECOG **, l_int32) as l_ok
        ///  <summary>
        /// (1) Generates an image that pairs each of the input images used
        /// in training with the average template that it is best
        /// correlated to.  This is written into the recog.<para/>
        ///
        /// (2) It also generates pixa_tr of all the input training images,
        /// which can be used, e.g., in recogShowMatchesInRange().<para/>
        ///
        /// (3) Destroys the recog if the averaging function finds any bad classes.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogDebugAverages/*"/>
        ///  <param name="precog">[in] - addr of recog</param>
        ///  <param name="debug">[in] - 0 no output 1 for images 2 for text 3 for both</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogDebugAverages(
            List <L_Recog> precog,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (precog == null)
            {
                throw new ArgumentNullException("precog cannot be Nothing");
            }

            IntPtr precogPtr = IntPtr.Zero;
            int    _Result   = Natives.recogDebugAverages(precogPtr, (int)debug);

            return(_Result);
        }
Ejemplo n.º 11
0
        // dewarp4.c (447, 1)
        // dewarpaInsertRefModels(dewa, notests, debug) as int
        // dewarpaInsertRefModels(L_DEWARPA *, l_int32, l_int32) as l_ok
        ///  <summary>
        /// (1) This destroys all dewarp models that are invalid, and then
        /// inserts reference models where possible.<para/>
        ///
        /// (2) If %notests == 1, this ignores the curvature constraints
        /// and assumes that all successfully built models are valid.<para/>
        ///
        /// (3) If useboth == 0, it uses the closest valid model within the
        /// distance and parity constraints.  If useboth == 1, it tries
        /// to use the closest allowed hvalid model if it doesn't find
        /// an hvalid model, it uses the closest valid model.<para/>
        ///
        /// (4) For all pages without a model, this clears out any existing
        /// invalid and reference dewarps, finds the nearest valid model
        /// with the same parity, and inserts an empty dewarp with the
        /// reference page.<para/>
        ///
        /// (5) Then if it is requested to use both vertical and horizontal
        /// disparity arrays (useboth == 1), it tries to replace any
        /// hvalid == 0 model or reference with an hvalid == 1 reference.<para/>
        ///
        /// (6) The distance constraint is that any reference model must
        /// be within maxdist.  Note that with the parity constraint,
        /// no reference models will be used if maxdist  is smaller 2.<para/>
        ///
        /// (7) This function must be called, even if reference models will
        /// not be used.  It should be called after building models on all
        /// available pages, and after setting the rendering parameters.<para/>
        ///
        /// (8) If the dewa has been serialized, this function is called by
        /// dewarpaRead() when it is read back.  It is also called
        /// any time the rendering parameters are changed.<para/>
        ///
        /// (9) Note: if this has been called with useboth == 1, and useboth
        /// is reset to 0, you should first call dewarpaRestoreModels()
        /// to bring real models from the cache back to the primary array.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaInsertRefModels/*"/>
        ///  <param name="dewa">[in] - </param>
        ///  <param name="notests">[in] - if 1, ignore curvature constraints on model</param>
        ///  <param name="debug">[in] - 1 to output information on invalid page models</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int dewarpaInsertRefModels(
            L_Dewarpa dewa,
            int notests,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

            int _Result = Natives.dewarpaInsertRefModels(dewa.Pointer, notests, (int)debug);

            return(_Result);
        }
Ejemplo n.º 12
0
        // recogtrain.c (1876, 1)
        // recogMakeBootDigitRecog(scaleh, linew, maxyshift, debug) as L_Recog
        // recogMakeBootDigitRecog(l_int32, l_int32, l_int32, l_int32) as L_RECOG *
        ///  <summary>
        /// (1) This takes a set of pre-computed, labeled pixa of single
        /// digits, and generates a recognizer where the character templates
        /// that will be used are derived from the boot-generated pixa:
        /// - extending by replicating the set with different widths,
        /// keeping the height the same
        /// - scaling (isotropically to fixed height)
        /// - optionally generating a skeleton and thickening so that
        /// all strokes have the same width.<para/>
        ///
        /// (2) The resulting templates are scaled versions of either the
        /// input bitmaps or images with fixed line widths.  To use the
        /// input bitmaps, set %linew = 0 otherwise, set %linew to the
        /// desired line width.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogMakeBootDigitRecog/*"/>
        ///  <param name="scaleh">[in] - scale all heights to this typ. use 40</param>
        ///  <param name="linew">[in] - normalized line width typ. use 5 0 to skip</param>
        ///  <param name="maxyshift">[in] - from nominal centroid alignment typically 0 or 1</param>
        ///  <param name="debug">[in] - 1 for showing templates 0 otherwise</param>
        ///   <returns>recog, or NULL on error</returns>
        public static L_Recog recogMakeBootDigitRecog(
            int scaleh,
            int linew,
            int maxyshift,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            IntPtr _Result = Natives.recogMakeBootDigitRecog(scaleh, linew, maxyshift, (int)debug);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new L_Recog(_Result));
        }
Ejemplo n.º 13
0
        // flipdetect.c (1025, 1)
        // pixMirrorDetectDwa(pixs, pconf, mincount, debug) as int
        // pixMirrorDetectDwa(PIX *, l_float32 *, l_int32, l_int32) as l_ok
        ///  <summary>
        /// (1) We assume the text is horizontally oriented, with
        /// ascenders going up.<para/>
        ///
        /// (2) See notes in pixMirrorDetect().
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixMirrorDetectDwa/*"/>
        ///  <param name="pixs">[in] - 1 bpp, deskewed, English text</param>
        ///  <param name="pconf">[out] - confidence that text is not LR mirror reversed</param>
        ///  <param name="mincount">[in] - min number of left + right use 0 for default</param>
        ///  <param name="debug">[in] - 1 for debug output 0 otherwise</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int pixMirrorDetectDwa(
            Pix pixs,
            out Single pconf,
            int mincount,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            int _Result = Natives.pixMirrorDetectDwa(pixs.Pointer, out pconf, mincount, (int)debug);

            return(_Result);
        }
Ejemplo n.º 14
0
        // baseline.c (506, 1)
        // pixGetLocalSkewAngles(pixs, nslices, redsweep, redsearch, sweeprange, sweepdelta, minbsdelta, pa, pb, debug) as Numa
        // pixGetLocalSkewAngles(PIX *, l_int32, l_int32, l_int32, l_float32, l_float32, l_float32, l_float32 *, l_float32 *, l_int32) as NUMA *
        ///  <summary>
        /// (1) The local skew is measured in a set of overlapping strips.
        /// We then do a least square linear fit parameters to get
        /// the slope and intercept parameters a and b in
        /// skew-angle = a  y + b  (degrees)
        /// for the local skew as a function of raster line y.
        /// This is then used to make naskew, which can be interpreted
        /// as the computed skew angle (in degrees) at the left edge
        /// of each raster line.<para/>
        ///
        /// (2) naskew can then be used to find the baselines of text, because
        /// each text line has a baseline that should intersect
        /// the left edge of the image with the angle given by this
        /// array, evaluated at the raster line of intersection.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixGetLocalSkewAngles/*"/>
        ///  <param name="pixs">[in] - 1 bpp</param>
        ///  <param name="nslices">[in] - the number of horizontal overlapping slices must be larger than 1 and not exceed 20 0 for default</param>
        ///  <param name="redsweep">[in] - sweep reduction factor: 1, 2, 4 or 8 use 0 for default value</param>
        ///  <param name="redsearch">[in] - search reduction factor: 1, 2, 4 or 8, and not larger than redsweep use 0 for default value</param>
        ///  <param name="sweeprange">[in] - half the full range, assumed about 0 in degrees use 0.0 for default value</param>
        ///  <param name="sweepdelta">[in] - angle increment of sweep in degrees use 0.0 for default value</param>
        ///  <param name="minbsdelta">[in] - min binary search increment angle in degrees use 0.0 for default value</param>
        ///  <param name="pa">[out][optional] - slope of skew as fctn of y</param>
        ///  <param name="pb">[out][optional] - intercept at y=0 of skew as fctn of y</param>
        ///  <param name="debug">[in] - 1 for generating plot of skew angle vs. y 0 otherwise</param>
        ///   <returns>naskew, or NULL on error</returns>
        public static Numa pixGetLocalSkewAngles(
            Pix pixs,
            int nslices,
            int redsweep,
            int redsearch,
            Single sweeprange,
            Single sweepdelta,
            Single minbsdelta,
            out Single pa,
            out Single pb,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            if ((new List <int> {
                1
            }).Contains((int)pixs.d) == false)
            {
                throw new ArgumentException("1 bpp");
            }

            if ((new List <int> {
                0, 1, 2, 4, 8
            }).Contains((int)redsweep) == false)
            {
                throw new ArgumentException("sweep reduction factor: 1, 2, 4 or 8 use 0 for default value");
            }
            ;

            if ((new List <int> {
                0, 1, 2, 4, 8
            }).Contains((int)redsearch) == false)
            {
                throw new ArgumentException("search reduction factor: 1, 2, 4 or 8, and not larger than redsweep use 0 for default value");
            }
            ;
            IntPtr _Result = Natives.pixGetLocalSkewAngles(pixs.Pointer, nslices, redsweep, redsearch, sweeprange, sweepdelta, minbsdelta, out pa, out pb, (int)debug);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Numa(_Result));
        }
Ejemplo n.º 15
0
        // colorcontent.c (1145, 1)
        // pixColorsForQuantization(pixs, thresh, pncolors, piscolor, debug) as int
        // pixColorsForQuantization(PIX *, l_int32, l_int32 *, l_int32 *, l_int32) as l_ok
        ///  <summary>
        /// (1) This function finds a measure of the number of colors that are
        /// found in low-gradient regions of an image.  By its
        /// magnitude relative to some threshold (not specified in
        /// this function), it gives a good indication of whether
        /// quantization will generate posterization. This number
        /// is larger for images with regions of slowly varying
        /// intensity (if 8 bpp) or color (if rgb). Such images, if
        /// quantized, may require dithering to avoid posterization,
        /// and lossless compression is then expected to be poor.<para/>
        ///
        /// (2) If pixs has a colormap, the number of colors returned is
        /// the number in the colormap.<para/>
        ///
        /// (3) It is recommended that document images be reduced to a width
        /// of 800 pixels before applying this function.  Then it can
        /// be expected that color detection will be fairly accurate
        /// and the number of colors will reflect both the content and
        /// the type of compression to be used.  For less than 15 colors,
        /// there is unlikely to be a halftone image, and lossless
        /// quantization should give both a good visual result and
        /// better compression.<para/>
        ///
        /// (4) When using the default threshold on the gradient (15),
        /// images (both gray and rgb) where ncolors is greater than
        /// about 15 will compress poorly with either lossless
        /// compression or dithered quantization, and they may be
        /// posterized with non-dithered quantization.<para/>
        ///
        /// (5) For grayscale images, or images without significant color,
        /// this returns the number of significant gray levels in
        /// the low-gradient regions.  The actual number of gray levels
        /// can be large due to jpeg compression noise in the background.<para/>
        ///
        /// (6) Similarly, for color images, the actual number of different
        /// (r,g,b) colors in the low-gradient regions (rather than the
        /// number of occupied level 4 octcubes) can be quite large, e.g.,
        /// due to jpeg compression noise, even for regions that appear
        /// to be of a single color.  By quantizing to level 4 octcubes,
        /// most of these superfluous colors are removed from the counting.<para/>
        ///
        /// (7) The image is tested for color.  If there is very little color,
        /// it is thresholded to gray and the number of gray levels in
        /// the low gradient regions is found.  If the image has color,
        /// the number of occupied level 4 octcubes is found.<para/>
        ///
        /// (8) The number of colors in the low-gradient regions increases
        /// monotonically with the threshold %thresh on the edge gradient.<para/>
        ///
        /// (9) Background: grayscale and color quantization is often useful
        /// to achieve highly compressed images with little visible
        /// distortion.  However, gray or color washes (regions of
        /// low gradient) can defeat this approach to high compression.
        /// How can one determine if an image is expected to compress
        /// well using gray or color quantization?  We use the fact that
        /// gray washes, when quantized with less than 50 intensities,
        /// have posterization (visible boundaries between regions
        /// of uniform 'color') and poor lossless compression
        /// color washes, when quantized with level 4 octcubes,
        /// typically result in both posterization and the occupancy
        /// of many level 4 octcubes.
        /// Images can have colors either intrinsically or as jpeg
        /// compression artifacts.  This function reduces but does not
        /// completely eliminate measurement of jpeg quantization noise
        /// in the white background of grayscale or color images.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixColorsForQuantization/*"/>
        ///  <param name="pixs">[in] - 8 bpp gray or 32 bpp rgb with or without colormap</param>
        ///  <param name="thresh">[in] - binary threshold on edge gradient 0 for default</param>
        ///  <param name="pncolors">[out] - the number of colors found</param>
        ///  <param name="piscolor">[out][optional] - 1 if significant color is found 0 otherwise.  If pixs is 8 bpp, and does not have a colormap with color entries, this is 0</param>
        ///  <param name="debug">[in] - 1 to output masked image that is tested for colors 0 otherwise</param>
        ///   <returns>0 if OK, 1 on error.</returns>
        public static int pixColorsForQuantization(
            Pix pixs,
            int thresh,
            out int pncolors,
            out int piscolor,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            int _Result = Natives.pixColorsForQuantization(pixs.Pointer, thresh, out pncolors, out piscolor, (int)debug);

            return(_Result);
        }
Ejemplo n.º 16
0
        // recogtrain.c (352, 1)
        // recogAddSample(recog, pix, debug) as int
        // recogAddSample(L_RECOG *, PIX *, l_int32) as l_ok
        ///  <summary>
        /// (1) The pix is 1 bpp, with the character string label embedded.<para/>
        ///
        /// (2) The pixaa_u array of the recog is initialized to accept
        /// up to 256 different classes.  When training is finished,
        /// the arrays are truncated to the actual number of classes.
        /// To pad an existing recog from the boot recognizers, training
        /// is started again if samples from a new class are added,
        /// the pixaa_u array is extended by adding a pixa to hold them.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogAddSample/*"/>
        ///  <param name="recog">[in] - </param>
        ///  <param name="pix">[in] - a single character, 1 bpp</param>
        ///  <param name="debug">[in] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int recogAddSample(
            L_Recog recog,
            Pix pix,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pix == null)
            {
                throw new ArgumentNullException("pix cannot be Nothing");
            }

            int _Result = Natives.recogAddSample(recog.Pointer, pix.Pointer, (int)debug);

            return(_Result);
        }
Ejemplo n.º 17
0
        // dewarp4.c (223, 1)
        // dewarpSinglePageRun(pixs, pixb, dewa, ppixd, debug) as int
        // dewarpSinglePageRun(PIX *, PIX *, L_DEWARPA *, PIX **, l_int32) as l_ok
        ///  <summary>
        /// (1) Dewarps pixs and returns the result in [and]pixd.<para/>
        ///
        /// (2) The 1 bpp version %pixb and %dewa are conveniently generated by
        /// dewarpSinglePageInit().<para/>
        ///
        /// (3) Non-default model parameters must be set before calling this.<para/>
        ///
        /// (4) If a model cannot be built, this returns a copy of pixs in [and]pixd.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpSinglePageRun/*"/>
        ///  <param name="pixs">[in] - any depth</param>
        ///  <param name="pixb">[in] - 1 bpp</param>
        ///  <param name="dewa">[in] - initialized</param>
        ///  <param name="ppixd">[out] - dewarped result</param>
        ///  <param name="debug">[in] - 1 for debugging output, 0 otherwise</param>
        ///   <returns>0 if OK, 1 on error list of page numbers, or NULL on error</returns>
        public static int dewarpSinglePageRun(
            Pix pixs,
            Pix pixb,
            L_Dewarpa dewa,
            out Pix ppixd,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            if (pixb == null)
            {
                throw new ArgumentNullException("pixb cannot be Nothing");
            }

            if (dewa == null)
            {
                throw new ArgumentNullException("dewa cannot be Nothing");
            }

            if ((new List <int> {
                1
            }).Contains((int)pixb.d) == false)
            {
                throw new ArgumentException("1 bpp");
            }
            IntPtr ppixdPtr = IntPtr.Zero;
            int    _Result  = Natives.dewarpSinglePageRun(pixs.Pointer, pixb.Pointer, dewa.Pointer, out ppixdPtr, (int)debug);

            if (ppixdPtr == IntPtr.Zero)
            {
                ppixd = null;
            }
            else
            {
                ppixd = new Pix(ppixdPtr);
            };

            return(_Result);
        }
Ejemplo n.º 18
0
        // recogident.c (246, 1)
        // recogSplitIntoCharacters(recog, pixs, minh, skipsplit, pboxa, ppixa, debug) as int
        // recogSplitIntoCharacters(L_RECOG *, PIX *, l_int32, l_int32, BOXA **, PIXA **, l_int32) as l_ok
        ///  <summary>
        /// (1) This can be given an image that has an arbitrary number
        /// of text characters.  It optionally splits connected
        /// components based on document image decoding in recogDecode().
        /// The returned pixa includes the boxes from which the
        /// (possibly split) components are extracted.<para/>
        ///
        /// (2) After noise filtering, the resulting components are put in
        /// row-major (2D) order, and the smaller of overlapping
        /// components are removed if they satisfy conditions of
        /// relative size and fractional overlap.<para/>
        ///
        /// (3) Note that the splitting function uses unscaled templates
        /// and does not bother returning the class results and scores.
        /// These are more accurately found later using the scaled templates.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogSplitIntoCharacters/*"/>
        ///  <param name="recog">[in] - </param>
        ///  <param name="pixs">[in] - 1 bpp, contains only mostly deskewed text</param>
        ///  <param name="minh">[in] - remove shorter components use 0 for default</param>
        ///  <param name="skipsplit">[in] - 1 to skip the splitting step</param>
        ///  <param name="pboxa">[out] - character bounding boxes</param>
        ///  <param name="ppixa">[out] - character images</param>
        ///  <param name="debug">[in] - 1 for results written to pixadb_split</param>
        ///   <returns>0 if OK, 1 on error or if no components are returned</returns>
        public static int recogSplitIntoCharacters(
            L_Recog recog,
            Pix pixs,
            int minh,
            int skipsplit,
            out Boxa pboxa,
            out Pixa ppixa,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (recog == null)
            {
                throw new ArgumentNullException("recog cannot be Nothing");
            }

            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr pboxaPtr = IntPtr.Zero;
            IntPtr ppixaPtr = IntPtr.Zero;
            int    _Result  = Natives.recogSplitIntoCharacters(recog.Pointer, pixs.Pointer, minh, skipsplit, out pboxaPtr, out ppixaPtr, (int)debug);

            if (pboxaPtr == IntPtr.Zero)
            {
                pboxa = null;
            }
            else
            {
                pboxa = new Boxa(pboxaPtr);
            };
            if (ppixaPtr == IntPtr.Zero)
            {
                ppixa = null;
            }
            else
            {
                ppixa = new Pixa(ppixaPtr);
            };

            return(_Result);
        }
Ejemplo n.º 19
0
        // strokes.c (208, 1)
        // pixaFindStrokeWidth(pixa, thresh, tab8, debug) as Numa
        // pixaFindStrokeWidth(PIXA *, l_float32, l_int32 *, l_int32) as NUMA *
        ///  <summary>
        /// (1) See pixFindStrokeWidth() for details.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixaFindStrokeWidth/*"/>
        ///  <param name="pixa">[in] - of 1 bpp images</param>
        ///  <param name="thresh">[in] - fractional count threshold relative to distance 1</param>
        ///  <param name="tab8">[in][optional] - table for counting fg pixels can be NULL</param>
        ///  <param name="debug">[in] - 1 for debug output 0 to skip</param>
        ///   <returns>na  array of stroke widths for each pix in %pixa NULL on error</returns>
        public static Numa pixaFindStrokeWidth(
            Pixa pixa,
            Single thresh,
            int[] tab8 = null,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (pixa == null)
            {
                throw new ArgumentNullException("pixa cannot be Nothing");
            }

            IntPtr _Result = Natives.pixaFindStrokeWidth(pixa.Pointer, thresh, tab8, (int)debug);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Numa(_Result));
        }
Ejemplo n.º 20
0
        // jp2kiostub.c (47, 7)
        // pixReadJp2k(filename, reduction, box, hint, debug) as Pix
        // pixReadJp2k(const char *, l_uint32, BOX *, l_int32, l_int32) as PIX *
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixReadJp2k/*"/>
        ///   <returns></returns>
        public static Pix pixReadJp2k(
            String filename,
            uint reduction,
            Box box,
            int hint,
            Enumerations.DebugOnOff debug)
        {
            if (filename == null)
            {
                throw new ArgumentNullException("filename cannot be Nothing");
            }

            if (box == null)
            {
                throw new ArgumentNullException("box cannot be Nothing");
            }

            if (File.Exists(filename) == false)
            {
                throw new ArgumentException("File is missing");
            }
            ;

            if (reduction < 2 || reduction > 16)
            {
                throw new ArgumentException("");
            }

            IntPtr boxPtr = IntPtr.Zero; if (box != null)
            {
                boxPtr = box.Pointer;
            }
            IntPtr _Result = Natives.pixReadJp2k(filename, reduction, box.Pointer, hint, (int)debug);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Pix(_Result));
        }
Ejemplo n.º 21
0
        // recogtrain.c (486, 1)
        // recogAverageSamples(precog, debug) as int
        // recogAverageSamples(L_RECOG **, l_int32) as l_int32
        ///  <summary>
        /// (1) This is only called in two situations:
        /// (a) When splitting characters using either the DID method
        /// recogDecode() or the the greedy splitter
        /// recogCorrelationBestRow()
        /// (b) By a special recognizer that is used to remove outliers.
        /// Both unscaled and scaled inputs are averaged.<para/>
        ///
        /// (2) If the data in any class is nonexistent (no samples), or
        /// very bad (no fg pixels in the average), or if the ratio
        /// of max/min average unscaled class template heights is
        /// greater than max_ht_ratio, this destroys the recog.
        /// The caller must check the return value of the recog.<para/>
        ///
        /// (3) Set debug = 1 to view the resulting templates and their centroids.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogAverageSamples/*"/>
        ///  <param name="precog">[in] - addr of existing recog may be destroyed</param>
        ///  <param name="debug">[in] - </param>
        ///   <returns>0 on success, 1 on failure</returns>
        public static int recogAverageSamples(
            ref L_Recog precog,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            IntPtr precogPtr = IntPtr.Zero;         if (precog != null)
            {
                precogPtr = precog.Pointer;
            }
            int _Result = Natives.recogAverageSamples(ref precogPtr, (int)debug);

            if (precogPtr == IntPtr.Zero)
            {
                precog = null;
            }
            else
            {
                precog = new L_Recog(precogPtr);
            };

            return(_Result);
        }
Ejemplo n.º 22
0
        // jp2kiostub.c (55, 7)
        // pixReadStreamJp2k(fp, reduction, box, hint, debug) as Pix
        // pixReadStreamJp2k(FILE *, l_uint32, BOX *, l_int32, l_int32) as PIX *
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixReadStreamJp2k/*"/>
        ///   <returns></returns>
        public static Pix pixReadStreamJp2k(
            FILE fp,
            uint reduction,
            Box box,
            int hint,
            Enumerations.DebugOnOff debug)
        {
            if (fp == null)
            {
                throw new ArgumentNullException("fp cannot be Nothing");
            }

            if (box == null)
            {
                throw new ArgumentNullException("box cannot be Nothing");
            }

            if (reduction < 2 || reduction > 16)
            {
                throw new ArgumentException("");
            }

            IntPtr fpPtr = IntPtr.Zero; if (fp != null)
            {
                fpPtr = fp.Pointer;
            }
            IntPtr boxPtr = IntPtr.Zero; if (box != null)
            {
                boxPtr = box.Pointer;
            }
            IntPtr _Result = Natives.pixReadStreamJp2k(fp.Pointer, reduction, box.Pointer, hint, (int)debug);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Pix(_Result));
        }
Ejemplo n.º 23
0
        // pixlabel.c (351, 1)
        // pixConnCompIncrAdd(pixs, ptaa, pncc, x, y, debug) as int
        // pixConnCompIncrAdd(PIX *, PTAA *, l_int32 *, l_float32, l_float32, l_int32) as l_int32
        ///  <summary>
        /// (1) This adds a pixel and updates the labeled connected components.
        /// Before calling this function, initialize the process using
        /// pixConnCompIncrInit().<para/>
        ///
        /// (2) As a result of adding a pixel, one of the following can happen,
        /// depending on the number of neighbors with non-zero value:
        /// (a) nothing: the pixel is already a member of a c.c.
        /// (b) no neighbors: a new component is added, increasing the
        /// number of c.c.
        /// (c) one neighbor: the pixel is added to an existing c.c.
        /// (d) more than one neighbor: the added pixel causes joining of
        /// two or more c.c., reducing the number of c.c.  A maximum
        /// of 4 c.c. can be joined.<para/>
        ///
        /// (3) When two c.c. are joined, the pixels in the larger index are
        /// relabeled to those of the smaller in pixs, and their locations
        /// are transferred to the pta with the smaller index in the ptaa.
        /// The pta corresponding to the larger index is then deleted.<para/>
        ///
        /// (4) This is an efficient implementation of a "union-find" operation,
        /// which supports the generation and merging of disjoint sets
        /// of pixels.  This function can be called about 1.3 million times
        /// per second.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixConnCompIncrAdd/*"/>
        ///  <param name="pixs">[in] - 32 bpp, with pixels labeled by c.c.</param>
        ///  <param name="ptaa">[in] - with each pta of pixel locations indexed by c.c.</param>
        ///  <param name="pncc">[out] - number of c.c</param>
        ///  <param name="x">[in] - ,y location of added pixel</param>
        ///  <param name="debug">[in] - 0 for no output otherwise output whenever debug smaller or equal nvals, up to debug == 3</param>
        ///   <returns>-1 if nothing happens 0 if a pixel is added 1 on error</returns>
        public static int pixConnCompIncrAdd(
            Pix pixs,
            Ptaa ptaa,
            out int pncc,
            Single x,
            Single y,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            if (ptaa == null)
            {
                throw new ArgumentNullException("ptaa cannot be Nothing");
            }

            int _Result = Natives.pixConnCompIncrAdd(pixs.Pointer, ptaa.Pointer, out pncc, x, y, (int)debug);

            return(_Result);
        }
Ejemplo n.º 24
0
        // pageseg.c (264, 1)
        // pixGenHalftoneMask(pixs, ppixtext, phtfound, debug) as Pix
        // pixGenHalftoneMask(PIX *, PIX **, l_int32 *, l_int32) as PIX *
        ///  <summary>
        /// Deprecated:
        /// This wrapper avoids an ABI change with tesseract 3.0.4.
        /// It should be removed when we no longer need to support 3.0.4.
        /// The debug parameter is ignored (assumed 0).
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixGenHalftoneMask/*"/>
        ///   <returns></returns>
        public static Pix pixGenHalftoneMask(
            Pix pixs,
            Pix ppixtext,
            object phtfound,
            Enumerations.DebugOnOff debug)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            if (ppixtext == null)
            {
                throw new ArgumentNullException("ppixtext cannot be Nothing");
            }

            if (phtfound == null)
            {
                throw new ArgumentNullException("phtfound cannot be Nothing");
            }

            IntPtr pixsPtr = IntPtr.Zero; if (pixs != null)
            {
                pixsPtr = pixs.Pointer;
            }
            IntPtr ppixtextPtr = IntPtr.Zero;       if (ppixtext != null)
            {
                ppixtextPtr = ppixtext.Pointer;
            }
            IntPtr _Result = Natives.pixGenHalftoneMask(pixs.Pointer, ppixtextPtr, phtfound, (int)debug);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Pix(_Result));
        }
Ejemplo n.º 25
0
        // dewarp4.c (97, 1)
        // dewarpSinglePage(pixs, thresh, adaptive, useboth, check_columns, ppixd, pdewa, debug) as int
        // dewarpSinglePage(PIX *, l_int32, l_int32, l_int32, l_int32, PIX **, L_DEWARPA **, l_int32) as l_ok
        ///  <summary>
        /// (1) Dewarps pixs and returns the result in [and]pixd.<para/>
        ///
        /// (2) This uses default values for all model parameters.<para/>
        ///
        /// (3) If pixs is 1 bpp, the parameters %adaptive and %thresh are ignored.<para/>
        ///
        /// (4) If it can't build a model, returns a copy of pixs in [and]pixd.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpSinglePage/*"/>
        ///  <param name="pixs">[in] - with text, any depth</param>
        ///  <param name="thresh">[in] - for global thresholding to 1 bpp ignored otherwise</param>
        ///  <param name="adaptive">[in] - 1 for adaptive thresholding 0 for global threshold</param>
        ///  <param name="useboth">[in] - 1 for horizontal and vertical 0 for vertical only</param>
        ///  <param name="check_columns">[in] - 1 to skip horizontal if multiple columns 0 otherwise default is to skip</param>
        ///  <param name="ppixd">[out] - dewarped result</param>
        ///  <param name="pdewa">[out][optional] - dewa with single page NULL to skip</param>
        ///  <param name="debug">[in] - 1 for debugging output, 0 otherwise</param>
        ///   <returns>0 if OK, 1 on error list of page numbers, or NULL on error</returns>
        public static int dewarpSinglePage(
            Pix pixs,
            int thresh,
            int adaptive,
            int useboth,
            int check_columns,
            out Pix ppixd,
            out L_Dewarpa pdewa,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr ppixdPtr = IntPtr.Zero;
            IntPtr pdewaPtr = IntPtr.Zero;
            int    _Result  = Natives.dewarpSinglePage(pixs.Pointer, thresh, adaptive, useboth, check_columns, out ppixdPtr, out pdewaPtr, (int)debug);

            if (ppixdPtr == IntPtr.Zero)
            {
                ppixd = null;
            }
            else
            {
                ppixd = new Pix(ppixdPtr);
            };
            if (pdewaPtr == IntPtr.Zero)
            {
                pdewa = null;
            }
            else
            {
                pdewa = new L_Dewarpa(pdewaPtr);
            };

            return(_Result);
        }
Ejemplo n.º 26
0
        // flipdetect.c (242, 1)
        // pixOrientCorrect(pixs, minupconf, minratio, pupconf, pleftconf, protation, debug) as Pix
        // pixOrientCorrect(PIX *, l_float32, l_float32, l_float32 *, l_float32 *, l_int32 *, l_int32) as PIX *
        ///  <summary>
        /// (1) Simple top-level function to detect if Roman text is in
        /// reading orientation, and to rotate the image accordingly if not.<para/>
        ///
        /// (2) Returns a copy if no rotation is needed.<para/>
        ///
        /// (3) See notes for pixOrientDetect() and pixOrientDecision().
        /// Use 0.0 for default values for %minupconf and %minratio<para/>
        ///
        /// (4) Optional output of intermediate confidence results and
        /// the rotation performed on pixs.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixOrientCorrect/*"/>
        ///  <param name="pixs">[in] - 1 bpp, deskewed, English text, 150 - 300 ppi</param>
        ///  <param name="minupconf">[in] - minimum value for which a decision can be made</param>
        ///  <param name="minratio">[in] - minimum conf ratio required for a decision</param>
        ///  <param name="pupconf">[out][optional] - use NULL to skip</param>
        ///  <param name="pleftconf">[out][optional] - use NULL to skip</param>
        ///  <param name="protation">[out][optional] - use NULL to skip</param>
        ///  <param name="debug">[in] - 1 for debug output 0 otherwise</param>
        ///   <returns>pixd  may be rotated by 90, 180 or 270 null on error</returns>
        public static Pix pixOrientCorrect(
            Pix pixs,
            Single minupconf,
            Single minratio,
            out Single pupconf,
            out Single pleftconf,
            out int protation,
            Enumerations.DebugOnOff debug = DebugOnOff.DebugOn)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr _Result = Natives.pixOrientCorrect(pixs.Pointer, minupconf, minratio, out pupconf, out pleftconf, out protation, (int)debug);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Pix(_Result));
        }
Ejemplo n.º 27
0
        // jp2kiostub.c (79, 7)
        // pixReadMemJp2k(data, size, reduction, box, hint, debug) as Pix
        // pixReadMemJp2k(const l_uint8 *, size_t, l_uint32, BOX *, l_int32, l_int32) as PIX *
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixReadMemJp2k/*"/>
        ///   <returns></returns>
        public static Pix pixReadMemJp2k(
            Byte[] data,
            uint size,
            uint reduction,
            Box box,
            int hint,
            Enumerations.DebugOnOff debug)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data cannot be Nothing");
            }

            if (box == null)
            {
                throw new ArgumentNullException("box cannot be Nothing");
            }

            if (reduction < 2 || reduction > 16)
            {
                throw new ArgumentException("");
            }

            IntPtr boxPtr = IntPtr.Zero; if (box != null)
            {
                boxPtr = box.Pointer;
            }
            IntPtr _Result = Natives.pixReadMemJp2k(data, size, reduction, box.Pointer, hint, (int)debug);

            if (_Result == IntPtr.Zero)
            {
                return(null);
            }

            return(new Pix(_Result));
        }