Пример #1
0
        // ptabasic.c (616, 1)
        // ptaGetArrays(pta, pnax, pnay) as int
        // ptaGetArrays(PTA *, NUMA **, NUMA **) as l_ok
        ///  <summary>
        /// (1) This copies the internal arrays into new Numas.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ptaGetArrays/*"/>
        ///  <param name="pta">[in] - </param>
        ///  <param name="pnax">[out][optional] - numa of x array</param>
        ///  <param name="pnay">[out][optional] - numa of y array</param>
        ///   <returns>0 if OK 1 on error or if pta is empty</returns>
        public static int ptaGetArrays(
            Pta pta,
            out Numa pnax,
            out Numa pnay)
        {
            if (pta == null)
            {
                throw new ArgumentNullException("pta cannot be Nothing");
            }

            IntPtr pnaxPtr = IntPtr.Zero;
            IntPtr pnayPtr = IntPtr.Zero;
            int    _Result = Natives.ptaGetArrays(pta.Pointer, out pnaxPtr, out pnayPtr);

            if (pnaxPtr == IntPtr.Zero)
            {
                pnax = null;
            }
            else
            {
                pnax = new Numa(pnaxPtr);
            };
            if (pnayPtr == IntPtr.Zero)
            {
                pnay = null;
            }
            else
            {
                pnay = new Numa(pnayPtr);
            };

            return(_Result);
        }
Пример #2
0
        // gplot.c (263, 1)
        // gplotAddPlot(gplot, nax, nay, plotstyle, plottitle) as int
        // gplotAddPlot(GPLOT *, NUMA *, NUMA *, l_int32, const char *) as l_ok
        ///  <summary>
        /// (1) There are 2 options for (x,y) values:
        /// o  To plot an array vs a linear function of the
        /// index, set nax = NULL.
        /// o  To plot one array vs another, use both nax and nay.<para/>
        ///
        /// (2) If nax is NULL, the x value corresponding to the i-th
        /// value of nay is found from the startx and delx fields
        /// in nay:
        /// x = startx + i  delx
        /// These are set with numaSetParameters().  Their default
        /// values are startx = 0.0, delx = 1.0.<para/>
        ///
        /// (3) If nax is defined, it must be the same size as nay, and
        /// must have at least one number.<para/>
        ///
        /// (4) The 'plottitle' string can have spaces, double
        /// quotes and backquotes, but not single quotes.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/gplotAddPlot/*"/>
        ///  <param name="gplot">[in] - </param>
        ///  <param name="nax">[in][optional] - numa: set to null for Y_VS_I required for Y_VS_X</param>
        ///  <param name="nay">[in] - numa: required for both Y_VS_I and Y_VS_X</param>
        ///  <param name="plotstyle">[in] - GPLOT_LINES, GPLOT_POINTS, GPLOT_IMPULSES, GPLOT_LINESPOINTS, GPLOT_DOTS</param>
        ///  <param name="plottitle">[in][optional] - title for individual plot</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int gplotAddPlot(
            GPlot gplot,
            Numa nax,
            Numa nay,
            int plotstyle,
            String plottitle = "")
        {
            if (gplot == null)
            {
                throw new ArgumentNullException("gplot cannot be Nothing");
            }

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

            IntPtr naxPtr = IntPtr.Zero;    if (nax != null)
            {
                naxPtr = nax.Pointer;
            }
            int _Result = Natives.gplotAddPlot(gplot.Pointer, naxPtr, nay.Pointer, plotstyle, plottitle);

            return(_Result);
        }
Пример #3
0
        // gplot.c (723, 1)
        // gplotSimpleXY2(nax, nay1, nay2, plotstyle, outformat, outroot, title) as int
        // gplotSimpleXY2(NUMA *, NUMA *, NUMA *, l_int32, l_int32, const char *, const char *) as l_ok
        ///  <summary>
        /// (1) This gives plots of %nay1 and %nay2 against nax, generated
        /// in the specified output format.  The title is optional.<para/>
        ///
        /// (2) Use 0 for default plotstyle (lines).<para/>
        ///
        /// (3) %nax is optional.  If NULL, %nay1 and %nay2 are plotted
        /// against the array index.<para/>
        ///
        /// (4) When calling these simple plot functions more than once, use
        /// different %outroot to avoid overwriting the output files.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/gplotSimpleXY2/*"/>
        ///  <param name="nax">[in] - is smalleroptional can be NULL</param>
        ///  <param name="nay1">[in] - </param>
        ///  <param name="nay2">[in] - </param>
        ///  <param name="plotstyle">[in] - GPLOT_LINES, GPLOT_POINTS, GPLOT_IMPULSES, GPLOT_LINESPOINTS, GPLOT_DOTS</param>
        ///  <param name="outformat">[in] - GPLOT_PNG, GPLOT_PS, GPLOT_EPS, GPLOT_LATEX</param>
        ///  <param name="outroot">[in] - root of output files</param>
        ///  <param name="title">[in][optional] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int gplotSimpleXY2(
            Numa nax,
            Numa nay1,
            Numa nay2,
            int plotstyle,
            int outformat,
            String outroot,
            String title = "")
        {
            if (nax == null)
            {
                throw new ArgumentNullException("nax cannot be Nothing");
            }

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

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

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

            int _Result = Natives.gplotSimpleXY2(nax.Pointer, nay1.Pointer, nay2.Pointer, plotstyle, outformat, outroot, title);

            return(_Result);
        }
Пример #4
0
        // watershed.c (1034, 1)
        // wshedBasins(wshed, ppixa, pnalevels) as int
        // wshedBasins(L_WSHED *, PIXA **, NUMA **) as l_ok
        ///  <summary>
        /// wshedBasins()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/wshedBasins/*"/>
        ///  <param name="wshed">[in] - </param>
        ///  <param name="ppixa">[out][optional] - mask of watershed basins</param>
        ///  <param name="pnalevels">[out][optional] - watershed levels</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int wshedBasins(
            L_WShed wshed,
            out Pixa ppixa,
            out Numa pnalevels)
        {
            if (wshed == null)
            {
                throw new ArgumentNullException("wshed cannot be Nothing");
            }

            IntPtr ppixaPtr     = IntPtr.Zero;
            IntPtr pnalevelsPtr = IntPtr.Zero;
            int    _Result      = Natives.wshedBasins(wshed.Pointer, out ppixaPtr, out pnalevelsPtr);

            if (ppixaPtr == IntPtr.Zero)
            {
                ppixa = null;
            }
            else
            {
                ppixa = new Pixa(ppixaPtr);
            };
            if (pnalevelsPtr == IntPtr.Zero)
            {
                pnalevels = null;
            }
            else
            {
                pnalevels = new Numa(pnalevelsPtr);
            };

            return(_Result);
        }
Пример #5
0
        // ptafunc2.c (132, 1)
        // ptaGetSortIndex(ptas, sorttype, sortorder, pnaindex) as int
        // ptaGetSortIndex(PTA *, l_int32, l_int32, NUMA **) as l_ok
        ///  <summary>
        /// ptaGetSortIndex()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ptaGetSortIndex/*"/>
        ///  <param name="ptas">[in] - </param>
        ///  <param name="sorttype">[in] - L_SORT_BY_X, L_SORT_BY_Y</param>
        ///  <param name="sortorder">[in] - L_SORT_INCREASING, L_SORT_DECREASING</param>
        ///  <param name="pnaindex">[out] - index of sorted order into original array</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int ptaGetSortIndex(
            Pta ptas,
            int sorttype,
            int sortorder,
            out Numa pnaindex)
        {
            if (ptas == null)
            {
                throw new ArgumentNullException("ptas cannot be Nothing");
            }

            IntPtr pnaindexPtr = IntPtr.Zero;
            int    _Result     = Natives.ptaGetSortIndex(ptas.Pointer, sorttype, sortorder, out pnaindexPtr);

            if (pnaindexPtr == IntPtr.Zero)
            {
                pnaindex = null;
            }
            else
            {
                pnaindex = new Numa(pnaindexPtr);
            };

            return(_Result);
        }
Пример #6
0
        // gplot.c (779, 1)
        // gplotSimpleXYN(nax, naay, plotstyle, outformat, outroot, title) as int
        // gplotSimpleXYN(NUMA *, NUMAA *, l_int32, l_int32, const char *, const char *) as l_ok
        ///  <summary>
        /// (1) This gives plots of each Numa in %naa against nax,
        /// generated in the specified output format.  The title is optional.<para/>
        ///
        /// (2) Use 0 for default plotstyle (lines).<para/>
        ///
        /// (3) %nax is optional.  If NULL, each Numa array is plotted against
        /// the array index.<para/>
        ///
        /// (4) When calling these simple plot functions more than once, use
        /// different %outroot to avoid overwriting the output files.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/gplotSimpleXYN/*"/>
        ///  <param name="nax">[in][optional] - can be NULL</param>
        ///  <param name="naay">[in] - numaa of arrays to plot against %nax</param>
        ///  <param name="plotstyle">[in] - GPLOT_LINES, GPLOT_POINTS, GPLOT_IMPULSES, GPLOT_LINESPOINTS, GPLOT_DOTS</param>
        ///  <param name="outformat">[in] - GPLOT_PNG, GPLOT_PS, GPLOT_EPS, GPLOT_LATEX</param>
        ///  <param name="outroot">[in] - root of output files</param>
        ///  <param name="title">[in][optional] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int gplotSimpleXYN(
            Numa nax,
            Numaa naay,
            int plotstyle,
            int outformat,
            String outroot,
            String title = "")
        {
            if (naay == null)
            {
                throw new ArgumentNullException("naay cannot be Nothing");
            }

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

            IntPtr naxPtr = IntPtr.Zero;    if (nax != null)
            {
                naxPtr = nax.Pointer;
            }
            int _Result = Natives.gplotSimpleXYN(naxPtr, naay.Pointer, plotstyle, outformat, outroot, title);

            return(_Result);
        }
Пример #7
0
        // readbarcode.c (1267, 1)
        // numaQuantizeCrossingsByWindow(nas, ratio, pwidth, pfirstloc, pnac, debugflag) as Numa
        // numaQuantizeCrossingsByWindow(NUMA *, l_float32, l_float32 *, l_float32 *, NUMA **, l_int32) as NUMA *
        ///  <summary>
        /// (1) The minimum size of the window is set by the minimum
        /// distance between zero crossings.<para/>
        ///
        /// (2) The optional return signal %nac is a sequence of 0s, 1s,
        /// and perhaps a few 2s, giving the number of crossings in each window.
        /// On the occasion where there is a '2', it is interpreted as
        /// ending two runs: the previous one and another one that has length 1.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/numaQuantizeCrossingsByWindow/*"/>
        ///  <param name="nas">[in] - numa of crossing locations</param>
        ///  <param name="ratio">[in] - of max window size over min window size in search typ. 2.0</param>
        ///  <param name="pwidth">[out][optional] - best window width</param>
        ///  <param name="pfirstloc">[out][optional] - center of window for first xing</param>
        ///  <param name="pnac">[out][optional] - array of window crossings (0, 1, 2)</param>
        ///  <param name="debugflag">[in] - 1 to generate various plots of intermediate results</param>
        ///   <returns>nad sequence of widths, in unit sizes, or NULL on error</returns>
        public static Numa numaQuantizeCrossingsByWindow(
            Numa nas,
            Single ratio,
            out Single pwidth,
            out Single pfirstloc,
            out Numa pnac,
            int debugflag)
        {
            if (nas == null)
            {
                throw new ArgumentNullException("nas cannot be Nothing");
            }

            IntPtr pnacPtr = IntPtr.Zero;
            IntPtr _Result = Natives.numaQuantizeCrossingsByWindow(nas.Pointer, ratio, out pwidth, out pfirstloc, out pnacPtr, debugflag);

            if (pnacPtr == IntPtr.Zero)
            {
                pnac = null;
            }
            else
            {
                pnac = new Numa(pnacPtr);
            };

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

            return(new Numa(_Result));
        }
Пример #8
0
        // grayquant.c (1952, 1)
        // makeGrayQuantTableArb(na, outdepth, ptab, pcmap) as int
        // makeGrayQuantTableArb(NUMA *, l_int32, l_int32 **, PIXCMAP **) as l_ok
        ///  <summary>
        /// (1) The number of bins is the count of %na + 1.<para/>
        ///
        /// (2) The bin boundaries in na must be sorted in increasing order.<para/>
        ///
        /// (3) The table is an inverse colormap: it maps input gray level
        /// to colormap index (the bin number).<para/>
        ///
        /// (4) The colormap generated here has quantized values at the
        /// center of each bin.  If you want to use the average gray
        /// value of pixels within the bin, discard the colormap and
        /// compute it using makeGrayQuantColormapArb().<para/>
        ///
        /// (5) Returns an error if there are not enough levels in the
        /// output colormap for the number of bins.  The number
        /// of bins must not exceed 2^outdepth.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/makeGrayQuantTableArb/*"/>
        ///  <param name="na">[in] - numa of bin boundaries</param>
        ///  <param name="outdepth">[in] - of colormap: 1, 2, 4 or 8</param>
        ///  <param name="ptab">[out] - table mapping input gray level to cmap index</param>
        ///  <param name="pcmap">[out] - colormap</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int makeGrayQuantTableArb(
            Numa na,
            int outdepth,
            out List <int[]> ptab,
            out PixColormap pcmap)
        {
            if (na == null)
            {
                throw new ArgumentNullException("na cannot be Nothing");
            }

            IntPtr ptabPtr  = IntPtr.Zero;
            IntPtr pcmapPtr = IntPtr.Zero;
            int    _Result  = Natives.makeGrayQuantTableArb(na.Pointer, outdepth, out ptabPtr, out pcmapPtr);

            if (ptabPtr == null)
            {
                ptab = null;
            }
            else
            {
                ptab = null;
            };
            if (pcmapPtr == IntPtr.Zero)
            {
                pcmap = null;
            }
            else
            {
                pcmap = new PixColormap(pcmapPtr);
            };

            return(_Result);
        }
Пример #9
0
        // textops.c (641, 1)
        // pixaAddTextNumber(pixas, bmf, na, val, location) as Pixa
        // pixaAddTextNumber(PIXA *, L_BMF *, NUMA *, l_uint32, l_int32) as PIXA *
        ///  <summary>
        /// (1) Typical usage is for labelling each pix in a pixa with a number.<para/>
        ///
        /// (2) This function paints numbers external to each pix, in a position
        /// given by %location.  In all cases, the pix is expanded on
        /// on side and the number is painted over white in the added region.<para/>
        ///
        /// (3) %val is the pixel value to be painted through the font mask.
        /// It should be chosen to agree with the depth of pixs.
        /// If it is out of bounds, an intermediate value is chosen.
        /// For RGB, use hex notation: 0xRRGGBB00, where RR is the
        /// hex representation of the red intensity, etc.<para/>
        ///
        /// (4) If na == NULL, number each pix sequentially, starting with 1.<para/>
        ///
        /// (5) If there is a colormap, this does the best it can to use
        /// the requested color, or something similar to it.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixaAddTextNumber/*"/>
        ///  <param name="pixas">[in] - input pixa colormap ok</param>
        ///  <param name="bmf">[in] - bitmap font data</param>
        ///  <param name="na">[in][optional] - number array use 1 ... n if null</param>
        ///  <param name="val">[in] - color to set the text</param>
        ///  <param name="location">[in] - L_ADD_ABOVE, L_ADD_BELOW, L_ADD_LEFT, L_ADD_RIGHT</param>
        ///   <returns>pixad new pixa with rendered numbers, or NULL on error</returns>
        public static Pixa pixaAddTextNumber(
            Pixa pixas,
            L_Bmf bmf,
            Numa na,
            uint val,
            int location)
        {
            if (pixas == null)
            {
                throw new ArgumentNullException("pixas cannot be Nothing");
            }

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

            IntPtr naPtr = IntPtr.Zero;     if (na != null)
            {
                naPtr = na.Pointer;
            }
            IntPtr _Result = Natives.pixaAddTextNumber(pixas.Pointer, bmf.Pointer, naPtr, val, location);

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

            return(new Pixa(_Result));
        }
Пример #10
0
        // morphapp.c (973, 1)
        // pixaExtendByScaling(pixas, nasc, type, include) as Pixa
        // pixaExtendByScaling(PIXA *, NUMA *, l_int32, l_int32) as PIXA *
        ///  <summary>
        /// (1) This scales every pix in %pixas by each factor in %nasc.
        /// and puts the results in %pixad.<para/>
        ///
        /// (2) If %include == 1, the output %pixad contains all the pix
        /// in %pixas.  Otherwise, it doesn't, but pixaJoin() can be
        /// used later to join pixas with pixad.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixaExtendByScaling/*"/>
        ///  <param name="pixas">[in] - </param>
        ///  <param name="nasc">[in] - numa of scaling factors</param>
        ///  <param name="type">[in] - L_HORIZ, L_VERT, L_BOTH_DIRECTIONS</param>
        ///  <param name="include">[in] - 1 to include a copy of the input pixas in pixad 0 to omit</param>
        ///   <returns>pixad   with derived pix, using all scalings, or NULL on error</returns>
        public static Pixa pixaExtendByScaling(
            Pixa pixas,
            Numa nasc,
            int type,
            int include)
        {
            if (pixas == null)
            {
                throw new ArgumentNullException("pixas cannot be Nothing");
            }

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

            IntPtr _Result = Natives.pixaExtendByScaling(pixas.Pointer, nasc.Pointer, type, include);

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

            return(new Pixa(_Result));
        }
Пример #11
0
        // recogtrain.c (970, 1)
        // recogFilterPixaBySize(pixas, setsize, maxkeep, max_ht_ratio, pna) as Pixa
        // recogFilterPixaBySize(PIXA *, l_int32, l_int32, l_float32, NUMA **) as PIXA *
        ///  <summary>
        /// (1) The basic assumption is that the most common and larger
        /// templates in each class are more likely to represent the
        /// characters we are interested in.  For example, larger digits
        /// are more likely to represent page numbers, and smaller digits
        /// could be data in tables.  Therefore, we bias the first
        /// stage of filtering toward the larger characters by removing
        /// very small ones, and select based on proximity of the
        /// remaining characters to median height.<para/>
        ///
        /// (2) For each of the %setsize classes, order the templates
        /// increasingly by height.  Take the rank 0.9 height.  Eliminate
        /// all templates that are shorter by more than %max_ht_ratio.
        /// Of the remaining ones, select up to %maxkeep that are closest
        /// in rank order height to the median template.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/recogFilterPixaBySize/*"/>
        ///  <param name="pixas">[in] - labeled templates</param>
        ///  <param name="setsize">[in] - size of character set (number of classes)</param>
        ///  <param name="maxkeep">[in] - max number of templates to keep in a class</param>
        ///  <param name="max_ht_ratio">[in] - max allowed height ratio (see below)</param>
        ///  <param name="pna">[out][optional] - debug output, giving the number in each class after filtering use NULL to skip</param>
        ///   <returns>pixa   filtered templates, or NULL on error</returns>
        public static Pixa recogFilterPixaBySize(
            Pixa pixas,
            int setsize,
            int maxkeep,
            Single max_ht_ratio,
            out Numa pna)
        {
            if (pixas == null)
            {
                throw new ArgumentNullException("pixas cannot be Nothing");
            }

            IntPtr pnaPtr  = IntPtr.Zero;
            IntPtr _Result = Natives.recogFilterPixaBySize(pixas.Pointer, setsize, maxkeep, max_ht_ratio, out pnaPtr);

            if (pnaPtr == IntPtr.Zero)
            {
                pna = null;
            }
            else
            {
                pna = new Numa(pnaPtr);
            };

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

            return(new Pixa(_Result));
        }
Пример #12
0
        // boxfunc2.c (1478, 1)
        // boxaaFlattenToBoxa(baa, pnaindex, copyflag) as Boxa
        // boxaaFlattenToBoxa(BOXAA *, NUMA **, l_int32) as BOXA *
        ///  <summary>
        /// (1) This 'flattens' the baa to a boxa, taking the boxes in
        /// order in the first boxa, then the second, etc.<para/>
        ///
        /// (2) If a boxa is empty, we generate an invalid, placeholder box
        /// of zero size.  This is useful when converting from a baa
        /// where each boxa has either 0 or 1 boxes, and it is necessary
        /// to maintain a 1:1 correspondence between the initial
        /// boxa array and the resulting box array.<para/>
        ///
        /// (3) If [and]naindex is defined, we generate a Numa that gives, for
        /// each box in the baa, the index of the boxa to which it belongs.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/boxaaFlattenToBoxa/*"/>
        ///  <param name="baa">[in] - </param>
        ///  <param name="pnaindex">[out][optional] - the boxa index in the baa</param>
        ///  <param name="copyflag">[in] - L_COPY or L_CLONE</param>
        ///   <returns>boxa, or NULL on error</returns>
        public static Boxa boxaaFlattenToBoxa(
            Boxaa baa,
            out Numa pnaindex,
            int copyflag)
        {
            if (baa == null)
            {
                throw new ArgumentNullException("baa cannot be Nothing");
            }

            IntPtr pnaindexPtr = IntPtr.Zero;
            IntPtr _Result     = Natives.boxaaFlattenToBoxa(baa.Pointer, out pnaindexPtr, copyflag);

            if (pnaindexPtr == IntPtr.Zero)
            {
                pnaindex = null;
            }
            else
            {
                pnaindex = new Numa(pnaindexPtr);
            };

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

            return(new Boxa(_Result));
        }
Пример #13
0
        // gplot.c (604, 1)
        // gplotSimple2(na1, na2, outformat, outroot, title) as int
        // gplotSimple2(NUMA *, NUMA *, l_int32, const char *, const char *) as l_ok
        ///  <summary>
        /// (1) This gives a line plot of two numa, where the array values
        /// are each plotted vs the array index.  The plot is generated
        /// in the specified output format the title  is optional.<para/>
        ///
        /// (2) When calling these simple plot functions more than once, use
        /// different %outroot to avoid overwriting the output files.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/gplotSimple2/*"/>
        ///  <param name="na1">[in] - numa plotted with Y_VS_I</param>
        ///  <param name="na2">[in] - ditto</param>
        ///  <param name="outformat">[in] - GPLOT_PNG, GPLOT_PS, GPLOT_EPS, GPLOT_LATEX</param>
        ///  <param name="outroot">[in] - root of output files</param>
        ///  <param name="title">[in][optional] - </param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int gplotSimple2(
            Numa na1,
            Numa na2,
            int outformat,
            String outroot,
            String title = "")
        {
            if (na1 == null)
            {
                throw new ArgumentNullException("na1 cannot be Nothing");
            }

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

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

            int _Result = Natives.gplotSimple2(na1.Pointer, na2.Pointer, outformat, outroot, title);

            return(_Result);
        }
Пример #14
0
        // ptafunc2.c (89, 1)
        // ptaSort(ptas, sorttype, sortorder, pnaindex) as Pta
        // ptaSort(PTA *, l_int32, l_int32, NUMA **) as PTA *
        ///  <summary>
        /// ptaSort()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ptaSort/*"/>
        ///  <param name="ptas">[in] - </param>
        ///  <param name="sorttype">[in] - L_SORT_BY_X, L_SORT_BY_Y</param>
        ///  <param name="sortorder">[in] - L_SORT_INCREASING, L_SORT_DECREASING</param>
        ///  <param name="pnaindex">[out][optional] - index of sorted order into original array</param>
        ///   <returns>ptad sorted version of ptas, or NULL on error</returns>
        public static Pta ptaSort(
            Pta ptas,
            int sorttype,
            int sortorder,
            out Numa pnaindex)
        {
            if (ptas == null)
            {
                throw new ArgumentNullException("ptas cannot be Nothing");
            }

            IntPtr pnaindexPtr = IntPtr.Zero;
            IntPtr _Result     = Natives.ptaSort(ptas.Pointer, sorttype, sortorder, out pnaindexPtr);

            if (pnaindexPtr == IntPtr.Zero)
            {
                pnaindex = null;
            }
            else
            {
                pnaindex = new Numa(pnaindexPtr);
            };

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

            return(new Pta(_Result));
        }
Пример #15
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);
        }
Пример #16
0
        // readbarcode.c (679, 1)
        // pixExtractBarcodeWidths2(pixs, thresh, pwidth, pnac, debugflag) as Numa
        // pixExtractBarcodeWidths2(PIX *, l_float32, l_float32 *, NUMA **, l_int32) as NUMA *
        ///  <summary>
        /// (1) The widths are alternating black/white, starting with black
        /// and ending with black.<para/>
        ///
        /// (2) The optional best decoding window width is the width of the window
        /// that is used to make a decision about whether a transition occurs.
        /// It is approximately the average width in pixels of the narrowest
        /// white and black bars (i.e., those corresponding to unit width).<para/>
        ///
        /// (3) The optional return signal %nac is a sequence of 0s, 1s,
        /// and perhaps a few 2s, giving the number of crossings in each window.
        /// On the occasion where there is a '2', it is interpreted as
        /// as ending two runs: the previous one and another one that has length 1.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixExtractBarcodeWidths2/*"/>
        ///  <param name="pixs">[in] - input image 8 bpp</param>
        ///  <param name="thresh">[in] - estimated pixel threshold for crossing white  is smallerto black typ. ~120</param>
        ///  <param name="pwidth">[out][optional] - best decoding window width, in pixels</param>
        ///  <param name="pnac">[out][optional] - number of transitions in each window</param>
        ///  <param name="debugflag">[in] - use 1 to generate debug output</param>
        ///   <returns>nad numa of barcode widths in encoded integer units, or NULL on error</returns>
        public static Numa pixExtractBarcodeWidths2(
            Pix pixs,
            Single thresh,
            out Single pwidth,
            out Numa pnac,
            int debugflag)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr pnacPtr = IntPtr.Zero;
            IntPtr _Result = Natives.pixExtractBarcodeWidths2(pixs.Pointer, thresh, out pwidth, out pnacPtr, debugflag);

            if (pnacPtr == IntPtr.Zero)
            {
                pnac = null;
            }
            else
            {
                pnac = new Numa(pnacPtr);
            };

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

            return(new Numa(_Result));
        }
Пример #17
0
        // strokes.c (123, 1)
        // pixFindStrokeWidth(pixs, thresh, tab8, pwidth, pnahisto) as int
        // pixFindStrokeWidth(PIX *, l_float32, l_int32 *, l_float32 *, NUMA **) as l_ok
        ///  <summary>
        /// (1) This uses two methods to estimate the stroke width:
        /// (a) half the fg boundary length
        /// (b) a value derived from the histogram of the fg distance transform<para/>
        ///
        /// (2) Distance is measured in 8-connected<para/>
        ///
        /// (3) %thresh is the minimum fraction N(dist=d)/N(dist=1) of pixels
        /// required to determine if the pixels at distance d are above
        /// the noise. It is typically about 0.15.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixFindStrokeWidth/*"/>
        ///  <param name="pixs">[in] - 1 bpp</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="pwidth">[out] - estimated width of the strokes</param>
        ///  <param name="pnahisto">[out][optional] - histo of pixel distances from bg</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int pixFindStrokeWidth(
            Pix pixs,
            Single thresh,
            int[] tab8,
            out Single pwidth,
            out Numa pnahisto)
        {
            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");
            }
            IntPtr pnahistoPtr = IntPtr.Zero;
            int    _Result     = Natives.pixFindStrokeWidth(pixs.Pointer, thresh, tab8, out pwidth, out pnahistoPtr);

            if (pnahistoPtr == IntPtr.Zero)
            {
                pnahisto = null;
            }
            else
            {
                pnahisto = new Numa(pnahistoPtr);
            };

            return(_Result);
        }
Пример #18
0
        // runlength.c (525, 1)
        // pixFindMaxRuns(pix, direction, pnastart) as Numa
        // pixFindMaxRuns(PIX *, l_int32, NUMA **) as NUMA *
        ///  <summary>
        /// (1) This finds the longest foreground runs by row or column<para/>
        ///
        /// (2) To find background runs, use pixInvert() before applying
        /// this function.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixFindMaxRuns/*"/>
        ///  <param name="pix">[in] - 1 bpp</param>
        ///  <param name="direction">[in] - L_HORIZONTAL_RUNS or L_VERTICAL_RUNS</param>
        ///  <param name="pnastart">[out][optional] - start locations of longest runs</param>
        ///   <returns>na of lengths of runs, or NULL on error</returns>
        public static Numa pixFindMaxRuns(
            Pix pix,
            int direction,
            out Numa pnastart)
        {
            if (pix == null)
            {
                throw new ArgumentNullException("pix cannot be Nothing");
            }

            if ((new List <int> {
                1
            }).Contains((int)pix.d) == false)
            {
                throw new ArgumentException("1 bpp");
            }
            IntPtr pnastartPtr = IntPtr.Zero;
            IntPtr _Result     = Natives.pixFindMaxRuns(pix.Pointer, direction, out pnastartPtr);

            if (pnastartPtr == IntPtr.Zero)
            {
                pnastart = null;
            }
            else
            {
                pnastart = new Numa(pnastartPtr);
            };

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

            return(new Numa(_Result));
        }
Пример #19
0
        // paintcmap.c (492, 1)
        // addColorizedGrayToCmap(cmap, type, rval, gval, bval, pna) as int
        // addColorizedGrayToCmap(PIXCMAP *, l_int32, l_int32, l_int32, l_int32, NUMA **) as l_ok
        ///  <summary>
        /// (1) If type == L_PAINT_LIGHT, it colorizes non-black pixels,
        /// preserving antialiasing.
        /// If type == L_PAINT_DARK, it colorizes non-white pixels,
        /// preserving antialiasing.<para/>
        ///
        /// (2) This increases the colormap size by the number of
        /// different gray (non-black or non-white) colors in the
        /// input colormap.  If there is not enough room in the colormap
        /// for this expansion, it returns 1 (treated as a warning)
        /// the caller should check the return value.<para/>
        ///
        /// (3) This can be used to determine if the new colors will fit in
        /// the cmap, using null for [and]na.  Returns 0 if they fit 2 if
        /// they don't fit.<para/>
        ///
        /// (4) The mapping table contains, for each gray color found, the
        /// index of the corresponding colorized pixel.  Non-gray
        /// pixels are assigned the invalid index 256.<para/>
        ///
        /// (5) See pixColorGrayCmap() for usage.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/addColorizedGrayToCmap/*"/>
        ///  <param name="cmap">[in] - from 2 or 4 bpp pix</param>
        ///  <param name="type">[in] - L_PAINT_LIGHT, L_PAINT_DARK</param>
        ///  <param name="rval">[in] - target color</param>
        ///  <param name="gval">[in] - target color</param>
        ///  <param name="bval">[in] - target color</param>
        ///  <param name="pna">[out][optional] - table for mapping new cmap entries</param>
        ///   <returns>0 if OK 1 on error 2 if new colors will not fit in cmap.</returns>
        public static int addColorizedGrayToCmap(
            PixColormap cmap,
            int type,
            int rval,
            int gval,
            int bval,
            out Numa pna)
        {
            if (cmap == null)
            {
                throw new ArgumentNullException("cmap cannot be Nothing");
            }

            IntPtr pnaPtr  = IntPtr.Zero;
            int    _Result = Natives.addColorizedGrayToCmap(cmap.Pointer, type, rval, gval, bval, out pnaPtr);

            if (pnaPtr == IntPtr.Zero)
            {
                pna = null;
            }
            else
            {
                pna = new Numa(pnaPtr);
            };

            return(_Result);
        }
Пример #20
0
        // dnafunc1.c (187, 1)
        // numaConvertToDna(na) as L_Dna
        // numaConvertToDna(NUMA *) as L_DNA *
        ///  <summary>
        /// numaConvertToDna
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/numaConvertToDna/*"/>
        ///  <param name="na">[in] - </param>
        ///   <returns>da, or NULL on error</returns>
        public static L_Dna numaConvertToDna(
            Numa na)
        {
            if (na == null) {throw new ArgumentNullException  ("na cannot be Nothing");}

            IntPtr _Result = Natives.numaConvertToDna(na.Pointer);

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

            return  new L_Dna(_Result);
        }
Пример #21
0
        // seedfill.c (3317, 1)
        // pixSelectMinInConnComp(pixs, pixm, ppta, pnav) as int
        // pixSelectMinInConnComp(PIX *, PIX *, PTA **, NUMA **) as l_ok
        ///  <summary>
        /// (1) For each 8 connected component in pixm, this finds
        /// a pixel in pixs that has the lowest value, and saves
        /// it in a Pta.  If several pixels in pixs have the same
        /// minimum value, it picks the first one found.<para/>
        ///
        /// (2) For a mask pixm of true local minima, all pixels in each
        /// connected component have the same value in pixs, so it is
        /// fastest to select one of them using a special seedfill
        /// operation.  Not yet implemented.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixSelectMinInConnComp/*"/>
        ///  <param name="pixs">[in] - 8 bpp</param>
        ///  <param name="pixm">[in] - 1 bpp</param>
        ///  <param name="ppta">[out] - pta of min pixel locations</param>
        ///  <param name="pnav">[out][optional] - numa of minima values</param>
        ///   <returns>0 if OK, 1 on error.</returns>
        public static int pixSelectMinInConnComp(
            Pix pixs,
            Pix pixm,
            out Pta ppta,
            out Numa pnav)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

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

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

            if ((new List <int> {
                1
            }).Contains((int)pixm.d) == false)
            {
                throw new ArgumentException("1 bpp");
            }
            IntPtr pptaPtr = IntPtr.Zero;
            IntPtr pnavPtr = IntPtr.Zero;
            int    _Result = Natives.pixSelectMinInConnComp(pixs.Pointer, pixm.Pointer, out pptaPtr, out pnavPtr);

            if (pptaPtr == IntPtr.Zero)
            {
                ppta = null;
            }
            else
            {
                ppta = new Pta(pptaPtr);
            };
            if (pnavPtr == IntPtr.Zero)
            {
                pnav = null;
            }
            else
            {
                pnav = new Numa(pnavPtr);
            };

            return(_Result);
        }
Пример #22
0
        // classapp.c (378, 1)
        // pixGetWordsInTextlines(pixs, minwidth, minheight, maxwidth, maxheight, pboxad, ppixad, pnai) as int
        // pixGetWordsInTextlines(PIX *, l_int32, l_int32, l_int32, l_int32, BOXA **, PIXA **, NUMA **) as l_ok
        ///  <summary>
        /// (1) The input should be at a resolution of between 75 and 150 ppi.<para/>
        ///
        /// (2) The four size constraints on saved components are all
        /// scaled by %reduction.<para/>
        ///
        /// (3) The result are word images (and their b.b.), extracted in
        /// textline order, at either full res or 2x reduction,
        /// and with a numa giving the textline index for each word.<para/>
        ///
        /// (4) The pixa and boxa interfaces should make this type of
        /// application simple to put together.  The steps are:
        /// ~ generate first estimate of word masks
        /// ~ get b.b. of these, and remove the small and big ones
        /// ~ extract pixa of the word images, using the b.b.
        /// ~ sort actual word images in textline order (2d)
        /// ~ flatten them to a pixa (1d), saving the textline index
        /// for each pix<para/>
        ///
        /// (5) In an actual application, it may be desirable to pre-filter
        /// the input image to remove large components, to extract
        /// single columns of text, and to deskew them.  For example,
        /// to remove both large components and small noisy components
        /// that can interfere with the statistics used to estimate
        /// parameters for segmenting by words, but still retain text lines,
        /// the following image preprocessing can be done:
        /// Pix pixt = pixMorphSequence(pixs, "c40.1", 0)
        /// Pix pixf = pixSelectBySize(pixt, 0, 60, 8,
        /// L_SELECT_HEIGHT, L_SELECT_IF_LT, NULL)
        /// pixAnd(pixf, pixf, pixs)  // the filtered image
        /// The closing turns text lines into long blobs, but does not
        /// significantly increase their height.  But if there are many
        /// small connected components in a dense texture, this is likely
        /// to generate tall components that will be eliminated in pixf.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixGetWordsInTextlines/*"/>
        ///  <param name="pixs">[in] - 1 bpp, typ. 75 - 150 ppi</param>
        ///  <param name="minwidth">[in] - of saved components smaller are discarded</param>
        ///  <param name="minheight">[in] - of saved components smaller are discarded</param>
        ///  <param name="maxwidth">[in] - of saved components larger are discarded</param>
        ///  <param name="maxheight">[in] - of saved components larger are discarded</param>
        ///  <param name="pboxad">[out] - word boxes sorted in textline line order</param>
        ///  <param name="ppixad">[out] - word images sorted in textline line order</param>
        ///  <param name="pnai">[out] - index of textline for each word</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int pixGetWordsInTextlines(
            Pix pixs,
            int minwidth,
            int minheight,
            int maxwidth,
            int maxheight,
            out Boxa pboxad,
            out Pixa ppixad,
            out Numa pnai)
        {
            if (pixs == null)
            {
                throw new ArgumentNullException("pixs cannot be Nothing");
            }

            IntPtr pboxadPtr = IntPtr.Zero;
            IntPtr ppixadPtr = IntPtr.Zero;
            IntPtr pnaiPtr   = IntPtr.Zero;
            int    _Result   = Natives.pixGetWordsInTextlines(pixs.Pointer, minwidth, minheight, maxwidth, maxheight, out pboxadPtr, out ppixadPtr, out pnaiPtr);

            if (pboxadPtr == IntPtr.Zero)
            {
                pboxad = null;
            }
            else
            {
                pboxad = new Boxa(pboxadPtr);
            };
            if (ppixadPtr == IntPtr.Zero)
            {
                ppixad = null;
            }
            else
            {
                ppixad = new Pixa(ppixadPtr);
            };
            if (pnaiPtr == IntPtr.Zero)
            {
                pnai = null;
            }
            else
            {
                pnai = new Numa(pnaiPtr);
            };

            return(_Result);
        }
Пример #23
0
        // tiffio.c (711, 1)
        // pixWriteTiffCustom(filename, pix, comptype, modestr, natags, savals, satypes, nasizes) as int
        // pixWriteTiffCustom(const char *, PIX *, l_int32, const char *, NUMA *, SARRAY *, SARRAY *, NUMA *) as l_ok
        ///  <summary>
        /// pixWriteTiffCustom()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixWriteTiffCustom/*"/>
        ///  <param name="filename">[in] - to write to</param>
        ///  <param name="pix">[in] - </param>
        ///  <param name="comptype">[in] - IFF_TIFF, IFF_TIFF_RLE, IFF_TIFF_PACKBITS, IFF_TIFF_G3, IFF_TIFF_G4, IFF_TIFF_LZW, IFF_TIFF_ZIP</param>
        ///  <param name="modestr">[in] - "a" or "w"</param>
        ///  <param name="natags">[in][optional] - NUMA of custom tiff tags</param>
        ///  <param name="savals">[in][optional] - SARRAY of values</param>
        ///  <param name="satypes">[in][optional] - SARRAY of types</param>
        ///  <param name="nasizes">[in][optional] - NUMA of sizes</param>
        ///   <returns>0 if OK, 1 on error Usage: 1 This writes a page image to a tiff file, with optional extra tags defined in tiff.h 2 For multipage tiff, write the first pix with mode "w" and all subsequent pix with mode "a". 3 For the custom tiff tags: a The three arrays {natags, savals, satypes} must all be either NULL or defined and of equal size. b If they are defined, the tags are an array of integers, the vals are an array of values in string format, and the types are an array of types in string format. c All valid tags are definined in tiff.h. d The types allowed are the set of strings: "char" "l_uint8" "l_uint16" "l_uint32" "l_int32" "l_float64" "l_uint16-l_uint16" note the dash use it between the two l_uint16 vals in the val string Of these, "char" and "l_uint16" are the most commonly used. e The last array, nasizes, is also optional.  It is for tags that take an array of bytes for a value, a number of elements in the array, and a type that is either "char" or "l_uint8" probably either will work. Use NULL if there are no such tags. f VERY IMPORTANT: if there are any tags that require the extra size value, stored in nasizes, they must be written first!</returns>
        public static int pixWriteTiffCustom(
            String filename,
            Pix pix,
            int comptype,
            String modestr,
            Numa natags    = null,
            Sarray savals  = null,
            Sarray satypes = null,
            Numa nasizes   = null)
        {
            if (filename == null)
            {
                throw new ArgumentNullException("filename cannot be Nothing");
            }

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

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

            IntPtr natagsPtr = IntPtr.Zero;         if (natags != null)
            {
                natagsPtr = natags.Pointer;
            }
            IntPtr savalsPtr = IntPtr.Zero;         if (savals != null)
            {
                savalsPtr = savals.Pointer;
            }
            IntPtr satypesPtr = IntPtr.Zero;        if (satypes != null)
            {
                satypesPtr = satypes.Pointer;
            }
            IntPtr nasizesPtr = IntPtr.Zero;        if (nasizes != null)
            {
                nasizesPtr = nasizes.Pointer;
            }
            int _Result = Natives.pixWriteTiffCustom(filename, pix.Pointer, comptype, modestr, natagsPtr, savalsPtr, satypesPtr, nasizesPtr);

            return(_Result);
        }
Пример #24
0
        public static L_Dna numaConvertToDna(this Numa na)
        {
            if (null == na)
            {
                throw new ArgumentNullException("na cannot be null");
            }

            var pointer = Native.DllImports.numaConvertToDna((HandleRef)na);

            if (IntPtr.Zero == pointer)
            {
                return(null);
            }
            else
            {
                return(new L_Dna(pointer));
            }
        }
Пример #25
0
        // tiffio.c (2703, 1)
        // pixWriteMemTiffCustom(pdata, psize, pix, comptype, natags, savals, satypes, nasizes) as int
        // pixWriteMemTiffCustom(l_uint8 **, size_t *, PIX *, l_int32, NUMA *, SARRAY *, SARRAY *, NUMA *) as l_ok
        ///  <summary>
        /// pixWriteMemTiffCustom()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixWriteMemTiffCustom/*"/>
        ///  <param name="pdata">[out] - data of tiff compressed image</param>
        ///  <param name="psize">[out] - size of returned data</param>
        ///  <param name="pix">[in] - </param>
        ///  <param name="comptype">[in] - IFF_TIFF, IFF_TIFF_RLE, IFF_TIFF_PACKBITS, IFF_TIFF_G3, IFF_TIFF_G4, IFF_TIFF_LZW, IFF_TIFF_ZIP</param>
        ///  <param name="natags">[in][optional] - NUMA of custom tiff tags</param>
        ///  <param name="savals">[in][optional] - SARRAY of values</param>
        ///  <param name="satypes">[in][optional] - SARRAY of types</param>
        ///  <param name="nasizes">[in][optional] - NUMA of sizes</param>
        ///   <returns>0 if OK, 1 on error Usage: 1) See pixWriteTiffCustom(.  This version writes to memory instead of to a file. 2) Use TIFFClose() TIFFCleanup( doesn't free internal memstream.</returns>
        public static int pixWriteMemTiffCustom(
            out Byte[] pdata,
            out uint psize,
            Pix pix,
            int comptype,
            Numa natags    = null,
            Sarray savals  = null,
            Sarray satypes = null,
            Numa nasizes   = null)
        {
            if (pix == null)
            {
                throw new ArgumentNullException("pix cannot be Nothing");
            }

            IntPtr pdataPtr  = IntPtr.Zero;
            IntPtr natagsPtr = IntPtr.Zero;         if (natags != null)
            {
                natagsPtr = natags.Pointer;
            }
            IntPtr savalsPtr = IntPtr.Zero;         if (savals != null)
            {
                savalsPtr = savals.Pointer;
            }
            IntPtr satypesPtr = IntPtr.Zero;        if (satypes != null)
            {
                satypesPtr = satypes.Pointer;
            }
            IntPtr nasizesPtr = IntPtr.Zero;        if (nasizes != null)
            {
                nasizesPtr = nasizes.Pointer;
            }
            int _Result = Natives.pixWriteMemTiffCustom(out pdataPtr, out psize, pix.Pointer, comptype, natagsPtr, savalsPtr, satypesPtr, nasizesPtr);

            Byte[] pdataGen = new Byte[psize];

            if (pdataPtr != IntPtr.Zero)
            {
                Marshal.Copy(pdataPtr, pdataGen, 0, pdataGen.Length);
            }

            pdata = pdataGen;
            return(_Result);
        }
Пример #26
0
        // pixalloc.c (168, 1)
        // pmsCreate(minsize, smallest, numalloc, logfile) as int
        // pmsCreate(size_t, size_t, NUMA *, const char *) as l_ok
        ///  <summary>
        /// (1) This computes the size of the block of memory required
        /// and allocates it.  Each chunk starts on a 32-bit word boundary.
        /// The chunk sizes are in powers of 2, starting at %smallest,
        /// and the number of levels and chunks at each level is
        /// specified by %numalloc.<para/>
        ///
        /// (2) This is intended to manage the image data for a small number
        /// of relatively large pix.  The system malloc is expected to
        /// handle very large numbers of small chunks efficiently.<para/>
        ///
        /// (3) Important: set the allocators and call this function
        /// before any pix have been allocated.  Destroy all the pix
        /// in the normal way before calling pmsDestroy().<para/>
        ///
        /// (4) The pms struct is stored in a static global, so this function
        /// is not thread-safe.  When used, there must be only one thread
        /// per process.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pmsCreate/*"/>
        ///  <param name="minsize">[in] - of data chunk that can be supplied by pms</param>
        ///  <param name="smallest">[in] - bytes of the smallest pre-allocated data chunk.</param>
        ///  <param name="numalloc">[in] - array with the number of data chunks for each size that are in the memory store</param>
        ///  <param name="logfile">[in] - use for debugging null otherwise</param>
        ///   <returns>0 if OK, 1 on error</returns>
        public static int pmsCreate(
            uint minsize,
            uint smallest,
            Numa numalloc,
            String logfile)
        {
            if (numalloc == null)
            {
                throw new ArgumentNullException("numalloc cannot be Nothing");
            }

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

            int _Result = Natives.pmsCreate(minsize, smallest, numalloc.Pointer, logfile);

            return(_Result);
        }
Пример #27
0
        // classapp.c (266, 1)
        // jbWordsInTextlines(dirin, reduction, maxwidth, maxheight, thresh, weight, pnatl, firstpage, npages) as JbClasser
        // jbWordsInTextlines(const char *, l_int32, l_int32, l_int32, l_float32, l_float32, NUMA **, l_int32, l_int32) as JBCLASSER *
        ///  <summary>
        /// (1) This is a high-level function.  See prog/jbwords for example
        /// of usage.<para/>
        ///
        /// (2) Typically, use input of 75 - 150 ppi for finding words.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/jbWordsInTextlines/*"/>
        ///  <param name="dirin">[in] - directory of input pages</param>
        ///  <param name="reduction">[in] - 1 for full res 2 for half-res</param>
        ///  <param name="maxwidth">[in] - of word mask components, to be kept</param>
        ///  <param name="maxheight">[in] - of word mask components, to be kept</param>
        ///  <param name="thresh">[in] - on correlation 0.80 is reasonable</param>
        ///  <param name="weight">[in] - for handling thick text 0.6 is reasonable</param>
        ///  <param name="pnatl">[out] - numa with textline index for each component</param>
        ///  <param name="firstpage">[in] - 0-based</param>
        ///  <param name="npages">[in] - use 0 for all pages in dirin</param>
        ///   <returns>classer for the set of pages</returns>
        public static JbClasser jbWordsInTextlines(
            String dirin,
            int reduction,
            int maxwidth,
            int maxheight,
            Single thresh,
            Single weight,
            out Numa pnatl,
            int firstpage,
            int npages)
        {
            if (dirin == null)
            {
                throw new ArgumentNullException("dirin cannot be Nothing");
            }

            if (reduction < 2 || reduction > 16)
            {
                throw new ArgumentException("1 for full res 2 for half-res");
            }

            IntPtr pnatlPtr = IntPtr.Zero;
            IntPtr _Result  = Natives.jbWordsInTextlines(dirin, reduction, maxwidth, maxheight, thresh, weight, out pnatlPtr, firstpage, npages);

            if (pnatlPtr == IntPtr.Zero)
            {
                pnatl = null;
            }
            else
            {
                pnatl = new Numa(pnatlPtr);
            };

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

            return(new JbClasser(_Result));
        }
Пример #28
0
        // readbarcode.c (837, 1)
        // numaQuantizeCrossingsByWidth(nas, binfract, pnaehist, pnaohist, debugflag) as Numa
        // numaQuantizeCrossingsByWidth(NUMA *, l_float32, NUMA **, NUMA **, l_int32) as NUMA *
        ///  <summary>
        /// (1) This first computes the histogram of black and white bar widths,
        /// binned in appropriate units.  There should be well-defined
        /// peaks, each corresponding to a specific width.  The sequence
        /// of barcode widths (namely, the integers from the set {1,2,3,4})
        /// is returned.<para/>
        ///
        /// (2) The optional returned histograms are binned in width units
        /// that are inversely proportional to %binfract.  For example,
        /// if %binfract = 0.25, there are 4.0 bins in the distance of
        /// the width of the narrowest bar.
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/numaQuantizeCrossingsByWidth/*"/>
        ///  <param name="nas">[in] - numa of crossing locations, in pixel units</param>
        ///  <param name="binfract">[in] - histo binsize as a fraction of minsize e.g., 0.25</param>
        ///  <param name="pnaehist">[out][optional] - histo of even (black) bar widths</param>
        ///  <param name="pnaohist">[out][optional] - histo of odd (white) bar widths</param>
        ///  <param name="debugflag">[in] - 1 to generate plots of histograms of bar widths</param>
        ///   <returns>nad sequence of widths, in unit sizes, or NULL on error</returns>
        public static Numa numaQuantizeCrossingsByWidth(
            Numa nas,
            Single binfract,
            out Numa pnaehist,
            out Numa pnaohist,
            int debugflag)
        {
            if (nas == null)
            {
                throw new ArgumentNullException("nas cannot be Nothing");
            }

            IntPtr pnaehistPtr = IntPtr.Zero;
            IntPtr pnaohistPtr = IntPtr.Zero;
            IntPtr _Result     = Natives.numaQuantizeCrossingsByWidth(nas.Pointer, binfract, out pnaehistPtr, out pnaohistPtr, debugflag);

            if (pnaehistPtr == IntPtr.Zero)
            {
                pnaehist = null;
            }
            else
            {
                pnaehist = new Numa(pnaehistPtr);
            };
            if (pnaohistPtr == IntPtr.Zero)
            {
                pnaohist = null;
            }
            else
            {
                pnaohist = new Numa(pnaohistPtr);
            };

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

            return(new Numa(_Result));
        }
Пример #29
0
        // ptabasic.c (149, 1)
        // ptaCreateFromNuma(nax, nay) as Pta
        // ptaCreateFromNuma(NUMA *, NUMA *) as PTA *
        ///  <summary>
        /// ptaCreateFromNuma()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/ptaCreateFromNuma/*"/>
        ///  <param name="nax">[in][optional] - can be null</param>
        ///  <param name="nay">[in] - </param>
        ///   <returns>pta, or NULL on error.</returns>
        public static Pta ptaCreateFromNuma(
            Numa nax,
            Numa nay)
        {
            if (nay == null)
            {
                throw new ArgumentNullException("nay cannot be Nothing");
            }

            IntPtr naxPtr = IntPtr.Zero;    if (nax != null)
            {
                naxPtr = nax.Pointer;
            }
            IntPtr _Result = Natives.ptaCreateFromNuma(naxPtr, nay.Pointer);

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

            return(new Pta(_Result));
        }
Пример #30
0
        // jbclass.c (1659, 1)
        // jbAccumulateComposites(pixaa, pna, pptat) as Pixa
        // jbAccumulateComposites(PIXAA *, NUMA **, PTA **) as PIXA *
        ///  <summary>
        /// jbAccumulateComposites()
        ///  </summary>
        ///  <remarks>
        ///  </remarks>
        ///  <include file="..\CHM_Help\IncludeComments.xml" path="Comments/jbAccumulateComposites/*"/>
        ///  <param name="pixaa">[in] - one pixa for each class</param>
        ///  <param name="pptat">[out] - centroids of bordered composites</param>
        ///   <returns>pixad accumulated sum of samples in each class, or NULL on error</returns>
        public static Pixa jbAccumulateComposites(
            Pixaa pixaa,
            Numa pna,
            out Pta pptat)
        {
            if (pixaa == null)
            {
                throw new ArgumentNullException("pixaa cannot be Nothing");
            }

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

            IntPtr pnaPtr = IntPtr.Zero;    if (pna != null)
            {
                pnaPtr = pna.Pointer;
            }
            IntPtr pptatPtr = IntPtr.Zero;
            IntPtr _Result  = Natives.jbAccumulateComposites(pixaa.Pointer, pnaPtr, out pptatPtr);

            if (pptatPtr == IntPtr.Zero)
            {
                pptat = null;
            }
            else
            {
                pptat = new Pta(pptatPtr);
            };

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

            return(new Pixa(_Result));
        }