Automatic judging method for day and night modes of visible light camera based on image
Technical Field
The invention relates to the technical field of camera day and night mode discrimination, in particular to an image-based automatic visible light camera day and night mode discrimination method.
Background
The visible light camera of the video monitoring equipment can obtain the best imaging effect no matter in daytime or at night through IR-CUT double-filter switching. During daytime, the optical filter used by the IR-CUT can filter out light rays of an infrared part, so that color cast of an image is avoided. When in a night scene, the optical filter used by the IR-CUT can enable light to be transmitted completely, so that the photosensitivity is improved, and the imaging capability of the night low-illumination scene is improved.
The existing day and night mode judgment is mainly based on detection of a photosensitive sensor, the photosensitive sensor converts an optical signal into an electric signal by utilizing a photosensitive element, and the sensitive wavelength of the photosensitive sensor is near the wavelength of visible light, so that the photosensitive sensor can be used for judging day and night scenes. The photosensor has the advantages of high sensitivity and small volume, but when in use, the photosensor needs to be placed on the shell of the equipment so as to contact external light, which increases the design complexity inside the equipment and the cost, and once the photosensor is damaged, the equipment cannot automatically switch day and night modes. The day-night mode detection method based on image analysis has the advantages of low cost and high reliability, and the detection mode of the photosensitive sensor is gradually replaced.
The chinese patent with publication No. CN103533252a discloses a method and apparatus for automatically switching a diurnal mode, in which a diurnal mode switching method is provided, which calculates the brightness of a picture according to a currently photographed image, and implements automatic switching of a diurnal mode according to the magnitude relation between the brightness and a brightness threshold th_ D, TH _h and Smart IR technology. The method overcomes the problems of cost, illumination and devices existing in the prior art by adopting the photoresistor. However, the method is only suitable for equipment with infrared light supplementing lamps, and has low universality.
The Chinese patent with publication number CN104615989A discloses an outdoor day and night distinguishing method, which comprises the steps of firstly collecting images for a plurality of continuous days, obtaining a classifier by obtaining an average brightness value and a brightness histogram of each image, obtaining a feature description file and a label description file, training a support vector machine by using the feature description file and the label description file, and obtaining day and night mode information by extracting feature descriptors of a current image and sending the feature descriptors to the classifier during image identification. The method is based on single frame image judgment, and when sky or light which is suddenly in exists in a scene, the possibility of repeatedly switching the day and night modes exists.
In summary, the existing automatic judging method for the day and night modes of the visible light camera has the following defects:
1) Depending on other sensors, some devices rely on photosensitive sensor data to realize day-night switching in addition to the visible light sensor, once the sensor is damaged, the visible light camera can lose the day-night switching function, and meanwhile, the sensor can also increase the design and manufacturing cost of the device.
2) The anti-interference capability is weak, namely, the anti-interference capability is weak for light, sky and the like, and the anti-interference device is only effective for specific scenes.
3) The time sequence data is not utilized, namely, the problem of frequent switching of the IR-CUT double filters exists when one frame is recognized incorrectly only based on single-frame image recognition.
Disclosure of Invention
The invention aims to provide an image-based automatic judging method for the day and night modes of a visible light camera, which solves the problems of high cost, weak anti-interference capability and no utilization of time sequence data in the existing automatic judging method for the day and night modes of the visible light camera.
The technical scheme adopted by the invention for solving the technical problems is as follows:
the invention discloses an image-based automatic judging method for the day and night modes of a visible light camera, which comprises the following steps:
step 1, obtaining multi-frame visible light images with equal time intervals;
Step 2, converting a plurality of frames of visible light images into single-channel gray scale images frame by frame;
Step 3, dividing the single-channel gray level image by using an adaptive dividing algorithm, and extracting a background area;
step 4, calculating brightness characteristics and noise characteristics of the single-channel gray-scale image based on the background area information of the single-channel gray-scale image;
and 5, counting the feature consistency among the multi-frame single-channel gray level images to determine day and night information, and realizing automatic judgment of the day and night mode of the visible light camera.
Further, in step 1, the time interval between two adjacent multi-frame visible light images is 1 minute.
Further, in step 2, the image is grayed by using a maximum value method, gray=max { R, G, B }, gray represents a pixel value of any coordinate of the single-channel Gray image, R represents a red channel pixel value of a corresponding coordinate in the multi-frame visible light image, G represents a green channel pixel value of a corresponding coordinate in the multi-frame visible light image, B represents a blue channel pixel value of a corresponding coordinate in the multi-frame visible light image, and max represents a maximum value of three pixel values calculated R, G, B.
In step 3, a single-channel gray level image is segmented by using an Ostu algorithm to obtain a binary image, the pixel value of a foreground region in the binary image is 255, the pixel value of a background region in the binary image is 0, morphological open operation is performed on the binary image, and noise points in the binary image are removed.
Further, in step 4, the calculation formula of the brightness feature is as follows:
Wherein L c represents the brightness characteristic of the c-th single-channel gray-scale image, c < M is more than or equal to 0, M represents the total frame number of the multi-frame visible light image, hei represents the pixel height of the single-channel gray-scale image, wid represents the pixel width of the single-channel gray-scale image, Representing the pixel value at the c single-channel gray-scale image (i, j), i < hei > 0, j < wid > 0, R c represents the background Area of the binary image corresponding to the c single-channel gray-scale image, phi (R c) represents the pixel Area of the background Area of the binary image corresponding to the c single-channel gray-scale image, and area_thres represents the pixel Area threshold of the background Area of the binary image corresponding to the c single-channel gray-scale image.
Further, in step 4, the calculation formula of the noise characteristic is as follows:
Where MSE c represents the mean square error of the original image and the filtered image, Representing the image of the c-th single-channel gray level image after median filtering,Extremum information of image after median filtering of c-th single-channel gray level image is represented, and max operation represents calculationN c represents the noise characteristics of the c-th single-channel gray-scale image.
Further, the specific operation steps of step 5 are as follows:
step 5.1, calculating a day-night mode of each frame of single-channel gray level image;
When L c < thres_l and N c > thres_n, then the c-th single-channel gray image is in night mode, i.e. circadian mode cur_mod c =0 of the c-th single-channel gray image, otherwise the c-th single-channel gray image is in day mode, i.e. circadian mode cur_mod c=1;Lc of the c-th single-channel gray image represents brightness characteristics of the c-th single-channel gray image, N c represents noise characteristics of the c-th single-channel gray image, thres_l represents brightness characteristic threshold, thres_n represents noise characteristic threshold, brightness characteristic threshold and noise characteristic threshold can be empirically set.
Step 5.2, counting the day and night modes of the multi-frame single-channel gray level image to obtain day and night information;
The discrimination formula of the day and night information is as follows:
where CUR_MODE represents the final calculated diurnal information and M represents the total number of frames of the multi-frame visible light image.
The beneficial effects of the invention are as follows:
Compared with the existing automatic day and night mode distinguishing method of the visible light camera, the technical scheme provided by the invention brings effects and convenience for day and night mode distinguishing in the following aspects:
1. The invention realizes automatic judgment of the day and night mode of the visible light camera based on visible light image analysis without other sensors, and reduces equipment cost and design complexity without other sensor data information.
2. The method has good anti-interference performance, the background area information is extracted through self-adaptive segmentation, the influence of interference sources such as night scene sky and lamplight on an algorithm can be removed, the scene adaptability of the algorithm is improved, the time mode universality is improved by using a maximum value method for image graying, and the method is applicable to both daytime and night after image graying.
3. The stability is improved by multi-frame statistics, namely the stability of the invention can be improved by multi-frame image feature statistics, and the problem of frequent switching of the IR-CUT double filters caused by single image identification errors is avoided.
Drawings
Fig. 1 is a flowchart of an automatic determination method for a day-night mode of a visible light camera based on an image according to the present invention.
Fig. 2 is an acquired original visible light image.
Fig. 3 is an acquired single-channel gray scale image.
Fig. 4 is an extracted image background area.
Fig. 5 is a graph of 20 sets of typical daytime and nighttime image characteristic profiles.
Detailed Description
The technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
According to the method for automatically judging the day and night modes of the visible light camera based on the images, automatic identification of the day and night modes of the visible light camera is achieved based on visible light image analysis, multiple frames of visible light images are collected at equal time intervals, multiple frames of visible light images of three channels are converted into single-channel gray images one by one, the background area of each single-channel gray image is extracted through an adaptive segmentation algorithm, the brightness characteristics and the noise characteristics of the single-channel gray images are calculated based on the single-channel gray image background area information, the feature consistency among the multiple frames of single-channel gray images is counted, day and night information is determined, and the automatic judging function of the day and night modes of the visible light camera is achieved.
The invention provides an image-based automatic judging method for a day and night mode of a visible light camera, which comprises the following steps of 1) obtaining multi-frame visible light camera data at equal time intervals, 2) obtaining a single-channel gray image through image graying, 3) extracting a background area of the single-channel gray image, 4) calculating brightness characteristics and noise characteristics of the single-channel gray image, and 5) counting feature consistency among the multi-frame single-channel gray images to determine day and night information, so that automatic judging of the day and night mode of the visible light camera is realized.
Referring to fig. 1 for explanation, the method for automatically judging the day and night modes of the visible light camera based on the image of the invention specifically comprises the following steps:
Step1, visible light image acquisition;
The multiple frames of visible light images with equal time intervals are acquired, the acquired multiple frames of visible light images are three-channel images, as shown in fig. 2, the total frame number of the multiple frames of visible light images is M frames, and the time interval between two adjacent multiple frames of visible light images is preferably 1 minute, but the method is not limited to this.
Step 2, graying the image;
The three-channel image obtained in the step 1 is converted into a single-channel gray level image frame by frame, and color information is removed as shown in fig. 3, so that the invention can be applied to all day and night modes. The specific operation steps are as follows:
And (3) carrying out image graying by using a maximum value method, setting Gray=max { R, G, B }, wherein Gray represents the pixel value of any coordinate of the single-channel Gray image, R represents the red channel pixel value of the corresponding coordinate in the multi-frame visible light image, G represents the green channel pixel value of the corresponding coordinate in the multi-frame visible light image, B represents the blue channel pixel value of the corresponding coordinate in the multi-frame visible light image, and max operation represents the maximum value of the three pixel values calculated R, G, B.
The invention does not depend on color data through image graying, and is suitable for day and night scenes.
Step3, extracting an image background area;
An adaptive segmentation algorithm is used for segmenting the M-frame single-channel gray level image, and an image background area is extracted, as shown in fig. 4. The specific operation steps are as follows:
And 3.1, dividing the M-frame single-channel gray level image by using an Ostu algorithm to obtain a binarized image, wherein the pixel value of a foreground region in the binarized image is 255, and the pixel value of a background region in the binarized image is 0.
And 3.2, performing morphological open operation on the binarized image, and removing noise points in the binarized image.
Step 4, calculating the brightness characteristics and noise characteristics of the image;
And (3) calculating the brightness characteristic and the noise characteristic of the image frame by frame for the single-channel gray-scale image obtained in the step (2) based on the background area information of the single-channel gray-scale image. The specific operation steps are as follows:
step 4.1, calculating the brightness characteristics of the image;
If the pixel Area phi (R c) of the background Area of the binarized image corresponding to the c single-channel gray-scale image is smaller than the pixel Area threshold value area_thres of the background Area of the binarized image corresponding to the c single-channel gray-scale image, the brightness characteristic of the c single-channel gray-scale image
If the pixel Area phi (R c) of the background Area of the binarized image corresponding to the c single-channel gray-scale image is larger than or equal to the pixel Area threshold value area_thres of the background Area of the binarized image corresponding to the c single-channel gray-scale image, the brightness characteristic of the c single-channel gray-scale image
The corresponding image brightness characteristic calculation formula is as follows:
Wherein L c represents the brightness characteristic of the c-th single-channel gray-scale image, c < M is more than or equal to 0, M represents the total frame number of the multi-frame visible light image, hei represents the pixel height of the single-channel gray-scale image, wid represents the pixel width of the single-channel gray-scale image, Representing the pixel value at the c-th single-channel gray-scale image (i, j), i < hei,0 < j < wid, R c represents the background Area of the c-th single-channel gray-scale image corresponding to the binary image, phi (R c) represents the pixel Area of the c-th single-channel gray-scale image corresponding to the binary image background Area, and area_thres represents the pixel Area threshold of the c-th single-channel gray-scale image corresponding to the binary image background Area, which is generally empirically set.
Step 4.2, calculating image noise characteristics;
And (3) regarding the single-channel gray image as a noisy image, regarding the image of the single-channel gray image after median filtering as an original image, and calculating the noise characteristics of the single-channel gray image by calculating the signal-to-noise ratio of the noisy image and the original image. The specific operation steps are as follows:
If the pixel Area phi (R c) of the background Area of the binarized image corresponding to the c single-channel gray-scale image is smaller than the pixel Area threshold value area_thres of the background Area of the binarized image corresponding to the c single-channel gray-scale image Extremum information of image after median filtering of c-th single-channel gray level image0≤i<hei,0≤j<wid。
If the pixel Area phi (R c) of the background Area of the binarized image corresponding to the c single-channel gray-scale image is larger than or equal to the pixel Area threshold value area_thres of the background Area of the binarized image corresponding to the c single-channel gray-scale image, thenExtremum information of image after median filtering of c-th single-channel gray level image
The corresponding image noise characteristic calculation formula is as follows:
Where MSE c represents the mean square error of the original image and the filtered image, Representing the image of the c-th single-channel gray level image after median filtering,Extremum information of image after median filtering of c-th single-channel gray level image is represented, and max operation represents calculationN c represents the noise characteristics of the c-th single-channel gray-scale image.
And 5, counting the feature consistency among the multi-frame single-channel gray level images to determine day and night information, and realizing automatic judgment of the day and night mode of the visible light camera. The specific operation steps are as follows:
step 5.1, calculating a day-night mode of each frame of single-channel gray level image;
When L c < thres_l and N c > thres_n, then the c-th single-channel gray image is in night mode, i.e. circadian mode cur_mod c =0 of the c-th single-channel gray image, otherwise the c-th single-channel gray image is in day mode, i.e. circadian mode cur_mod c =1 of the c-th single-channel gray image, wherein L c represents brightness characteristic of the c-th single-channel gray image, N c represents noise characteristic of the c-th single-channel gray image, thres_l represents brightness characteristic threshold, thres_n represents noise characteristic threshold, brightness characteristic threshold and noise characteristic threshold can be empirically set.
Step 5.2, counting the day and night modes of the multi-frame single-channel gray level image to obtain day and night information;
day and night mode of single-channel gray scale image of c-th frame The day and night information finally calculated is the daytime mode, if the day and night mode of the c-th single-channel gray scale imageThe finally calculated circadian information is a night mode.
The discrimination formula of the day and night information is as follows:
where CUR_MODE represents the final calculated diurnal information and M represents the total number of frames of the multi-frame visible light image.
The obtained 20 groups of typical daytime and nighttime image characteristic distribution are shown in figure 5 by the image-based visible light camera day-night mode automatic distinguishing method. The invention avoids the phenomenon of frequent switching of the day and night modes of the camera caused by single frame identification errors through multi-frame image feature statistics, and has the advantages of no dependence on other sensor data information, low equipment cost, good anti-interference performance, strong method stability and the like.
The foregoing is merely a preferred embodiment of the present invention and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present invention, which are intended to be comprehended within the scope of the present invention.