The invention discloses an automatic coal and gangue sorting system and method, and belongs to a coal and gangue sorting system and method. The sorting system comprises a vibrator feeder, a queuing device, a coal collecting hopper, a gangue collecting hopper, a belt conveyor, a detecting device, a camera, an industrial personal computer, a lens hood, an LED light source, an executing device, a controller, a high-speed electromagnetic valve and a spray gun. A belt is monitored in real time through the camera, and two square sub-regions are selected, wherein side lengths of belt imaging regions corresponding to the sub-regions are smaller than the lower limit of granularity of coal and gangue; the grey level histogram average value of the two sub-regions is calculated in real time and compared with a threshold, determined through a test, of gangue, coal and the belt, when the grey level histogram average value of the sub-regions is larger than the threshold, the material is judged as gangue, the controller controls the high-speed electromagnetic valve to be switched on, the spray gun blows the gangue into the gangue collecting hopper, and coal continues to move and fall to the coal collecting hopper or the conveying belt. Real-time monitoring is conducted through the camera, control is timely, the sorting result is accurate, the layout is close to that of site artificial gangue discharge, and actual transformation is easy.