Skip to content

Commit

Permalink
Merge pull request UTSAVS26#990 from Suvadip-sana/main
Browse files Browse the repository at this point in the history
Video summarization
  • Loading branch information
UTSAVS26 authored Nov 3, 2024
2 parents a9f8c45 + 4787182 commit 25ede8a
Show file tree
Hide file tree
Showing 4 changed files with 434 additions and 0 deletions.
70 changes: 70 additions & 0 deletions Image processing/Video Summarization/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Video Frame Extraction and Entropy Analysis

This project extracts frames from a video, saves both colored and grayscale versions, calculates entropy for each grayscale frame, and analyzes histogram differences between frames. This workflow can be helpful in video analysis tasks like detecting scene changes, frame selection based on entropy, and other types of frame-by-frame video analysis.

## Table of Contents
- [Project Overview](#project-overview)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Project Structure](#project-structure)
- [Plotting Frame Entropies](#plotting-frame-entropies)
- [Reducing Frames](#reducing-frames)
- [License](#license)

## Project Overview

The primary objectives of this project are:
1. Extract frames from a video file and save both the colored and grayscale versions.
2. Compute entropy for each grayscale frame to analyze its complexity.
3. Compare consecutive frames using histogram differences and select frames based on those changes.
4. Visualize the entropy across selected frames to understand variation over time.

## Features
- Extracts frames from a video file.
- Saves extracted frames as both color and grayscale images.
- Computes entropy for grayscale images.
- Compares consecutive frames based on histogram differences.
- Selects and plots frames with the highest entropy changes.

## Installation
To run this code, make sure you have the following dependencies installed:

```bash
pip install opencv-python numpy matplotlib
```

## Usage
- Place your video file (e.g., `Sample.mkv`) in the project directory.
- Run the code to extract frames and save them in two folders: `vout1` (colored frames) and `grayvout1` (grayscale frames).
- Entropy values will be calculated for each frame and plotted. You can also plot the histogram difference-based frame selection.
``` bash
python main.py
```
## Project Structure

``` bash
project-folder/
├── Sample.mkv # Sample video file (place your video file here)
├── vout1/ # Directory to store colored frames
├── grayvout1/ # Directory to store grayscale frames
├── main.py # Main Python script
├── README.md # Project description file
```
## Plotting Frame Entropies
The entropy of each selected frame is calculated and plotted to visualize changes over time.

``` bash
# Plotting the entropy values for selected frames
plt.plot(x, listed, color='r', label='Entropy')
plt.legend()
plt.show()
```

## Reducing Frames
To reduce the number of frames analyzed, only the frames with the most significant histogram differences are selected. This helps in analyzing key frames, such as those with scene changes.

``` bash
selected_frames = select_frames(frame_changes, num_frames=100)
```
Binary file added Image processing/Video Summarization/Sample.mp4
Binary file not shown.
362 changes: 362 additions & 0 deletions Image processing/Video Summarization/Video Summarization.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Project-Structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,8 @@
* [Example](Image%20processing/PhotoSpectroscope/Theme/example.py)
* Real-Time-Feature-Detection-And-Matching
* [Main](Image%20processing/Real-Time-Feature-Detection-and-Matching/Main.py)
* Video Summarization
* [Video Summarization](Image%20processing/Video%20Summarization/Video%20Summarization.ipynb)
* Covid Face Mask
* [Test](Image%20processing/covid_face_mask/test.py)
* [Train Model](Image%20processing/covid_face_mask/train_model.ipynb)
Expand Down

0 comments on commit 25ede8a

Please sign in to comment.