This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Thursday, June 23, 2005 2:12:58 PM(UTC)
Groups: Registered
Posts: 2
Do you have an example of how I can detect blank pages using DOTNET? I have reviewed the forum posts and read the documentation however it seems to indicate that the GetRegion only gets the number of pixels in a region and not necessairly the number of black pixels. How can I get a percentage of just the number of black pixels in a Bitmap object without hard counting them? Thanks
#2
Posted
:
Friday, June 24, 2005 7:08:10 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
The attached VB.NET sample demonstrates how to detect a blank page which may be useful in scanning applications. It basically creates a region of white pixels and counts how many pixels are not in that region. If that number is less than a certain percentage of the total number of pixels, we can consider the page blank.
#3
Posted
:
Monday, March 27, 2006 5:55:26 AM(UTC)
Groups: Registered
Posts: 7
Hi. I am currently using the code in this demo to do white/black page detection. We are using this to split scanned in documents, based on where the white pages are.
It works great except for one thing. Every time (or two) that i run .AddColorRgbRangeToRegion, my service seems to suck up about an extra meg of Ram. This service is potentially processing many documents a minute, that are all multi paged. This quickly adds up to my service hogging as much ram as is available.
I have used .MakeRegionEmpty() to try and regain some of this memory, but to no avail. I also notice that if i run the sample application over and over, i see this same ramping of memory usage.
Is there any way to regain the memory within the code, as shutting down the service for each document isnt really an option.
#4
Posted
:
Wednesday, March 29, 2006 4:05:40 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Make sure that if you are freeing any images or regions tht you call GC.Collect and GC.WaitForPendingFinalizers to ensure that the garbage collector has freed all objects marked for deletion.
#5
Posted
:
Tuesday, April 4, 2006 9:16:18 AM(UTC)
Groups: Registered
Posts: 7
I think i have already tried what you have suggested, yet i cannot seem to get the memory back. Here is the code :
Try
If f.Exists(Me.strSrcFile) Then
lRaster = codecs.Load(strSrcFile)
lRasterView.Image = lRaster
For i = 1 To lRasterView.Image.PageCount
With lRasterView.Image
.Page = i
.AddColorRgbRangeToRegion(lowerWhite, upperWhite, RasterRegionCombineMode.SetNot)
If .CalculateRegionArea / (.ImageWidth * .ImageHeight) < thisThresh Then
'white page, add to splitPages arrays here
End If
.MakeRegionEmpty()
End With
GC.Collect()
GC.WaitForPendingFinalizers()
Next
End If
Return alSplitPages
Catch ex As Exception
Throw
Finally
upperWhite = Nothing
lowerWhite = Nothing
lRasterView.Image.RemoveAllPages()
lRasterView.Image.Dispose()
lRasterView.Image = Nothing
If lRaster.PageCount > 0 Then lRaster.RemoveAllPages()
codecs = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
End Try
For each page of the raster image, after i have calculated the area, i run a .MakeRegionEmpty(which i beleive frees the region, as you mentioned), as well as some garbage collection. On top of this, i am doing garbage collection in the Finally, and disposing of the Image, and the image viewer.
What am i missing?
#6
Posted
:
Tuesday, April 11, 2006 5:02:34 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
I used the attached application to test this which basically just runs the same image 1000 times in a loop. On my end, the memory pretty much remains the same throughout the entire process. What are you using to monitor the memory? Also, have you tried updating to the latest dll's?
#7
Posted
:
Thursday, April 13, 2006 5:51:48 AM(UTC)
Groups: Registered
Posts: 7
I tried running the example code you sent. It has the same memory
leak issue. It processed the image 136 times then ran out of
virtual memory space and I shut it down. Windows Task Manager
showed that it was using over 350 Mb of memory. I must need to
update my dll's as you mentioned. Where do I go to get these?
Thanks.
#8
Posted
:
Monday, April 17, 2006 3:37:53 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
It appears you have a license for the product so you should be able to log into our support site and download the most recent patch.
#9
Posted
:
Thursday, April 26, 2007 2:41:05 AM(UTC)
Groups: Registered
Posts: 7
Dear Support,
I have Downloaded the sample and try to lad a document
i t displays an error
An unhandled exception of type 'Leadtools.RasterException' occurred in leadtools.dll
Additional information: Error in the application
How can i handle
Regards
Nagarjuna
#10
Posted
:
Monday, April 30, 2007 5:15:14 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
When does this error occur? Also, make sure you are compiling the project with the latest dll's.
#11
Posted
:
Tuesday, April 29, 2008 10:30:56 PM(UTC)
Groups: Registered
Posts: 4
Since the original question and answer is already a couple of years old, i would like to know, is the above attached example by Otis still the way to go for detecting blank pages?
Because the LEADTOOLS Document Imaging SDK v.15 feature list specifies a "Blank Page Detector" function (http://www.leadtools.com/SDK/Image%20Processing/functions/Blank%20Page%20Detector/)
And even though Otis' example is pretty straight-forward, because this functionality is listed as a separate feature, i expected there to be a method in the SDK which takes a page and handles all this for me (the calculation and evaluating whether the page is blank), perhaps parameterized with a few options to tweak the detection :)
#12
Posted
:
Wednesday, April 30, 2008 12:55:56 AM(UTC)
Groups: Registered, Tech Support
Posts: 1,326
Was thanked: 1 time(s) in 1 post(s)
Hello,
In LEADTOOLS v15, you can detect whether an image is a blank page by using the BlankPageDetectorCommand Class.
For more information about the BlankPageDetectorCommand Class, please read the following topic in the LEADTOOLS .Net documentation:
- BlankPageDetectorCommand Class.
Thanks,
Maen Badwan
LEADTOOLS Technical Support
#13
Posted
:
Sunday, May 4, 2008 11:13:41 PM(UTC)
Groups: Registered
Posts: 4
Thank you, exactly what i was looking for.
Can't believe i didn't find it myself in the documentation, just searching for 'blank' returns what i was looking for..:$
#14
Posted
:
Friday, September 26, 2008 6:25:42 AM(UTC)
Groups: Registered, Tech Support
Posts: 207
Was thanked: 3 time(s) in 3 post(s)
I have created a small demo in Visual Studio 6.0 using our C DLLS that simply provides a UI to the L_BlankPageDetectorBitmap. It allows you to load an image (specifying a page too) then setting the options of the function (minus the user margins) and seeing what the return values are for the function.
This should help in determining what settings to use for different types of images.
Travis Montgomery
Senior Sales Engineer
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.