/Video-Subtitles-Detector-Program

Primary LanguageJupyter NotebookApache License 2.0Apache-2.0

Video Subtitles Detector Program

This program processes video frames to detect subtitles using various image processing techniques. It is done on this video https://drive.google.com/file/d/1mUOdZbcvRS_UTIoi4wGdfp9i8pNl3fYM/view

Image Processing Basics

The program includes the following image processing steps:

  1. Pre-processing: Adjustments for noise reduction, contrast enhancement.
  2. Image Segmentation: Dividing an image into meaningful parts.
  3. Feature Extraction: Identifying and extracting important characteristics.
  4. Image Recognition: Assigning labels or classifications to objects.

Pre-Processing

1. Converting Image to Grayscale

Convert a 3-channel image into a one-channel grayscale image for faster and easier processing. The grayscale values range between [0:255].

Grayscale Conversion

2. Noise Removal

Applies a Gaussian blur to the grayscale image (frame_gray) using a kernel of size kernel_size x kernel_size and a standard deviation of 5. This reduces noise and smooths the image.

Noise Removal

3. Thresholding & Connectivity

cv2.threshold is a function that applies a fixed-level threshold to each pixel in the image. cv2.THRESH_BINARY converts the image to a binary image (black and white).

Thresholding & Connectivity

Image Segmentation

1. Region of Interest (ROI)

Working on a specific region to apply other processing steps without the need to apply these processes to the whole frame.

Region of Interest

2. Mask Filtration

The code converts a region of interest (ROI) in a video frame from BGR to HSV color space and then creates a mask that isolates white colors within the specified HSV range. The mask highlights pixels in the ROI that fall within the range defined by lower_white and upper_white.

Mask Filtration

3. Remove Noise using Morphology

Morphological transformations are applied to remove noise and improve the mask.

Morphology

Results

Segmentation Results

Segmentation Results

Feature Extraction Results

Feature Extraction Results

Final Result

Final Result