A kind of method of removing picture noise
Technical field
The present invention relates to image processing techniques, particularly a kind of method of removing picture noise.
Background technology
One of purpose that image processing is the most basic is exactly to improve picture quality, for follow-up processing operation provides the good premise environment.Removing picture noise is a kind of relatively effective method that improves picture quality.The reason that noise forms has multiple, may produce in imaging process, also may produce in transmission course, and the existence of noise is handled operation to successive image and brought very big inconvenience, therefore, removes noise and can be described as the step that all images processing must be gone.
At present, the method for removal picture noise has multiple.The mean filter smoothed image is a kind of method of removal picture noise commonly used, and this method is mainly by means of the template operator, substitutes self value with the average of a certain pixel neighboring pixel value, to reach the purpose of removing noise, smoothed image.
Referring to Fig. 1, Fig. 1 is a prior art mean filter principle schematic.Wherein, just by four pixel B, C, D, the E of its periphery, promptly the average of four pixels on the round edge substitutes the pixel value of pixel A among Fig. 1.Its concrete processing procedure is referring to Fig. 2, and Fig. 2 removes the flow chart of picture noise for prior art with the mean filter mode, and this flow process may further comprise the steps:
Step 201, the coordinate figure of each pixel of reading images and gray value data store function f (x into, y) in, wherein stored the horizontal ordinate of each pixel, represented with x, y, also stored the gray value (being also referred to as pixel value usually) of each pixel, by f (x, value representation y).
Step 202, the whole sub-picture of traversal calculates the new gray value of each pixel with formula (1), and stores.
Wherein, a, b are that (x, y) horizontal ordinate, n are step-length to pixel.
Step 203, function reading f (according to the coordinate of each pixel, replace the gray value of each pixel with new gray value, promptly use f (x, the f of value y) (x, value replacement y) of each pixel by x, the y) gray value of each pixel of middle storage.
Because it is exactly the pixel value that substitutes noise with the average of noise surrounding pixel point that the mean filter mode of prior art is removed the essence of picture noise method, though like this can be effectively with noise remove, but image is through after such processing, the gray value of neighbor may be more approaching, the difference of gray scale that is to say neighbor is reduced, therefore also just may cause image blurring phenomenon.
In addition, the method for above-mentioned removal picture noise, owing to be to adopt the template operator that image is carried out point by point scanning, so amount of calculation is bigger, and need pointwise to calculate, and to open the temporary intermediate data of memory space in addition, wasted system resource.At present, the step-length n=1 that chooses usually, i.e. computation of mean values in the window of a 3*3, if step-length increases, amount of calculation also can rise by straight line.
Summary of the invention
In view of this, main purpose of the present invention is to provide a kind of method of removing picture noise, and this method not only can be removed picture noise effectively, and can reduce because of removing picture noise and handle the image blurring phenomenon that causes.
For achieving the above object, technical scheme of the present invention specifically is achieved in that
A kind of method of removing picture noise, this method may further comprise the steps:
A, obtain each pixel data of image;
B, use the gray value of these all pixels of image, calculate the gray average and the gray variance value thereof of this image;
Whether the gray value of C, all pixels of reading images, the gray value of judging each pixel one by one drop on average up and down in 3 times of variances; If then do not revise the gray value of this pixel; Otherwise this pixel is a noise, removes noise by the gray value of revising this pixel.
Wherein, described image can be a zone in whole sub-picture or the image.
The method of the gray average of described this image of calculating of step B can for:
After the gray value summation to all pixels, ask its mean value.
The method of this gradation of image variance yields of the described calculating of step B can comprise:
B1, to all pixels, ask the gray scale difference value of its gray value and gray average, and obtain this gray scale difference value square;
After B2, square summation, obtain mean value, this mean value is carried out evolution, obtain the gray variance value of this image the gray scale difference value of all pixels.
Step C described by revise this gray value remove picture noise method can for:
Gray value is added the pixel of 3 times of variances greater than gray average, its gray value is reduced;
Gray value is subtracted the pixel of 3 times of variances less than gray average, its gray value is increased.
Step C is described to be specifically as follows by the method for revising this gray value removal picture noise:
The gray value that gray value is added the pixel of 3 times of variances greater than gray average is revised as gray average and adds 3 times of variances;
The gray value that gray value is subtracted the pixel of 3 times of variances less than gray average is revised as gray average and subtracts 3 times of variances.
Step C described by revise this gray value remove picture noise method can also for:
Adjust gray value for predetermined one;
The gray value that gray value is added the pixel of 3 times of variances greater than gray average is revised as former gray value and subtracts predetermined adjustment gray value;
The gray value that gray value is subtracted the pixel of 3 times of variances less than gray average is revised as former gray value and adds predetermined adjustment gray value.
As seen from the above technical solutions, the method of this removal picture noise of the present invention, owing to utilized 3 θ principles in the probability statistics opinion, with gray value drop on average up and down 3 times of outer pixels of variances regard noise as and remove, therefore can remove picture noise effectively.
And, because only gray value is dropped on extraneous pixel revises its gray value in the present invention, rather than as prior art, all use the average of calculating separately to substitute to all pixels, the present invention has just guaranteed that the gray value that gray value drops on the pixel in this scope is not modified like this, handle the image blurring phenomenon that causes thereby reduced because of removing picture noise, operand is little, can save system resource.
Description of drawings
Fig. 1 is a prior art mean filter principle schematic;
Fig. 2 removes the flow chart of picture noise with the mean filter mode for prior art;
Fig. 3 removes the process chart of a preferred embodiment of picture noise method for the present invention.
Embodiment
For making purpose of the present invention, technical scheme and advantage clearer, below with reference to the accompanying drawing embodiment that develops simultaneously, the present invention is described in more detail.
The method of this removal picture noise of the present invention has been utilized 3 θ principles in the probability statistics opinion, and it has characterized the overall big number information of determining and has been present in average up and down in 3 times of variances.Based on this theory, image is regarded as an overall calculation the publish picture gray average and the variance of picture, by the point by point scanning pixel relatively, with gray value drop on average up and down 3 times of outer pixels of variances regard noise as, its gray value is revised as average adds/subtract 3 times of variances, can get rid of noise.
Referring to Fig. 3, Fig. 3 removes the process chart of a preferred embodiment of picture noise method for the present invention.This flow process may further comprise the steps:
Step 301, data such as the gray value of each pixel of reading images, coordinate figure and storage.
In this step, the method for storage can be same as the prior art, promptly store into function f (x, y) in.Certainly adopt other modes to store, as long as can be with the gray value and the coordinate figure corresponding stored of each pixel.
Step 302 reads the gray value of all pixels of this image, calculates gray average μ.By formula (2) calculate gray average μ:
Step 303 is calculated variance θ with gray average.By formula calculate earlier (3):
Wherein, the mean value of x is exactly μ.
Calculate the value of variance θ then by extracting operation.
Step 304 reads the gray value of a pixel.
In the step 305, [μ-3 θ, the μ+3 θ] scope of judging whether this gray value drops on, if then carry out
Step 307; Otherwise execution in step 306.
Step 306 is if gray value less than μ-3 θ, then substitutes gray value with μ-3 θ; If gray value greater than μ+3 θ, then substitutes this gray value with μ+3 θ.
The processing procedure of step 305~306 can be represented with formula (4).
Wherein p represents the gray value of each pixel.
The essence of step 305~306 is exactly: to the pixel of gray value greater than μ+3 θ, its gray value is reduced; To the pixel of gray value, its gray value is increased less than μ-3 θ.Therefore, can also there be other modes to realize.
Such as: adjust gray value for predetermined one; Gray value is revised as former gray value greater than the gray value of the pixel of μ+3 θ subtracts predetermined adjustment gray value; Gray value is revised as former gray value less than the gray value of the pixel of μ-3 θ adds predetermined adjustment gray value.
Step 307 judges whether the pixel that do not read in addition, if having, then returns step 304, reads next pixel; Otherwise end process flow process.
The present invention can implement denoising to whole sub-picture, also can select certain zone in the image to implement denoising as required.If whole sub-picture is implemented denoising, the image described in the then above-mentioned flow process is whole sub-picture; If denoising is implemented in certain zone, the image described in the then above-mentioned flow process is selected certain image-region.Processing procedure is identical, is that handled range size is not quite similar.
By the above embodiments as seen, the method of this removal picture noise of the present invention, owing to utilized 3 θ principles in the probability statistics opinion, with gray value drop on average up and down 3 times of outer pixels of variances regard noise as and remove, therefore can remove picture noise effectively.
And, because the present invention only drops on [μ-3 θ to gray value, μ+3 θ] extraneous pixel revises its gray value, rather than as prior art, all use the average of calculating separately to substitute to all pixels, the present invention has just guaranteed that the gray value that gray value drops on the pixel in this scope is not modified, and handles the image blurring phenomenon that causes thereby reduced because of removing picture noise like this.
In addition, the present invention only carries out formula (2) and (3) twice computing to all pixels of image, carry out formula (4) by mode relatively, amount of calculation is little, processing method is easy, and can directly make amendment to the gray value of original image, do not need extra memory space, saved system resource.