This folder contains example implementations of how to
- extract features from an image and save them to a file
- flatten the features such that they can be used as input to a machine learning model, and
- apply filters to the images and save the new images to a file.
## ✔ Setup
- tested with Python 3.11 (other versions might work as well)
Create a virtual environment and install the required packages:
```bash
python3.11 -m venv venv
source venv/bin/activate
pip install-r requirements.txt
```
## Usage: `extract_features.py`
```bash
python extract_features.py
```
This will extract the RGB values from the image [`figures/examples_from_dataset/banana.jpg`](figures/examples_from_daaset/banana.jpg) and create the following files:
-`features-banana.txt` :arrow_right: contains the features (RGB values) of the image
-`features-banana-flattened.txt` :arrow_right: contains the flattened features (RGB values) of the image
-`features-banana-resized.txt`:arrow_right: contains the features (RGB values) of the banana image after resizing it to 50x50 pixels
-`features-banana-resized-flattened.txt`:arrow_right: contains the flattened features (RGB values) of the banana image after resizing it to 50x50 pixels
## Usage: `apply_filters.py`
```bash
python apply_filters.py
```
This will apply the following filters to the image [`figures/examples_from_dataset/banana.jpg`](figures/examples_from_daaset/banana.jpg) and create the following files in the folder [`figures/examples_from_dataset/`](figures/examples_from_dataset/):
-`banana-edges.jpg` :arrow_right: contains the image with applied Canny edge detection filter
-`baanan-sobel.jpg` :arrow_right: contains the image with applied Sobel filter
-`banana-hsv.jpg` :arrow_right: contains the image with applied HSV filter
-`banana-gray.jpg` :arrow_right: contains the image with applied grayscale filter
For each filter, another file is created that contains the image with the filter applied after resizing to 50x50. The files are named `....-resized.jpg`.