Realistically, there is no single best way to differentiate between such images.
A lot depends on the images selected and the intent and method of the analysis undertaken. To computer software and devices, there might be little salient difference in terms of the maths; the histograms of under-exposed daytime images and over-exposed nighttime ones might provide histogramic data which seems remarkably similar. However, thinking about how light works and the mechanics of digital image capture may suggest a number of factors which offer clues that can be visually understood as distinguishing the recording circumstance. Deductive application of the Exposure Tripod of Aperture, Sensitivity and Shutter Speed will help.
Images taken during day light hours obviously have a major, if indirect, light source; the sun. Sunlight has its own unique qualities, and is largely colour-cast toward the blue, whereas artificial sources such as tungsten or fluorescents cast toward the orange and green respectively. Colour cast provides a first suggestive criteria. Sunlight is directional, and even under heavy cloud creates directional areas of localised shadow, if with, at times, somewhat diffuse edges. Images captured at night obviously have to use moonlight, with its own qualities, or more frequently, artificial light often with multiple sources of no single directional aspect. The necessarily greater proximity of these artificial sources can also lead to evidence of divergently angled, multi-directional sharp-edged shadows that don’t drop off in the same way that shadows from sunlight do. Surface textures can be very contrasting and high-key.
It is worth bearing in mind that the mechanism of capture inherently shapes the image recorded. In daylight, with a large volume of light to draw on, the capture lens aperture can be very small, leading to great depth of field in images, with sharp focus across the field of view and into the far picture plane. Daylight’s brightness also facilitates lower levels of sensitivity with commensurately lower ISO levels, and decreased image grain. The much lower levels of light at night mean that images captured need larger, more open aperture settings which narrow the depth of field, leading to very narrow areas of focus with much of the picture plane subject to blurring. The ISO sensitivity for night-time images must also be increased, leading to much more noticeable levels of ‘noise’ or grain in the capture. This grain can most clearly be discerned in the separate channels, usually blue or red.
The greater availability of day light allows for shorter exposure times, freezing movement above about 100th of a second. Night shooting extends shutter speed, often resulting in the capture of blurred movement and light-trails evident. This might be in figures, foliage, traffic, clouds, or simple camera shake.
So critical visual evaluation of the colour cast, and intensity localisation and directionality of shadows, observation of the focussed depth of field, evidence of ‘noise’ in the colour channels and sharp or blurred or light trails from longer shutter speeds provide a range of combinant criteria with which to reach a probable conclusion about the diurnal light conditions of capture.
I got the solution by this way. First, I get the input folder address and run a while loop for all images in that directory. We know in black and white images (night images), the difference between pixels' RGB values is near to zero. Therefore, we calculate the differences between channels mutually for all pixels. Afterwards, we consider the square of the differences to avoid negative values and then we find the mean values for all differences. If this mean value is near to zero then the image is taken at night, otherwise it is taken in day light.