| We need to remove blank pages that are scanned when the scanner is in duplex mode. Also, all the files we scan are multi-page. How do I do this using the functions in VisImage for PowerBuilder? |
| User Opinions |
|
No users have voted.
|
|
Thank you for rating this answer.
|
We have a morphological API in our C/C++ toolkit that is not published in our Power Builder toolkit. Since VisImage for Power Builder uses the DLL, you can create an External API call to the function for detection of a blank page. The function to use is:
Prototype int vimg_countcolor(VIMG_HNDL imghandle, WORD row, WORD startcol, WORD endcol, int color);
Description This function is for use with black and white image only. Valid color values are 1 - WHITE and 0 - BLACK. This function is used to count the number of white or black pixels found in an image row starting at the specified startcol column and ending at the specified endcol column. This function is useful when designing your own custom OMR based functions and it is required to do a fast pixel count of a subarea of an image row. Other uses include determining if the page in question is blank.
Parameter Descripion VIMG_HNDL: A valid VisImage Image handle WORD row: The image row number this function is to act on. All image rows begin at 0 and are valid thru the image height -1 WORD startcol: The image column this function is to begin on. All image cols begin at 0 and are valid thru the image width - 1 WORD endcol: The image column this function is to end on. All image cols begin at 0 and are valid thru the image width -1 int: The pixel color this function is to count
You would declare the above function in the PowerBuilder External Function painter as: private FUNCTION long vimg_countcolor(unsigned long imghandle, short row, short startcol, short endcol) library "visimg32.dll".
The Visimage for PowerBuilder UserObject has a function called fu_get_imghandle. With the returned unsigned long value you can fill out the first parameter VIMG_HNDL imghandle.
To detect a blank page, calculate the total number of pixels in the page. Then use the above function to return the number of black pixels. A little math will derive a ratio of black to white pixels. Set the threshold at say 10%. When the ratio is less than 10%, you can assume the page is blank and throw it away.
With regards to multi-page files, you would need to make each page its own file. Scan each file to its own folder whereby those detected as blank are discarded. When the batch is complete, iterate the files in the folder and create your multi-page file.
|
| Visitor Comments |
|
No visitor comments posted. Post a comment
|
| Attachments |
|
No attachments were found.
|