// pageseg.c (548, 1) // pixFindPageForeground(pixs, threshold, mindist, erasedist, showmorph, pixac) as Box // pixFindPageForeground(PIX *, l_int32, l_int32, l_int32, l_int32, PIXAC *) as BOX * /// <summary> /// (1) This doesn't simply crop to the fg. It attempts to remove /// pixel noise and junk at the edge of the image before cropping. /// The input %threshold is used if pixs is not 1 bpp.<para/> /// /// (2) This is not intended to work on small thumbnails. The /// dimensions of pixs must be at least MinWidth x MinHeight.<para/> /// /// (3) Debug: set showmorph to display the intermediate image in /// the morphological operations on this page.<para/> /// /// (4) Debug: to get pdf output of results when called repeatedly, /// call with an existing pixac, which will add an image of this page, /// with the fg outlined. If no foreground is found, there is /// no output for this page image. /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/pixFindPageForeground/*"/> /// <param name="pixs">[in] - full resolution (any type or depth</param> /// <param name="threshold">[in] - for binarization typically about 128</param> /// <param name="mindist">[in] - min distance of text from border to allow cleaning near border at 2x reduction, this should be larger than 50 typically about 70</param> /// <param name="erasedist">[in] - when conditions are satisfied, erase anything within this distance of the edge typically 20-30 at 2x reduction</param> /// <param name="showmorph">[in] - debug: set to a negative integer to show steps in generating masks this is typically used for debugging region extraction</param> /// <param name="pixac">[in] - debug: allocate outside and pass this in to accumulate results of each call to this function, which can be displayed in a mosaic or a pdf.</param> /// <returns>box region including foreground, with some pixel noise removed, or NULL if not found</returns> public static Box pixFindPageForeground( Pix pixs, int threshold, int mindist, int erasedist, int showmorph, PixaComp pixac) { if (pixs == null) { throw new ArgumentNullException("pixs cannot be Nothing"); } if (pixac == null) { throw new ArgumentNullException("pixac cannot be Nothing"); } IntPtr _Result = Natives.pixFindPageForeground(pixs.Pointer, threshold, mindist, erasedist, showmorph, pixac.Pointer); if (_Result == IntPtr.Zero) { return(null); } return(new Box(_Result)); }
// dewarp1.c (661, 1) // dewarpaCreateFromPixacomp(pixac, useboth, sampling, minlines, maxdist) as L_Dewarpa // dewarpaCreateFromPixacomp(PIXAC *, l_int32, l_int32, l_int32, l_int32) as L_DEWARPA * /// <summary> /// (1) The returned dewa has disparity arrays calculated and /// is ready for serialization or for use in dewarping.<para/> /// /// (2) The sampling, minlines and maxdist parameters are /// applied to all images. See notes in dewarpaCreate() for details.<para/> /// /// (3) The pixac is full. Placeholders, if any, are w=h=d=1 images, /// and the real input images are 1 bpp at full resolution. /// They are assumed to be cropped to the actual page regions, /// and may be arbitrarily sparse in the array.<para/> /// /// (4) The output dewarpa is indexed by the page number. /// The offset in the pixac gives the mapping between the /// array index in the pixac and the page number.<para/> /// /// (5) This adds the ref page models.<para/> /// /// (6) This can be used to make models for any desired set of pages. /// The direct models are only made for pages with images in /// the pixacomp the ref models are made for pages of the /// same parity within %maxdist of the nearest direct model. /// </summary> /// <remarks> /// </remarks> /// <include file="..\CHM_Help\IncludeComments.xml" path="Comments/dewarpaCreateFromPixacomp/*"/> /// <param name="pixac">[in] - pixacomp of G4, 1 bpp images with 1x1x1 placeholders</param> /// <param name="useboth">[in] - 0 for only vert disparity 1 for both vert and horiz</param> /// <param name="sampling">[in] - use -1 or 0 for default value otherwise minimum of 5</param> /// <param name="minlines">[in] - minimum number of lines to accept e.g., 10</param> /// <param name="maxdist">[in] - for locating reference disparity use -1 for default</param> /// <returns>dewa or NULL on error</returns> public static L_Dewarpa dewarpaCreateFromPixacomp( PixaComp pixac, int useboth, int sampling, int minlines, int maxdist) { if (pixac == null) { throw new ArgumentNullException("pixac cannot be Nothing"); } IntPtr _Result = Natives.dewarpaCreateFromPixacomp(pixac.Pointer, useboth, sampling, minlines, maxdist); if (_Result == IntPtr.Zero) { return(null); } return(new L_Dewarpa(_Result)); }