SoftwarePractice.org: Home | Courseware | Wiki | Archive

Deblurring and Noise

From SoftwarePractice.org

Functions: deblur, noise


This portion of the barcode processing involves analysing a blurred or noisy barcode image.

Barcode impairments include:

- Quality impairments: broken bars, low ink within the image, or white/coloured/black noise

- Distortions and damage to the barcode: crooked or warped bars, smudges, white/black blobs, image is partially obscured

- Poor scanning: image is unevenly scanned, bars are merged and spaces eliminated due to low threshold, broken bars as scanning threshold is too high


As evident from the numerous impairments evident with barcode scanning, there are a multitude of problems that can be encountered. As with the real world, we cannot ensure that all barcodes are successfully decoded.

One of the predominant problems we saw was associated with poor scanning. We found that the images found on the internet were of a poor scanning quality, experiencing all the issues mentioned above.

Such images focussed upon within this component are shown below:

Image: example18_blurgaus05.jpg

Image: example12.jpg

deblur.m


The deblur function only operates when the deblur checkbox is selected within the main GUI window. It utilises numerous functions available within the image processing toolbox.

In general, this function aims to “clean-up” the image, by sharpening the edges of the bars within the image. It focuses upon the thresholds of the barcode t determine where the original bars are situated. One issue with this is that at times, the image may be too blurred for proper recognition.

Below are the functions exercised within the deblurring process:

Rgb2gray:–

Converts RGB images into greyscale images. RGB (red,green,blue) images are typically in true colour and therefore are required to be altered for processing so it can be filtered. Grayscale images are typically black and white images, depicting the true nature of the barcodes we wish to process. This step is necessary as the majority of the functions evident within our processing process use 2 dimensional matrices, rather than the 3 dimensions represented by RGB images.

Within the image processing toolbox, Matlab offers numerous algorithms to deblur images.

These include:-

- deconvblind: deblurs using the blind deconvolution algorithm. It uses a maximum likelihood algorithm and requires an initial guess.

- devonvlucy: deblurs using the Lucy-Richardson algorithm. This function relies on Poisson statistics.

- deconvreg: deblurs using a regularised filter. This is most successful when there is limited known information about the noise prevalent within the image

- deconvwnr: deblurs using the Wiener filter. This filter is successful when the frequency characteristics and additive noise evident within the image is already known.

- edgetaper: does not use discrete Fourier transform like the above 3 functions. It analyses the edge of the images and tapers them.

fspecial:-

Creates 2D special filters based on the selection of the following algorithms – Gaussian, sobel, prewitt, laplacian, log, average and unsharp.

Within our deblurring process, we utilise the fspecial function of the Gaussian type. Our particular function returns a rotationally symmetric Gaussian lowpass filter of size 7 and a standard deviation of 10. The resultant is the point-spread-function (PSF).

Graythresh:–

Determines the global image threshold using Otsu’s method. Using this method, the image is ensured to be a binary image.

Edge:–

The edge function is very important to the processing process as it determines the edges of the bars within the barcode. Within the program, we use an edge function of type canny. By inputting the determined global threshold value, the program is able to detect strong and weak edges within the barcode. We chose the canny filter as it is much more adequate and powerful in comparison to the other filters available as it uses two different thresholds. This ensures that it can notice noise within the image more sufficiently.

Strel:–

The strel function used within the deblurring process is of a type disk. This means that a structuring element of radius 2 is identified.

Imdilate:–

After the strel function, we pass the edged image and the structuring element though an imdilate morphological function. This expands the image to be processed.

The modified image array is then processed by adding 0s close to the border of the image where it is then further deconvolved using the blind convolution algorithm.

Deconvblind:–

This is used as no information about the blurring and noise of the image is known. This is usually the case with a new image.

Since we do not know the blurring and nosies level of the image we employed deconvblind function,alone with the fspecial function of the Gaussian type as described.

Matlab Simulation of Deblure Process:- Original blurred Image Image:example18_blurred.jpg Out puts of deblur process; Image:dbl.jpg

First 3 barcodes in above figure are restore the blurred image using PSFs of various sizes

- The size of the UNDERPSF array is 4 pixels shorter in each dimension than the true PSF.

-OVERPSF, for an initial PSF that is 4 pixels longer in each dimension than the true PSF.

-INITPSF, for an initial PSF that is exactly of the same size as the true PSF.

-Using additional constraints on the PSF restoration in OVERPSF

PSF:- Define as below. Most blurring processes can be approximated by convolution integrals, also known as Fredholm integral equations. The blurring is characterized by a PSF or impulse response. The PSF is the output of the imaging system for an input point source. All the blurring processes considered in this thesis are linear and have a spatially invariant PSF.

For discrete image processing, the convolution integral is replaced by a sum. The blurry image x(n,m) is obtained from the original image s(n,m) by this convolution: Image:img21.gif

The function h(n,m) is the discrete Point Spread Function for the imaging system. Also of interest is the Discrete Fourier Transform (DFT) representation of the point-spread function, given by Image:img22.gif

For Image:img23.gifandImage:img24.gif . H(u,v) gives a set of coefficients for plane waves of various frequencies and orientations. These plane waves, called spatial frequency components, reconstruct the PSF exactly when multiplied by the coefficients H(u,v) and summed. The function H(u,v) is referred to as the transfer function, or system frequency response. By examining |H(u,v)|, one can quickly determine which spatial frequency components are passed or attenuated by the imaging system.

Image:img25.jpg

By consider a very small point of light. If the visual system had perfect optics the image of this point on the retina would be identical to the original point of light. So if the relative intensity of this point of light were plotted as a function of distance, on the retina, such a plot would look like the dashed, vertical, green line. However, the eye's optics are not perfect so the relative intensity of the point of light is distributed across the retina as shown by the red curve in below graph. This curve is called the PSF. Image:img26f.gif


To view the corresponding deblur.m Code

noise.m

This function reduces the noise that exists within the barcode image. We have used 2 types of filters: medfilt2 and wiener2.

Medfilt2:–

Uses a linear median filter to ‘clean-up’ the image. It reduces what is called sale-and-pepper noise. That is, the noises prevalent are specks on the barcode image. We have used this filter as opposed to convolution of the image as we wish to not only eliminate the noise within the image, but retain the edges of the bars. This function looks at the median values of the neighboring pixels to determine the actual value of the processed pixel. This eliminates any extremes in pixel values that can result of the existence of outlying values of noise pixels.

Wiener2:–

The wiener2 function is a 2 dimensional, adaptive filter. It determines the variance values of neighboring pixels to determine noise. We chose this filter as it is able to preserve the edges of our barcode.

wiener2 estimates the local mean and variance around each pixel,

Image:Eq1.gif

where n is the N-by-M local neighbourhoods of each pixel in the image A. wiener2 then creates a pixelwise Wiener filter using these estimates,

Image:Eq2.gif

filter2:-

Two-dimensional correlation is equivalent to two-dimensional convolution with the filter matrix rotated 180 degrees.

Matlab Simulation noise Reduction process;

Image:Noise11.jpg

By having close look at the second and the last figure in the picture above it is very clear that the adaptive filter is the best filter for noise reduction ahead of digital filter(filter2). So we choose wiener for this process.


To view corresponding noise.m Code



Back to Team F's Main Page Team F: Barcode Reading from Image write my essay

Personal tools