How to improve image quality in Matlab

I am creating an Optical Character Recognition system.

the system is still able to identify good quality license plates without any noise.

what I want on the next level is the ability to identify low quality license plates for various reasons.

for example, look at the following plate:

enter image description here

As you can see, the numbers do not look clear, due to the return of light or something else.

for my question: how to improve image quality, so when I go to the binary image, the numbers will not disappear?

early.

+3
source share
3 answers

We can try to correct the lighting effect by setting a linear plane according to the image intensities, which will bring the average image level closer. Subtracting this shading plane from the original image, we can try to normalize the lighting conditions in the image.

For RGB color images, simply repeat the process for each channel separately, or even apply it to a different color space (HSV, Lab *, etc.)

Here is an example implementation:

function img = correctLighting(img, method) if nargin<2, method='rgb'; end switch lower(method) case 'rgb' %# process R,G,B channels separately for i=1:size(img,3) img(:,:,i) = LinearShading( img(:,:,i) ); end case 'hsv' %# process intensity component of HSV, then convert back to RGB HSV = rgb2hsv(img); HSV(:,:,3) = LinearShading( HSV(:,:,3) ); img = hsv2rgb(HSV); case 'lab' %# process luminosity layer of L*a*b*, then convert back to RGB LAB = applycform(img, makecform('srgb2lab')); LAB(:,:,1) = LinearShading( LAB(:,:,1) ./ 100 ) * 100; img = applycform(LAB, makecform('lab2srgb')); end end function I = LinearShading(I) %# create X-/Y-coordinate values for each pixel [h,w] = size(I); [XY] = meshgrid(1:w,1:h); %# fit a linear plane over 3D points [XYZ], Z is the pixel intensities coeff = [X(:) Y(:) ones(w*h,1)] \ I(:); %# compute shading plane shading = coeff(1).*X + coeff(2).*Y + coeff(3); %# subtract shading from image I = I - shading; %# normalize to the entire [0,1] range I = ( I - min(I(:)) ) ./ range(I(:)); end 

Now let's test it on this image:

 img = im2double( imread('http://i.stack.imgur.com/JmHKJ.jpg') ); subplot(411), imshow(img) subplot(412), imshow( correctLighting(img,'rgb') ) subplot(413), imshow( correctLighting(img,'hsv') ) subplot(414), imshow( correctLighting(img,'lab') ) 

enter image description here

The difference is subtle, but it can improve the results of further image processing and OCR tasks.


EDIT: Here are some results that I obtained using other methods to increase the contrast IMADJUST , HISTEQ , ADAPTHISTEQ on different color spaces in the same way as above:

enter image description here

Remember that you must fine tune any parameter that matches your image ...

+3
source

It looks like your question has more or less already answered (see comment d00b); however, here are some basic image processing tips that may help you.

You can try a simple imadjust first . This simply maps the pixel intensity to the โ€œbestโ€ value, which often increases contrast (makes viewing / reading easier). I had great success in my work. It is also easy to use! I think it's worth it.

Also, this looks promising if you just want a higher resolution image.

Enjoy the "pleasure" of image processing in MATLAB!

Good luck

tylerthemiler

PS If you smooth the image to a binary file, you are likely to destroy the image to start with it, so do not do this if you can avoid it!

+1
source

Since you only want to find numbers (of which there are only 10), you can use cross-correlation. To do this, you would Fourier transform the plate image. You also Fourier transform the pattern that you want to match with a good representation of the image of the number 1. Then you multiply in Fourier space and invert the Fourier result.

In the final cross-correlation, you will see pronounced peaks, where the picture goes well with your image.

You do this 10 times and know where each digit is. Note that you must correct the slope before performing cross-correlation.

This method has the advantage that you do not need to set an image threshold.

In the literature, of course, there are much more complex algorithms for assigning number plates. For example, you can use Bayesian theory to estimate which number will be the most likely (this helps a lot if you already have a database of possible numbers).

+1
source

Source: https://habr.com/ru/post/918883/


All Articles