# Patent

## Title
Background noise removal for a low-cost digital color copier

## Abstract

A method of generating an M-bit grayscale image from an N-bit grayscale image, where 1<M<N, includes the steps of: for each pixel in the N-bit image, determining a threshold, based on the values of neighboring pixels, for generating the most significant bit (MSB) of the M-bit image, and determining thresholds, based on the threshold determined in step i) and the values of surrounding pixels, for each successive less significant bit(s) (LSB) of the M-bit image. The thresholds are used to quantize the pixels in the N-bit image to produce the M-bit image. The resulting M-bit image can be displayed on a multilevel display device for good readability, and the most significant bit of the M-bit image can be archived and printed on a binary printer thereby minimizing long term storage requirements.

## Background
The disclosure in the appendix of this patent document contains material to which a claim of copyright protection is made. The copyright owner has no objection to the facsimile reproduction of any one of the patent documents or the patent disclosure as it appears in the U.S. Patent and Trademark Office patent file or records, but reserves all other rights whatsoever.

The present invention relates to the field of digital image processing and more particularly to processing of document images to reduce the amount of data used to represent the image.

Document images which are scanned using 8 bits per pixel require large amounts of storage space and expensive hardware for processing. Scanned documents are currently quantized using one bit per pixel, which reduces the hardware and processing requirements, but degrades the image quality, specifically when these images are displayed on display devices which support 4-8 bits per pixel

One known method of quantizing document images in a single-bit down is to use one-bit adaptive thresholding as disclosed in U.S. Pat. No. 5,583,659, entitled "A Multiwindowing Technique For Thresholding An Image Using Local Image Properties," issued Dec. 10, 1996, to Y. Lee, J. Basile, and P. Rudak. This approach limits the display to one bit. The current method of quantizing document images in a multi-bit domain employs fixed threshold points for each gray value. This approach results in poor image quality when a small number of bits per pixel is used to reduce data storage and processing requirements. There is a need therefore for an improved method of quantizing document images to optimize image quality when displayed on a multilevel display device while minimizing data storage requirements.

The present invention is directed to overcoming one or more of the problems set forth above. Briefly summarized, according to one aspect of the present invention, a method of generating an M-bit grayscale image from an N-bit grayscale image, where 1<M<N, includes the steps of: for each pixel in the N-bit image, determining a threshold, based on the values of neighboring pixels, for generating the most significant bit (MSB) of the M-bit image, and determining thresholds, based on the threshold determined in step i) and the values of surrounding pixels, for each successive less significant bit(s) (LSB) of the M-bit image. The thresholds are used to quantize the pixels in the N-bit image to produce the M-bit image. The resulting M-bit image can be displayed on a multilevel display device for good readability, and the most significant bit of the M-bit image can be archived and printed on a binary printer thereby minimizing long term storage requirements.

The proposed method quantizes the scanned images using two (or more) bits per pixel so that their display can be improved, while maintaining low requirements on storage and processing hardware. Additionally, the improvements in image quality can significantly improve character recognition accuracy especially for broken or partially formed characters.

Adaptive quantization of scanned images using two (or more) bits per pixel provides an image representation which is similar to the original image, while maintaining low storage and processing requirements. The invention provides:

FIG. 1 is a schematic diagram of a document imaging system employing the method of the present invention;

FIG. 2 is a flow chart illustrating the method of generating a quantized image from a grayscale image according to the present invention;

FIG. 3 is a graph useful in describing the method of the present invention, showing one line of a grayscale image and the gradient sum based on a local window;

FIG. 4 is a graph useful in describing the method of the present invention, showing one line of a grayscale image and the corresponding quantization levels;

FIG. 5 is a graph useful in describing the method of the present invention, showing one line of a grayscale image and the resulting 2-bit quantization;

FIG. 6 is a schematic diagram illustrating a preferred file structure of a document image resulting from 2-bit version of the present invention; and

FIG. 7 is a schematic diagram illustrating the decompression and display of the quantized image according to the present invention.

To facilitate understanding, identical reference numerals have been used, where possible, to designate identical elements that are common to the figures.

The present invention is directed to a method of reducing the number of bits per pixel in a grayscale document image while enhancing the contrast of the characters and lines in the document Referring to FIG. 1, a document imaging system employing the method of the present invention is shown. The system, generally designated 10, includes a scanner 12 for scanning a document 14 to generate an N-bit (e.g. 8-bit) grayscale image. The scanner 12 includes an adaptive grayscale processor 16 for converting the N-bit grayscale image to an M-bit grayscale image (e.g. 2-bit), where M<N. For the purposes of the following discussion, an N=8-bit to an M=2-bit image conversion will be presumed. The scanner 12 is connected to a personal computer (PC) 18 that functions as a host to scanner 12. The PC 18 includes a display, such as a CRT 20 and an input device, such as keyboard 22. Alternatively, the adaptive grayscale processor 16 of the present invention may be located in the PC 18.

The PC 18 is connected to a network 24 that includes a net server 26. The network 24 provides access to a display monitor 28, a binary printer 30 such as a laser or inkjet printer, and an archival storage 32 such as a CD writer. According to the present invention, the 2-bit image is used for display on the monitors 20 or 28, and the most significant bit of the 2-bit image is used for printing the image on the binary printer 30 and storing in archival storage 32. Alternatively, the 2-bit image may be stored in archival storage 32.

According to the present invention Quantization is performed adaptively based on whether or not the objective pixel is near an image edge. If the pixel is near an image edge, the quantization levels are determined based on the statistics of a local region surrounding the pixel. If the pixel is not near an image edge, the method employs fixed quantization levels. The quantized images display more information than images with one bit per pixel used by current approaches. The most significant bit (MSB) of the quantized (2-bit) image is equivalent to a binary image using adaptive thresholding. This image can be sent for printing, or can be used by current OCR software that require one bit per pixel. When the MSB and LSB binary images are combined, the resulting 2-bit per pixel representation enhances low contrast characters, reduces the jaggedness and breaks around character edges, and makes the background graylevel closer to the original. The method of the present invention allows the user to determine the level of adaptivity by adjusting a gradient threshold parameter GT. This parameter allows a system to be optimized for its intended application-viewing on a CRT, OCR, printing, etc.

Referring to FIG. 2, the method of generating a quantized image from a grayscale image according to the present invention will now be described in detail. First, a gradient sum in a 5.times.5 window centered at pixel (i,j) is calculated (34) as follows. to be quantized; j-1);

FIG. 3 shows the gradient sum 36 plotted with the intensity level 38 for one line of a document image.

Returning to FIG. 2, next, a test is made (40) to determine whether the image pixel currently being processed is near an edge in the image. The test (40) is performed as follows: 7.times.7 window centered on pixel (i,j) as follows:

and compute quantization levels uniformly distributed between Imax and Imin (46) as follows:

The quantization levels T1, T2, and T3, shown by lines 48, 50 and 52 respectively, computed for the one line 38 of grayscale image are shown in FIG. 4, and where the fixed quantization levels have been set to T1=50, T2=100, and T3=150.

Quantization (54) of the gray level image pixel is done as follows:

and

The results of the quantization step (54) for the one line 38 of a grayscale image are shown in FIG. 5, where the four level binary results are shown by diamonds 55.

Finally the 2-bit binary image is stored (56) and optionally compressed (58) using a lossless compression technique such as group 3, group 4 or JBIG compression. Referring to FIG. 6, the compressed 2-bit image is preferably stored as two 1-bit image files 60 and 62 representing the most significant bit (MSB) and least significant bit (LSB) of the image respectively. In this format, the most significant bit may be recalled and displayed on a binary output device independently of the least significant bit.

Referring to FIG. 7, when the image is to be displayed, the compressed image file is decompressed (64). For display on a multilevel display device, such a CRT, the two one-bit files are merged (66) and supplied to a look-up table 68 associated with the multilevel display 28. The look-up table 68 converts the two-bit image values to values appropriate for display on the particular display device 28, as is well known in the art. For printing on the binary printer 30, only the most significant bit of the image is sent to the printer 30.

A computer program written in the C programming language for performing an 8-bit to 2-bit quantization according to the present invention is included in Appendix A.

The invention has been described with reference to a preferred embodiment. However, it will be appreciated that variations and modifications can be effected by a person of ordinary skill in the art without departing from the scope of the invention. For example, although the invention has been disclosed and described with reference to a quantization from 8 bits to 2 bits, it will be apparent to one of ordinary skill in the art that the method of the present invention may be employed to quantize an image from N bits to M bits where M<N.

/** Fast 2 bit Adaptive Threshold : Code by Andreas Savakis **/

/* This program reads image lines and extracts 7.times.7 block for processing */

#include <stdio.h>

#include <rasterfile.h>

#include <math.h>

#define TRUE 1

#define FALSE 0

typedef unsigned char Byte;

int width,height;

Byte *Irow; /* Current line */

Byte *Irow_p1; /* Current line plus 1*/

Byte *Irow_p2; /* Current line plus 2*/

Byte *Irow_p3; /* Current line plus 3 */

Byte *Irow_m1; /* Current line minus 1*/

Byte *Irow_m2; /* Current line minus 2 */

Byte *Irow_m3; /* Current line minus 3 */

Byte *Iout; /* Current line of tholded image */

typedef struct rasterfile Header;

**********************************************

main ( )

FILE *infile,*outfile;

/* File info */

printf("Image name: ");

scanf("%s",iname);

printf("Binary image name: ");

scanf("%s",oname);

printf("Enter Lo Fixed Thold (0<T<256): ");

scanf("%d",&fixed_lo);

printf("Enter Mid Fixed Thold (0<T<256): ");

scanf("%d",&fixed_mid);

printf("Enter Hi Fixed Thold (0<T<256): ");

scanf("%d",&fixed_hi);

printf("Level of Gradient Adaptivity (0<level<100): ");

scanf("%d",&level);

level *=10;

infile = fopen(iname,"r");

outfile = fopen(oname,"wb");

ReadHeader(infile);

WriteHeader(outfile);

/* Allocate memory */

/* Initialize */

for(j=0; j<width; j++) {

}

/**** LOOP: (i,j) coords determine the center of the 7.times.7 block ****/

for(i=0; i<height; i++) {

/* Move to new 7.times.7 block by shifting 6 lines and reading 1 line */

for(j=0; j<width; j++){

}

fread(Irow_p3,1,width,infile);

/**** Top and Bot Edge Processing ****/

if(i<3 .vertline..vertline.i>=height-3) {

}/* end if */

/***** Vertical main body processing ******/

else {

for (j=0; j<width; j++) {

/*** Left and Right Edge processing ***/

if(j<3 .vertline..vertline.j>=width-3) {

else {

/*** Horizontal main body processing ***/

/* Extract 7.times.7 block from row buffers into f[][]*/

for(k=0; k<7; k++) {

/* end for k */

/* Compute sum of gradients over a 5.times.5 block at the center of the 7.times.7 block */

Gsum=0;

for(p=1; p<=5; p++) {/* (p,q) is the point in f[][] block whose gradient is being computed

for(q=1; q<=5; q++) {

grad_x= f[p-1][q+1]+2*f[p][q+1]+f[p+1][q+1]-f[p-1][q-1]-2*f[p][q-1]-f[p+1][q-1]; grad_y= f[p+1][q-1]+2*f [p+1][q]+f[p+1][q+1]-f [p-1][q-1 ]-2*f[p-1][q]-f [p-1][q+1];

GSum+=grad;

}} /* end for p, q */

/* Normalize sum of gradients */

/* Determine threshold */

/* Fixed threshold */

if(Gsum<level) {

/* Adaptive threshold */

else {

Imax=Imin=f[0 ] [0];

for(p=0; p<7; p++) {

for(q=0; q<7; q++) {

} /* end else */

/* Convert image to binary */

} /* end horizontal main body processing else */

} /* End main */

/**********************************************

## Claims

1. A method of generating an M-bit grayscale image from an N-bit grayscale image, where 1<M<N, comprising the steps of: generating the most significant bit (MSB) of the M-bit image, and the values of surrounding pixels, for each successive less significant bit(s) (LSB) of the M-bit image; and produce the M-bit image.

2. The method claimed in claim 1, wherein M=2, and further comprising the step of storing the most significant bits of the 2-bit image in a first file and the least significant bits of the 2-bit image in a second file.

3. The method claimed in claim 2, further comprising the steps of: multilevel display device; and

4. The method of claim 2, further comprising the step of compressing the first and second files and storing the compressed files.

5. The method of claim 4, further comprising the steps of: merged files on a multilevel display device; and

6. The method of claim 1, wherein M=2 and the step of determining the thresholds for generating the MSB and LSB, comprises the steps of: threshold: and setting the MSB and LSB thresholds to predetermined values; the maximum and minimum pixel values in a second neighborhood and employing the determined maximum and minimum pixel values to calculate the MSB and LSB thresholds.

7. The method claimed in claim 6, wherein the MSB threshold is the average value of the determined maximum and minimum pixel values; an upper LSB threshold is the average value of the maximum pixel value and the MSB threshold; and a lower LSB threshold is the average value of the minimum pixel value and the MSB threshold.

8. The method claimed in claim 6, wherein the gradient of a pixel is determined as a weighted sum of the differences between a pixel and its surrounding pixels, and the first neighborhood is a 5.times.5 window of pixels and the second neighborhood is a 7.times.7 window of pixels.