Giter Club home page Giter Club logo

computer-vision-tasks's Introduction

Computer Vision Course Tasks

In this Repository we present a variety of Image Processing Techniques implemented from scratch using Python with help of some helpful packages.

Table of contents

To install the required libraries and dependencies, open your terminal in the repository directory and run this command:

pip install -r requirements.txt

Script's Components

requirements.txt contains the versions of each libraries, if already installed the installation will be skipped:

  • Scipy
  • Numpy
  • Pyqtgraph
  • PyQt5
  • opencv-python
  • Pillows
  • Matplotlib
  • scikit_learn

The GUI is composed of many tabs; each tab contains some push buttons, combo boxes or sliders, input texts and some widgets to view the images.

Each category of implemented Algorithms is displayed in a separate tab in the GUI.

Simply you could load the image you want to apply the algorithm on via push buttons, adjust the required parameters then apply the selected algorithm.

Here's the view of the UI tabs without loading any images or applying any algorithms.

Main UI Tabs

Noise_Filters_Edges_Tab

Histogram_Tab

Hybrid_Tab

Hough_Tab.png

Active_Contour_Tab

Harris_Tab

SIFT_Tab

Segmentation_Tab

In this section we present some implementations such as adding noise to image, filtering the added noise, viewing different types of histograms, applying threshold to image and hybrid images.

1. Adding Noise To Image

We implemented 3 types of noise: Uniform, Gaussian and Salt & Pepper. In each type, you could adjust some parameters such as Signal-To-Noise Ratio (SNR) and Sigma to show different outputs.

The results below were taken with the following setup:

Noise parameters:

  • SNR = 0.6
  • Sigma = 128 (For Gaussian Noise Only)

The whole GUI is displayed to show you the difference between the original and the noisy image.

1.1 Uniform Noise

Noise_Uniform_1

1.2 Gaussian Noise

Noise_Gaussian_1

1.3 Salt & Pepper Noise

Noise_Salt_and_Pepper_1

To decrease amount of noise, move the SNR slider a little, and this would be the new output with SNR = 0.9, which means only 10% of the image is noise.

Noise_Salt_and_Pepper_2

2. Image Filtering

We implemented 3 types of Filters: Average, Gaussian, and Median filter. In each filter, you could adjust some parameters such as mask size and Sigma to show different outputs.

The results below were taken with the following setup:

Noise parameters:

  • SNR = 0.6
  • Sigma = 128 (For Gaussian Noise Only)

Filter Parameters:

  • Mask Size: 5x5
  • Sigma = 128 (For Gaussian Filter Only)

The whole GUI is displayed to show you the difference between the noise and the filtered image.

2.1 Average Filter Applied on Uniform Noise

Filter_Average_On_Noise_Uniform_1

2.2 Gaussian Filter Applied on Gaussian Noise

Filter_Gaussian_On_Noise_Gaussian_1

2.3 Median Filter Applied on Salt & Pepper Noise

Filter_Median_On_Noise_Salt_And_Pepper_1

To increase the blurring effect, increase mask size, and this would be the new output with mask size = 9x9.

Filter_Gaussian_On_Noise_Gaussian_2

3. Edge Detection

We implemented 4 types of Edge Detection Techniques (Masks): Prewitt, Sobel, Roberts and Canny.

3.1 Sobel Mask

Edges_Sobel_Mask

3.2 Roberts Mask

Edges_Roberts_Mask

3.3 Prewitt Mask

Edges_Prweitt_Mask

3.4 Canny Mask

The Canny edge detector is an edge detection operator that uses a multi-stage algorithm to detect a wide range of edges in images.

Edges_Canny_Mask

4. Image Histogram and Thresholding

We applied Histogram Equalization and Normalization, each algorithm is used for specific problem. In addition to Convert RGB to Gray Image. We also applied Local and Global Thresholding to differentiate between objects in the image and display specific area of interest. .

4.1 Histogram Equalization

Histogram_Equalization_1

4.2 Histogram Normalization

Histogram_Normalization_1

4.3 RGB To Gray

Histogram_RGB_To_Gray

4.4 Local Thresholding

Thresholding_Local_1

4.5 Global Thresholding

Thresholding_Global_1

5. Hybrid Images

Given 2 images, we apply a Low Pass Filter to the 1st image, and a High Pass Filters to the 2nd image, both in Frequency Domain, and mix the two images to see the output.

5.1 Low Pass Filter With High Pass Filter

Hybrid_Images_1

If you zoomed in the image you would see more details from the dog, if you zoomed out the image you would see more details from the cat.

In this section we present 2 algorithms implementations; Hough Transformation and Active Contour Model, aka 'Snake Algorithm'.

1. Hough Transformation

The Hough transform is a technique that locates shapes in images. In particular, it has been used to extract lines, circles and ellipses if you can represent that shape in mathematical form.

The results below were taken with the following setup:

1.1 Line Detection

The Votes number is basically responsible for determining the amount of output lines. More votes means more detected lines, but this doesn't mean that 5 votes should equal 5 lines, it's not working in that way.

Hough_Lines_1

Hough_Lines_2

1.2 Circle Detection

Here there is an option to choose the range of radius you want to detect, minimum and maximum range.

Hough_Circles_1

Hough_Circles_2

In the 2nd image the maximum radius is less than the bigger circle, so it wasn't detected.

2. Active Contour Model

Active contour is one of the active models in segmentation techniques, which makes use of the energy constraints and forces in the image for separation of region of interest.

Active contour defines a separate boundary or curvature for the regions of target object for segmentation. This implementation is based on Greedy Algorithm.

2.1 Result of applying Snake Model on a hand image

Active_Contour_Snake_1

The parameters' values of alpha, beta, gamma and number of iterations are selected by trial and error approach.

This GIF shows the process in a better way

Active_Contour_Snake_1

2.2 Result of applying the algorithm on circles image

Active_Contour_Snake_2

This GIF shows the process in a better way

Active_Contour_Snake_2

In this section we present 3 algorithms implementations; Feature Extraction Using Harris Operator, Scale Invariant Features (SIFT) and Feature Matching.

1. Extract The Unique Features In All Images Using Harris Operator

There are mainly 2 parameters in Harris Detector:

  • Threshold: Value used computing local maxima (Higher threshold means less corners)
  • Sensitivity: Sensitivity factor to separate corners from edges. (Small values result in detection of sharp corners).

1.1 Harris Corners with 0.2 Threshold and 0.01 Sensitivity

Harris_Corners_1

1.2 Harris Corners with 0.1 Threshold and 0.02 Sensitivity

Harris_Corners_2

The processing time is barely noticeable, it only took about 0.01 second to detect all the corners in the first image and 0.02 second in the second image.

2. Feature Descriptors Using Scale Invariant Features (SIFT) Algorithm

Applying SIFT Algorithm to generate features descriptors to use them in matching images with different techniques.

It is not necessary to show the output of SIFT algorithm, the final output is shown in the matching step.

3. Matching the Image Set Features

We applied two Matching Algorithms, Sum Of Squared Differences (SSD) and Normalized Cross Correlations (NCC).

3.1 Feature Matching Using Sum of Squared Differences (SSD)

Feature_Matching_SSD

3.2 Feature Matching Using Normalized Cross Correlations (NCC)

Feature_Matching_NCC

The computations in this algorithm are heavily and extreme, so as you see it took around 1 minute to finish the whole process on a small image.

Note:

In the above results, each SIFT Algorithm applied was running on a separate thread for faster and better experience, and to avoid GUI freezing problem.

In this section we present some algorithms implementations for Image Segmentation; Using Thresholding and Clustering Methods.

1. Segmentation Using Thresholding

We implemented 3 types of Thresholding, Local and Global for each threshold:

  • Optimal Thresholding
  • Otsu Thresholding
  • Spectral Thresholding (More than 2 modes)

There are mainly 1 parameter used in Local Thresholding:

  • X-Regions: indicates how many regions we want to divide in x-direction
  • Y-Regions: indicates how many regions we want to divide in y-direction

1.1 Optimal Thresholding

Using Global Thresholding

Thresholding_Optimal_Global_1

Thresholding_Optimal_Global_2

Using Local Thresholding

Thresholding_Optimal_Local_1

Thresholding_Optimal_Local_2

1.2 Otsu Thresholding

Using Global Thresholding

Thresholding_Otsu_Global_1

Thresholding_Otsu_Global_2

Note: There is some noise in the image which affects the output a little.

Using Local Thresholding

Thresholding_Otsu_Local_1

1.3 Spectral Thresholding

Using Global Thresholding

Thresholding_Spectral_Global_1

Thresholding_Spectral_Global_2

Using Local Thresholding

Thresholding_Spectral_Local_1

2. Segmentation Using Clustering

We implemented 4 Clustering methods:

  • K-Means
  • Region Growing
  • Agglomerative Clustering
  • Mean-Shift

There are mainly 2 parameters in some Clustering methods:

  • Number of Clusters: to specify how many clusters you need in the output image.
  • Threshold: to threshold the output image in specif level in some methods.

2.1 K-Means with 6 Clusters

Clustering_K_Means_1

2.2 Region Growing with 3 Clusters

Clustering_Region_Growing_1.png

2.3 Agglomerative Clustering with 10 Clusters

Clustering_Agglomerative_1.png

2.4 Mean-Shift with 30 Threshold

Clustering_Mean_Shift_1.png

Mean-Shift with 90 Threshold

Clustering_Mean_Shift_2.png

The output image is changed whenever you change the threshold. You could choose the desired threshold by trial and error to know what value fits.

In this section we present Face Detection and Recognition implementations; Using PCA/Eigenfaces Analysis.

1. Face Detection

This is implemented using openCV library, using CascadeClassifier which contains OpenCV data used to detect objects.

There are mainly 2 parameter you can adjust in Face Detection:

  • Scale Factor: Since some faces may be closer to the camera, they would appear bigger than the faces in the back. The scale factor compensates for this.
  • Minimum Window Size: size of each moving window that that algorithm to detect objects.

Face Detection of one person

Face_Detection_1

Face_Detection_3

Face Detection of our team

Face_Detection_3

2. Face Recognition

This implementation is based on PCA/Eigenfaces Analysis, it's implemented from scratch with the help of some useful libraries.

Quick Description

  • First you need to load the training dataset which consists of 40 class (folder), each class represents one person. Each class has 10 images, taken in different positions.
  • Create Eigen-faces matrix for the dataset, which will be used later to compare with any new test image.
  • Load your test image then start the matching (recognition) process.
  • This function runs in a separate QThreads to ensure best quality and prevent GUI from freezing as it may take some seconds to finish.

Face Recognition with correct test

Face_Recognition_1

Face_Recognition_2

The output image Best Match, is just a combination of all the class images in the database, just for displaying purposes to make it clear to the user.

Face Recognition with wrong test

Face_Recognition_3

This repository is created by a group of 4 students in Biomedical Engineering Department, Cairo University. Šī¸

Name Section B.N Number
Ahmed Salah El-Dein 1 5
Ahmad Abdelmageed Ahmad 1 8
Ahmad Mahdy Mohammed 1 9
Abdullah Mohammed Sabry 2 7

computer-vision-tasks's People

Contributors

abdullah-alrefaey avatar salo7a avatar ahmad-abdalmageed avatar amahdy98 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.