Skip to main content

Detecting blank page

8 replies [Last post]
niravpurohit
Offline
Joined: 2008-09-10
Points: 0

Currently I am working on web scanning project in which I have to get the documents from the scanner and save them in form of TIFF files (either single page or multi-page). As an enhancement to this project, I have to detect and eliminate blank pages. Can anybody please tell me how to detect blank pages/images??

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Brian Burkhalter

Compute the extrema and if they are equal or almost so it's probably a
blank.

On Sep 10, 2008, at 5:49 AM, jai-interest@javadesktop.org wrote:

> Currently I am working on web scanning project in which I have to
> get the documents from the scanner and save them in form of TIFF
> files (either single page or multi-page). As an enhancement to this
> project, I have to detect and eliminate blank pages. Can anybody
> please tell me how to detect blank pages/images??
> [Message sent by forum member 'niravpurohit' (niravpurohit)]
>
> http://forums.java.net/jive/thread.jspa?messageID=298312
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
> For additional commands, e-mail: interest-help@jai.dev.java.net
>

Brian

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Fabrizio Giudici

Brian Burkhalter wrote:
> Compute the extrema and if they are equal or almost so it's probably a
> blank.

Maybe you could also run a median filter or such before computing the
extrema, just to remove dust spots and noise (otherwise, a single black
dust spot would keep the extrema too separated).

--
f.g.

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Brian Burkhalter

Good idea.

On Sep 10, 2008, at 7:00 AM, Fabrizio Giudici wrote:

> Maybe you could also run a median filter or such before computing
> the extrema, just to remove dust spots and noise (otherwise, a
> single black dust spot would keep the extrema too separated).

Brian

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

niravpurohit
Offline
Joined: 2008-09-10
Points: 0

thanks for the reply.

the scanned images contains noise. hence even plain scanned white page gives min extrema 0 and max extrema 1. so it becomes necessary to remove the noise as per Fabrizio. i tried using MedianFilterDescriptor but got out of memory exception. i tried searching for its example but didn't succeed. can u please provide more details on how to implement the filter.

niravpurohit
Offline
Joined: 2008-09-10
Points: 0

i found that the MedianFilter was not much effective. hence i used MaximumFilter. that reduces the noise to more extent as compared to MedianFilter. However, we will have to arrive to a threshold value to conclude whether the image is blank or not.

niravpurohit
Offline
Joined: 2008-09-10
Points: 0

I have found the solution to the problem.

Blank images will have highly uniform pixel values throughout the whole image. To measure the degree of uniformity (or variability), I came up with the function that calculates the standard deviation of all pixel values. An image is determined to be blank if the standard deviation falls below a certain threshold.

briangriffin
Offline
Joined: 2008-09-19
Points: 0

niravpurohit,

i'm working on a project that needs to do exactly the same : detecting blank pages that might have with noise on them, also because since they are scanned in.

Would you please be so kind to share your code here ?
Thanks.

niravpurohit
Offline
Joined: 2008-09-10
Points: 0

hi briangriffin,

The main idea is to find the standard deviation and based on it's value you can take the decision whether the image is blank or not. Below is the one possible way to find the standard deviation:

int[] pixels = new int[w * h];
PixelGrabber pg = new PixelGrabber(bi, x, y, w, h, pixels, 0, w);

pg.grabPixels();

for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
count++;

int pixel = pixels[j * w + i];

int alpha = (pixel >> 24) & 0xff;
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel) & 0xff;

int pixelValue = new Color(red, green,blue,0).getRGB();
total += pixelValue;
double avg = total /count;
totalVariance += Math.pow(pixelValue - avg, 2);
stdDev = Math.sqrt(totalVariance / count);

}
}

if(stdDev < 100000)
{
System.out.println("Image is BLANK");
}
else
{
System.out.println("Image is NOT BLANK");
}

n-joy...