Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, January 10, 2007 9:10:40 PM(UTC)
Raymond Lee

Groups: Registered
Posts: 30


Hi,

I got this formula from the lead support forum but it is not working?
Is it because the image I used has some noise on it?

public bool IsBlankImage(IRasterImage image)
{
    if (image.CalculateRegionArea() / (image.ImageWidth * image.ImageHeight) < 0.005)
        return true;
    else
        return false;
}

My colleague suggests me to use file size to check the blank page,
Is there any good alternatives?

I attached the test image for your reference.

Thanks for your kind attention,
Raymond

File Attachment(s):
1.2.zip (1kb) downloaded 22 time(s).
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Sunday, January 14, 2007 6:21:02 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 367

Was thanked: 1 time(s) in 1 post(s)

Raymond,
In this image's case, the ratio of black pixels to total pixels is actually 0.0001834 because it has 719 black pixels out of  3919168.
This means if your code is calculating the ratio correctly, it will be much less than the threshold you specify in your code, which is 0.005

If you can't find the source of the error, put your blank detection code in a small test project (not your full application) and either post it here or send it to support@leadtools.com and we will check it for you.

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#3 Posted : Monday, January 15, 2007 7:53:50 PM(UTC)
Raymond Lee

Groups: Registered
Posts: 30


Hi,

I attach a simple project, the TIF image and output result from the project.
I suspect that the image was reversed in black and white, so that the no. of black pixels turned out to be 3919168 instead of 719. (Just like a negative film photo, why I said that because in my early scan testing with leadtools, I figured out that the black and white color of TIF file saved was reverse in the first save of rastercodecs.save(). If the image was loaded and saved again, the black and white color became correct)

These are the capability settings I did with a program that generate the TIF image:

   // Pixel(Type - Black & White)
    twCap.Information.Type = TwainCapabilityType.ImagePixelType;
    twCap.OneValue.ItemType = TwainItemType.Uint16;
    twCap.OneValue.Value = TwainCapabilityValue.PixelTypeBw;
    this.twainSession.SetCapability(twCap, TwainSetCapabilityMode.Set);

    // Set Pixel Type first
    // Bit Depth - 1 Bit (Bitonal)
    twCap.Information.Type = TwainCapabilityType.ImageBitDepth;
    twCap.OneValue.ItemType = TwainItemType.Uint16;
    twCap.OneValue.Value = 1;
    this.twainSession.SetCapability(twCap, TwainSetCapabilityMode.Set);


Please kindly help!

Thanks,
Raymond



File Attachment(s):
BlankTest.zip (505kb) downloaded 24 time(s).
 
#4 Posted : Wednesday, January 17, 2007 10:10:05 AM(UTC)

Amin  
Amin

Groups: Manager, Tech Support
Posts: 367

Was thanked: 1 time(s) in 1 post(s)

The code does not count the black pixels. That's why it doesn't calculate the ratio correctly.
To correct this, I added the following 2 lines to the beginning of the IsBlankImage() function before calling CalculateRegionArea():

Leadtools.RasterColor black = new Leadtools.RasterColor(0, 0, 0);     // Black color has RGB(0,0,0)
image.AddColorToRegion(black, Leadtools.RasterRegionCombineMode.Set); // Define a region of black pixels


Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
LEAD Logo
 
#5 Posted : Thursday, April 26, 2007 3:40:42 AM(UTC)
Nagarjuna

Groups: Registered
Posts: 7


Dear Support,

      I have tested with the sugession given above, i can able to recognise blank page, if there is any text on the document even it dispalys blank page, iam attaching the code, i want the result blank if the document is blank else not blank, i have the tif file in the appication path, please work with it

 

Regards

Nagarjuna

File Attachment(s):
BlankPage.zip (740kb) downloaded 24 time(s).
 
#6 Posted : Monday, April 30, 2007 6:04:05 AM(UTC)

Otis  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

Your IsBlankImage function is not correct. Since you are dividing two integers values, the compiler is giving you back an integer and you need a float. Change your code to look like below.

if ((float)image.CalculateRegionArea() / (image.ImageWidth * image.ImageHeight) < 0.005)

 
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.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.179 seconds.