Giter VIP home page Giter VIP logo

image_filter's Introduction

Description

Program to remove speckle (salt and pepper) noise from images. Two common filters in this are implemented in this project:

  1. Alpha-trim filter

  2. Adaptive median filter

The main idea of both filters is to sort the pixel values in a neighborhood region with certain window size and then chose/calculate the single value from them and places it in the center of the window in a new image, see figure 1. This process is repeated for all pixels in the original image

Screenshot 2022-03-18 214854

First: Alpha-trim filter

The idea is to calculate the average of some neighboring pixels' values after trimming out (excluding) the smallest T pixels and largest T pixels. This can be done by repeating the following steps for each pixel in the image:

  1. Store the values of the neighboring pixels in an array. The array is called the window, and it should be odd sized.

  2. Sort the values in the window in ascending order.

  3. Exclude the first T values (smallest) and the last T values (largest) from the array.

  4. Calculate the average of the remaining values as the new pixel value and place it in the center of the window in the new image.

This filter is usually used to remove both salt & pepper noise and random noise.

Screenshot 2022-03-18 215055

Alpha-trim filter implemented with TWO different algorithms:

  1. Counting Sort

  2. Selecting Kth smallest element in the array without sorting it (Textbook sec. 9.2). where K = T to exclude the smallest T values, then on the remaining array, apply the algorithm again to exclude the largest T values. Finally, calculate the average of the remaining values

Second: Adaptive Median Filter

The idea of the standard median filter is similar to alpha-trim filter but instead we calculate the median of neighboring pixels' values (middle value in the window array after sorting).

It's usually used to remove the salt and pepper noise.

However, the standard median filter has the following drawbacks:

  1. It fails to remove salt and pepper noise with large percentage (greater than 20%) without causing distortion in the original image.

  2. It usually has a side-effect on the original image especially when it’s applied with large mask size, see figure 2 with window 7×7. Adaptive median filter is designed to handle these drawbacks by:

  3. Seeking a median value that’s not either salt or pepper noise by increasing the window size until reaching such median.

  4. Replace the noise pixels only. (i.e. if the pixel is not a salt or a pepper, then leave it).

Screenshot 2022-03-18 215400

Adaptive median filter implemented with TWO different algorithms:

  1. Quick Sort

  2. Counting Sort

Timing graphs:

  1. Display two graphs to show the execution time against different window sizes (3, 5, 7,… Wmax), where Wmax is user input:

    1. One graph for alpha-trim filter to compare its two methods (counting & selecting kth element)

    2. Another graph for adaptive median filter to compare its two methods (quick & counting).

image_filter's People

Watchers

Menna Halim  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.