A kind of method of detected image flicker striped
Technical field
The present invention relates to video processing technique, particularly a kind of method of detected image flicker striped.
Technical background
The light source used in daily life mostly is AC power, and the brightness of illuminating lamp changed along with the period of waves of alternating source.When illuminating lamp adopts 50Hz power supply, brightness period of change is 1/100 second; When illuminating lamp adopts 60Hz power supply, brightness period of change is 1/120 second.And for adopting the lens sensors (sensor) of row exposure (Rolling shutter), the image of different rows not in the same time exposure collect, therefore the usual integral multiple being set to 1/100 second or 1/120 second the time for exposure, eliminate the luminous energy difference that different rows is accumulated within the time for exposure, to eliminate flicker striped (Flicker).But when not upon exposure being the integral multiple of 1/100 or 1/120 second, the luminous energy that often row pixel receives will be caused to there are differences, bright secretly alternate Flicker striped will be produced like this in single image.If the output time of every two field picture neither the integral multiple of 1/100 second or 1/120 second time, will cause adjacent two two field pictures with the pixel of a line the initial time for exposure between phase difference, thus in continuous print sequence of video images, observe the Flicker striped of rolling.And the existence of Flicker striped can have a strong impact on quality and the visual effect of video image, particularly give the targeted surveillance in monitoring field and identify and bring very large puzzlement.
Therefore the method for a kind of detected image flicker striped is badly in need of, for follow-up elimination Flicker striped carries out early-stage preparations.
Summary of the invention
In view of this, a kind of method that the embodiment of the present invention provides detected image to glimmer striped, to reach the object detecting in video sequence the striped that glimmers.
In order to achieve the above object, the method for a kind of detected image flicker striped that the embodiment of the present invention provides comprises:
Obtain the row mean vector of two two field pictures in described video sequence to be detected; Wherein, each element in described row mean vector is the average of the pixel value of one-row pixels in current frame image;
Obtain the ratio vector of the row mean vector of described two two field pictures;
Described ratio vector is carried out Fourier transform and obtain spectrum information, remove the spectrum information of DC component in described spectrum information;
The flicker striped in described video sequence to be detected is detected according to described spectrum information.
The method of a kind of detected image flicker striped that the embodiment of the present invention provides, based on Fourier transform, is transformed the flicker striped function information of different frame image in video sequence to be detected in order to spectrum information by Fourier transform; And the flicker striped in video sequence to be detected accurately can be judged according to the frequency spectrum characteristic of spectrum information, testing process does not limit by time for exposure and single-frame images output time, has filled up the technological gap of the flicker striped that current detect lines exposure produces.
Accompanying drawing explanation
Fig. 1 is the flow chart of the method for a kind of detected image flicker striped that one embodiment of the invention provides.
The flow chart of the method for detected image flicker striped when Fig. 2 is space periodic and the frame per second of a kind of flicker striped when known video sequence to be detected that one embodiment of the invention provides.
The flow chart of the method for detected image flicker striped when Fig. 3 is space periodic and the frame per second of a kind of flicker striped when unknown video sequence to be detected that one embodiment of the invention provides.
Body execution mode
For making the object, technical solutions and advantages of the present invention clearly, below in conjunction with accompanying drawing, the present invention is described in further detail.
Fig. 1 is the flow chart of the method for a kind of detected image flicker striped that the embodiment of the present invention provides.As shown in Figure 1, the method comprises the steps:
Step 101: the row mean vector obtaining two two field pictures in described video sequence to be detected; Wherein, each element in described row mean vector is the average of the pixel value of one-row pixels in current frame image.
In an embodiment of the present invention, the product that pixel value is flicker striped functional value and background function value is set.Wherein, flicker striped function can be to glimmer the function being biased to parameter of the space periodic of striped (hereinafter representing with Flicker), the initial phase of flicker striped and flicker striped, and this function can be the trigonometric function comprising SIN function or cosine function.
In an embodiment of the present invention, this flicker striped function F can be expressed as:
wherein ω is the space periodic of Flicker striped, and d is the biased of Flicker striped,
be respectively the initial phase of Flicker striped in two two field pictures.
Owing to can be broken down into Flicker striped and background image two parts with the image of Flicker striped, the pixel value therefore in a two field picture can be expressed as:
wherein B is background function, is m * n matrix, m and n is respectively line number and the columns of current frame image pixel.
Frame output time (inverse of frame per second) due to video image is not the integral multiple of 1/100 second (the brightness period of change under civil power 50Hz) or 1/120 second (the brightness period of change under civil power 60Hz), causes the phase place of the Flicker striped of this two two field picture different.The pixel value of two two field pictures now in step 101 can be expressed as:
Wherein, dI is the biased of two two field picture Flicker stripeds,
with
be respectively the initial phase of two two field picture Flicker stripeds, B
1and B
2be respectively the background function value of pixel in two two field pictures.
The row mean vector of then trying to achieve two two field pictures is respectively mean (I
1) and mean (I
2).
In an embodiment of the present invention, this two two field picture is adjacent two two field pictures; Or when the phase difference of the flicker striped curve of adjacent two two field pictures is less, this two two field picture also can interval one frame or multiple image.In an alternative embodiment of the invention, when the flicker stripe rolling speed of described video sequence to be detected is known, can also according to the rolling speed of described flicker striped, if calculate this two two field picture when there is flicker striped, the flicker striped curve of this two two field picture reaches the frame number of being separated by during certain phase difference; And carry out subsequent calculations with two two field pictures of this frame number of being separated by.
It will be understood by those skilled in the art that the accuracy in order to improve subsequent detection Flicker striped further, can be minimum the be separated by frame number of the flicker striped curve calculating two two field pictures when reaching maximal phase potential difference; And carry out subsequent calculations with two two field pictures of this minimum frame number of being separated by.
Step 102: the ratio vector obtaining the row mean vector of described two two field pictures.
Obtain ratio vector div detailed process can be expressed as:
Background image due to two two field picture respective pixel is rest image, i.e. B
1=B
2=B, in the process of trying to achieve ratio vector, background function value can be removed, and therefore this ratio vector is only relevant with the Flicker striped functional value of two images.
In an embodiment of the present invention, in order to prevent the situation of div=" 0/0 ", doing before two frame line mean vectors are divided by, be first that often corresponding two elements in the row mean vector of two two field pictures add a correction value (offset).As enough relative to the element value in row mean vector hour of this offset, both avoid the situation of appearance " 0/0 ", reduced value can not produce larger impact again.
Detailed process represents and can be:
Wherein, offset=max (max (mean (I1)), max (mean (I2)))/8, max represents maximizing.Namely correction value offset is the row mean vector mean (I of two two field pictures
1) and mean (I
2) all elements in maximum 1/8.
In an embodiment of the present invention, in order to reduce the amount of calculation of follow-up Fourier transform, the element in the row mean vector of two two field pictures can be sampled, and obtain the ratio vector of the row mean vector of described two two field pictures after sampling.It will be understood by those skilled in the art that the number of sampled point can be determined by the size in Flicker cycle, when the Flicker cycle is less, suitably will increase the number of sampled point, the number of the present invention to sampled point does not limit.
Step 103: described ratio vector is carried out Fourier transform and obtain spectrum information, remove the spectrum information of DC component in described spectrum information.
Because the ratio vector of step 102 gained has certain periodicity, its cycle was determined by the cycle of Flicker striped in two two field pictures, its phase place is determined by the phase difference of Flicker striped in two two field pictures, and its fluctuating range is determined by the phase difference of two two field pictures and biased d.Therefore ratio vector can be utilized to carry out Fourier transform, and do spectrum analysis for the curve of conversion gained, detect the Flicker in video sequence to be detected according to frequency spectrum characteristic.
After ratio vector is carried out Fourier transform, the spectrum information of the maximum of spectrum information necessarily DC component, and the spectrum information of this DC component can not reflect the cyclic variation of Flicker fringe value, therefore the spectrum information of this DC component to be removed.Otherwise the spectrum position of later use spectrum information maximum and number of times there will be error when carrying out threshold decision.
Step 104: detect the flicker striped in described video sequence to be detected according to described spectrum information.
In an embodiment of the present invention, in order to improve the accuracy rate of detection further, Fourier transform (FFT) frequency spectrum no longer for single ratio vector performs an analysis, but obtain the average of the FFT spectrum information of the multiple ratio vectors calculated by multiple image, then threshold decision is done to this spectrum mean.Now, step 104 can comprise: first, and being averaged by a spectrum information preset in frame number obtains mean spectrum information; Secondly, the flicker striped in mean spectrum infomation detection video sequence to be detected is utilized.
In an embodiment of the present invention, can be when detecting that the number of times of appearance flicker striped in described video sequence to be detected reaches a predetermined threshold value, then output detections result.
It will be understood by those skilled in the art that because the space periodic of the flicker striped of video sequence to be detected and frame per second may be known, also may be unknown.Therefore in both cases, the embodiment of the present invention provide detected image flicker striping methods detailed process can be different.
When space periodic and the frame per second of the flicker striped of known video sequence to be detected, step 104 specifically can comprise two steps: first, and the prediction spectrum position of peak appears in the spectrum information doping described ratio vector according to the space periodic of described flicker striped.Secondly, judge that spectrum information occurs that whether the spectrum position of peak is consistent with prediction spectrum position, and whether the ratio of the absolute value of peak and all spectrum information mean value is more than or equal to a predetermined threshold value; Be if return results is then illustrate in video sequence to be detected and occurred flicker striped.
The flow chart of the method for detected image flicker striped when Fig. 2 is space periodic and the frame per second of a kind of flicker striped when known video sequence to be detected that one embodiment of the invention provides.As shown in Figure 2, the idiographic flow of the method is:
First input parameter num, fd and T, wherein num is accumulative frame number when asking multiple ratio vector FFT spectrum mean, and fd is represented as and exports one-time detection result every fd frame, and T is the minimum alarm value (S21) of the frame number of the Flicker occurred in fd frame; Three counters count1, count2 and count3 are initialized as 0 (S22); Then from video sequence, choose two two field pictures (S23), and try to achieve the row mean vector (S24) of this two two field picture; Ask the ratio vector of the row mean vector of this two two field picture, and FFT conversion is carried out to this ratio vector, the result cumulative (S25) that FFT is converted; Counter count3 is added 1 (S26), then judge whether count3 reaches num (S27); If do not reached, return S23 and read two two field pictures again and calculate, to continue the result that cumulative FFT converts; If reached, then the result of the FFT conversion after cumulative is averaged, counter count2 is added 1, and count3 is reset (S28), and start to carry out follow-up threshold decision to the average of this FFT transformation results; First judge whether maximum spectrum is greater than a predetermined threshold value with the ratio of all spectrum means except DC component, and maximum spectrum appears at the position (S29) of expection; If S29 judged result is Y, then illustrates and occurred flicker striped, now counter count1 is added 1 (S210), then judge whether count2 reaches fd (S211); If S29 judged result is N, also then to judge whether count2 reaches fd (S211); If S211 judged result is N, then the threshold value also not reaching output detections result is described, now returns S23 and read two two field pictures again and calculate; If S211 judged result is Y, then then judge whether count1 reaches T (S212); If the judged result of S212 is N, then illustrates in fd frame, not occur T flicker striped, this does to point out (S213) without Flicker; If the judged result of S212 is Y, then the alarm threshold value reaching in fd frame and occur T flicker striped is described, this alarm (S214); Finally counter count1 and count2 is reset (S215), and return S23 and read two two field pictures again and calculate.
When space periodic and the frame per second of the flicker striped of the described video sequence to be detected of the unknown, step 104 specifically can comprise: preset in frame number N one and judge whether the frame number that described spectrum information peak is positioned at a fixed frequency spectrum position is greater than N/2, and whether the ratio of the absolute value of described peak and all spectrum information mean value is more than or equal to a predetermined threshold value; Or, preset in frame number N to judge whether respectively at least occurred N/2 peak on adjacent two spectrum positions one.If above any one judged result is yes, then illustrates in described video sequence to be detected and occurred flicker striped.
The flow chart of the method for detected image flicker striped when Fig. 3 is space periodic and the frame per second of a kind of flicker striped when unknown video sequence to be detected that one embodiment of the invention provides.As shown in Figure 3, the idiographic flow of the method is:
First input parameter fd and T, wherein fd is represented as and exports one-time detection result (being also aforesaid default frame number N) every fd frame, and T is the minimum alarm value (S31) of the frame number of the flicker striped occurred in fd frame; Counter count is initialized as 0 (S32); Then from video sequence, choose two two field pictures (S33), and try to achieve the row mean vector (S34) of this two two field picture; Ask the ratio vector of row average, and reduced value vector does FFT conversion, after removal DC component frequency spectrum, store this FFT and convert frequency spectrum (S35); Counter count is added 1 (S36), then judge whether count reaches fd (S37); If do not reached, return S33 and read the calculating that two two field pictures carry out next round FFT conversion frequency spectrum again; If reached, then the threshold value having reached output detections result is described, now counter count is reset, and flicker striated state value Flicker is initialized as 0 (S38); Then, in this fd frame output detections result, count the position that maximum spectrum occurs, record the number of times (S39) that maximum spectrum appears in other positions except first spectrum position; Then judge to occur in a fixed position whether the number of times of spectrum information peak is more than or equal to T (S310); If S310 returns results as Y, then and then calculate the mean value of the peak occurred in this fixed position and the ratio r atio (S311) of all spectrum means; Then judge whether ratio is more than or equal to a predetermined threshold value (S312); If S312 returns results as Y, be then 1 (S313) by Flicker assignment, if whether N then enters S316 to the value of Flicker is 1 to judge; If S310 returns results as N, then judge whether respectively to have occurred fd/2 maximum (S314) on adjacent two spectrum positions; If S314 returns results as Y, be then 1 (S313) by Flicker assignment, if whether N then enters S316 to the value of Flicker is 1 to judge; If the judged result of S316 is Y, then prove to have occurred flicker striped, this alarm (S318); If the judged result of S316 is N, then do the prompting (S317) not occurring flicker striped.
The method of a kind of detected image flicker striped that the embodiment of the present invention provides, based on Fourier transform, is transformed the flicker striped function information of different frame image in video sequence to be detected in order to spectrum information by Fourier transform.And the flicker striped in video sequence to be detected accurately can be judged according to the frequency spectrum characteristic of spectrum information, testing process does not limit by time for exposure and single-frame images output time, has filled up the technological gap of the flicker striped that current detect lines exposure produces.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment done, equivalent replacement etc., all should be included within protection scope of the present invention.