isBlank yielding weird results

Discussions about image processing and document imaging.
Post Reply
blewis
Posts: 38
Joined: Wed May 18, 2011 4:28 am

isBlank yielding weird results

Post by blewis » Wed Aug 15, 2012 11:34 pm

I was getting some unanticpiated results from the isBlank function from a larger console app that I had written, so I decided to do some testing using a very simple script (included below). The isBlank function was returning "true" for an image that was not blank and that I wanted to return not blank. I figured I just needed to adjust "Confidence" percentage to ensure that everything was fine. In my testing I have come realize that no matter what value I put into that parameter, isBlank still returns true. This is screwing with my program and I need to figure out what is going on.

To do some sanity checks, I used the CountColor function to do some of my own math. According to that math, the image is 99.50097 percent white. So if I set the Confidence to 99.6, isBlank should return "False" correct? Or am I misunderstanding the use of that parameter?

My simple test script code is below and the image I am testing is attached. Using ASP.net 4.0 and GdPicture 8.5.0.8.

Code: Select all

        Dim oGdPictureImaging As New GdPictureImaging
        Dim oLicenseManager As New LicenseManager
        oLicenseManager.RegisterKEY("XXXX")

        ' Process command line input(s)
        Dim imageFile As String = My.Application.CommandLineArgs(0).Trim()
        Dim isBlankPercent As Single = Single.Parse(My.Application.CommandLineArgs(1).Trim())

        ' Open the image
        Console.WriteLine("Opening Image...")
        Dim image_ID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile(imageFile)

        Console.WriteLine("Image Opened as ID: " & image_ID.ToString())

        ' Count the number of pixels in the whole image
        Dim pixelCount As Integer = oGdPictureImaging.GetHeight(image_ID) * oGdPictureImaging.GetWidth(image_ID)
        Console.WriteLine("Total Number of Pixels: " & pixelCount.ToString())

        ' Total Number of white pixels
        Dim whiteCount As Integer = oGdPictureImaging.CountColor(image_ID, oGdPictureImaging.ARGB(255, 255, 255))
        Console.WriteLine("White Pixel Count: " & whiteCount.ToString())
        Console.WriteLine("Percent White Pixels: " & ((whiteCount / pixelCount) * 100).ToString())

        If oGdPictureImaging.IsBlank(image_ID, isBlankPercent) Then
            Console.WriteLine("Image is Blank.")
        Else
            Console.WriteLine("Image is Non-blank.")
        End If

        Console.WriteLine("Done.")
Attachments
20120731010006_01077830_9_9_000012.png
20120731010006_01077830_9_9_000012.png (2.97 KiB) Viewed 9173 times

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: isBlank yielding weird results

Post by Loïc » Sun Aug 19, 2012 8:05 pm

Hello,
To do some sanity checks, I used the CountColor function to do some of my own math. According to that math, the image is 99.50097 percent white. So if I set the Confidence to 99.6, isBlank should return "False" correct? Or am I misunderstanding the use of that parameter?
No this is not correct. The isBlank method do not simply count black or white pixel. Such approach usually results in very bad result on high resolution image. The algorithm is more sophisticated and is more a layout analysis algorithm than a linear algorithm checking the image color histogram.

Hope this clarify!

Kind regards,

Loïc

blewis
Posts: 38
Joined: Wed May 18, 2011 4:28 am

Re: isBlank yielding weird results

Post by blewis » Mon Aug 20, 2012 7:24 pm

I understand this, but I guess my question is why this image is considered blank, no matter what confidence number I provide? Clearly the image is not blank, and if the Confidence value is supposed to adjust the sensitivity threshold, then why will no number provide a blank = true?

Thanks,
Bryan

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: isBlank yielding weird results

Post by SamiKharma » Wed Aug 22, 2012 9:22 am

Hi,

For all purposes this image is blank because the percentage which you have investigated yourself, is bigger than the noise percentage in most images, even blank ones.

Best Regards,
Sami

Username
Posts: 16
Joined: Wed Jul 18, 2012 12:11 am

Re: isBlank yielding weird results

Post by Username » Sun Aug 26, 2012 3:36 am

I don't know how sophisticated IsBlank() is, but what about these two images in attached file - for one of them IsBlank() returns "true", for other one returns "false". This is the reason we cannot use IsBlank() at all... GdPicture 9.
Attachments
BlankErrors.zip
Contains 2 .tif images containing a lot of text.
(402.23 KiB) Downloaded 390 times

Username
Posts: 16
Joined: Wed Jul 18, 2012 12:11 am

Re: isBlank yielding weird results

Post by Username » Sun Aug 26, 2012 3:46 am

And this is a fast preview of attached "BlankErrors.zip" in my previous post.
Attachments
IsBlankError.png

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: isBlank yielding weird results

Post by Loïc » Mon Aug 27, 2012 4:26 pm

This problem is fixed for the next minor release.

Username
Posts: 16
Joined: Wed Jul 18, 2012 12:11 am

Re: isBlank yielding weird results

Post by Username » Thu Sep 06, 2012 4:37 pm

I have tried newest GdPicture version 9.1.0.3 and it still reports "false positives" for IsBlank(). Attached file contains 17 pages. Some of them are really blank but most are not. Is this normal behavior ?
Attachments
AllBlank.zip
(271.07 KiB) Downloaded 392 times

Username
Posts: 16
Joined: Wed Jul 18, 2012 12:11 am

Re: isBlank yielding weird results

Post by Username » Thu Sep 06, 2012 4:40 pm

And this is the preview of one of the pages in previously attached file for which IsBlank() returns true.
Attachments
Blank.png

sulfaroj
Posts: 9
Joined: Tue Jun 19, 2012 5:50 am

Re: isBlank yielding weird results

Post by sulfaroj » Tue Oct 30, 2012 5:51 am

If the confidence level is not passed in the isBlank function, what does it use as a default. I tested the image attached and if I only use isBlank with no confidence it does report as blank. If I try 99.9 it does not report blank.

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: isBlank yielding weird results

Post by SamiKharma » Tue Oct 30, 2012 10:57 am

Hi,

We pass 99.5 internally.

The problem with your image is that it is really small taken at high dpi, meaning that the text that you see is pretty much represented by a very small amount of pixels, nearing or even less than the normal amount of noise at that dpi level.

Best,
Sami

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest