{"id":34919138,"url":"https://github.com/abdulrahman-k-s/image_filter","last_synced_at":"2026-05-20T13:34:07.954Z","repository":{"id":171776317,"uuid":"648356357","full_name":"Abdulrahman-K-S/Image_Filter","owner":"Abdulrahman-K-S","description":"This project tackles an important problem which deals with the removal of noise from images is a major task in the field of image processing, because it affects the quality of the image and leads to the loss of some of its important information through the impact of noise on it.","archived":false,"fork":false,"pushed_at":"2023-06-23T16:39:56.000Z","size":2536,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-23T20:09:39.488Z","etag":null,"topics":["algorithm","algorithms","csharp","filter","image-processing","sort","sorting","university-project"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Abdulrahman-K-S.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-06-01T19:30:57.000Z","updated_at":"2024-04-23T20:09:42.893Z","dependencies_parsed_at":null,"dependency_job_id":"76483092-03da-4453-b69c-d8c645e532af","html_url":"https://github.com/Abdulrahman-K-S/Image_Filter","commit_stats":null,"previous_names":["bebo-k-s/image_filter","abdulrahman-k-s/image_filter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Abdulrahman-K-S/Image_Filter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abdulrahman-K-S%2FImage_Filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abdulrahman-K-S%2FImage_Filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abdulrahman-K-S%2FImage_Filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abdulrahman-K-S%2FImage_Filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Abdulrahman-K-S","download_url":"https://codeload.github.com/Abdulrahman-K-S/Image_Filter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abdulrahman-K-S%2FImage_Filter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28055272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-26T02:00:06.189Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","algorithms","csharp","filter","image-processing","sort","sorting","university-project"],"created_at":"2025-12-26T13:08:42.778Z","updated_at":"2025-12-26T13:08:43.895Z","avatar_url":"https://github.com/Abdulrahman-K-S.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction  \nThis project tackles an important problem which deals with the removal of noise from images is a major task in the field of image processing, because it affects the quality of the image and leads to the loss of some of its important information through the impact of noise on it. Removing noise from an image is a big field and deals with many algorithms and techniques. Order statistic filters are non-linear spatial filters whose response is based on the ordering(ranking) of the pixels contained in the image area encompassed by the filter, and then replacing the value in the center pixel with the value determined by the ranking result. We are going to introduce and implement two of the order statistic filters which are:\n1.\tAlpha-Trim Filter\n2.\tAdaptive Median Filter\n\n## Alpha-Trim Filter\nAlso known as the Alpha-Trimmed Mean Filter, it is a type of nonlinear filter used to remove noise from image data. It works by taking the average (mean) of a subset of pixel values, excluding the T highest and T lowest values in that subset; the T-value is taken as an input from the user. The number of pixels to include in the subset is determined by a parameter called the alpha value. The alpha-trimmed mean filter is effective at removing impulse noise, which is characterized by sudden, isolated spikes in pixel values. By excluding the T highest and T lowest values in the subset, the filter can remove these spikes while preserving the underlying structure of the image. The alpha-trimmed mean filter is a type of rank-order filter, which means that its output value is determined by the order of the pixel values in the subset, rather than their actual values. This makes it robust to outliers and other types of noise that can distort the pixel values in an image. The alpha-trimmed mean filter is commonly used in applications such as digital image processing, computer vision, and signal processing. Its effectiveness depends on the choice of alpha value, which should be selected based on the characteristics of the noise in the image.\n\n## Adaptive Mean Filter\nThe adaptive mean filter is a type of nonlinear filter used for image processing and noise reduction. It works by calculating the mean value of a local neighborhood of pixels around each pixel in the image. Unlike a traditional mean filter, the size of the local neighborhood is not fixed, but varies depending on the local image characteristics.\nTo calculate the size of the local neighborhood, the adaptive mean filter uses a threshold value. If the difference between the central pixel and the mean of the local neighborhood is greater than the threshold value, then the size of the neighborhood is increased to include more pixels. This helps the filter to adapt to the local variation in the image data and preserve the edges and other fine details.\nThe adaptive mean filter is effective at removing noise from images while preserving the edges and other important features. It is particularly useful for images with non-uniform noise, where the noise level varies across the image. By adapting the size of the neighborhood based on the local image characteristics, the filter can remove noise without blurring or distorting the underlying image structure.\nThe adaptive mean filter is commonly used in applications such as medical imaging, remote sensing, and computer vision. Its effectiveness depends on the choice of threshold value and the size of the local neighborhood, which should be selected based on the characteristics of the image and the level of noise present.\n\n## Alpha-Trim Filter – Sorting Algorithms: \n### Counting Sort:\nCounting sort is an efficient sorting algorithm used to sort a collection of integers or other discrete values. It works by counting the number of occurrences of each value in the collection, and then using this information to determine the final sorted order.\nHere's how counting sort works:\n1.\tFind the minimum and maximum values in the collection.\n2.\tCreate an array of counters that is large enough to hold the range of values from the minimum to the maximum value.\n3.\tIterate through the collection, incrementing the counter for each value encountered.\n4.\tIterate through the counter array, accumulating the counts to determine the final position of each value in the sorted output.\n5.\tIterate through the original collection again, placing each value in its final position in the sorted output.\n\nThe time complexity of counting sort is O(N + K), where n is the number of elements in the collection and k is the range of values. This makes it a linear time sorting algorithm, which can be very efficient for collections with a small range of values.\n \n### Merge Sort:\nMerge sort is a popular sorting algorithm that uses the divide-and-conquer approach to sort a collection of elements. It works by dividing the collection into two halves, recursively sorting each half, and then merging the two sorted halves into a single sorted output.\nHere's how merge sort works:\n1.\tDivide the collection into two halves.\n2.\tRecursively sort each half.\n3.\tMerge the two sorted halves into a single sorted output.\n\nThe merge operation works by comparing the first element of each half, selecting the smaller one to be the next element in the output, and repeating the process until all elements have been merged. If one half is exhausted before the other, the remaining elements from the other half are appended to the output.\nThe time complexity of merge sort is O(N log N), where n is the number of elements in the collection. This makes it a very efficient sorting algorithm for large collections.\nMerge sort is a stable sorting algorithm, meaning that it preserves the relative order of equal elements in the input collection. It is also an in-place sorting algorithm, meaning that it does not require additional memory to sort the collection.\n\n## Adaptive Median Filter – Sorting Algorithms: \n### Insertion Sort:\nInsertion sort is a simple sorting algorithm that is efficient for small collections or partially sorted collections. It works by iterating over the collection and inserting each element into its correct position in the sorted output.\nHere's how insertion sort works:\n1.\tIterate through the collection from left to right.\n2.\tFor each element, compare it with the previous elements in the sorted output and insert it into its correct position.\n\nTo insert an element into the sorted output, we compare it with the previous elements from right to left, shifting each element to the right until we find the correct position for the new element. Once we have found the correct position, we insert the new element into that position.\n\nThe time complexity of insertion sort is O(N2), where n is the number of elements in the collection. This makes it less efficient than other sorting algorithms for large collections, but it can be very efficient for small or partially sorted collections.\n\nThe best case of insertion sort occurs when the input collection is already sorted or nearly sorted. In this case, the inner loop of the algorithm will never execute, and the time complexity of the algorithm becomes O(N), where n is the number of elements in the collection.\nWhen the input collection is already sorted, the algorithm simply iterates through the collection once, comparing each element with the previous element and inserting it in its correct position. Since each element is already in its correct position, no elements need to be shifted to the right, and the inner loop of the algorithm is never executed.\nInsertion sort is a stable sorting algorithm, meaning that it preserves the relative order of equal elements in the input collection. It is also an in-place sorting algorithm, meaning that it sorts the collection in place without requiring additional memory.\n### Quick Sort:\nQuick sort is a popular comparison-based sorting algorithm that uses the divide-and-conquer approach to sort a collection of elements. It works by partitioning the collection into two parts, based on a pivot element, and recursively sorting each part.\nHere's how quick sort works:\n1.\tChoose a pivot element from the collection.\n2.\tPartition the collection into two parts: elements smaller than the pivot and elements larger than the pivot.\n3.\tRecursively sort each part.\n4.\tCombine the sorted parts into a single sorted output.\n\nThe partition step works by selecting a pivot element and dividing the collection into two parts: elements smaller than the pivot and elements larger than the pivot. This can be done in various ways, such as selecting the first, last, or middle element as the pivot, or selecting a random element as the pivot. Once the partition is complete, the pivot element is in its final sorted position.\nThe time complexity of quick sort is O(N log N) on average and O(N2) in the worst case, where n is the number of elements in the collection. The worst case occurs when the pivot element is consistently chosen in a way that leads to an unbalanced partition, such as selecting the first or last element of a sorted or nearly sorted collection.\nQuick sort is a widely used sorting algorithm due to its efficiency and adaptability to different input distributions. It is also an in-place sorting algorithm, meaning that it sorts the collection in place without requiring additional memory.\n## Alpha-Trim Filter - Complexity: \nIt has two complexities due to the fact that the user chooses one of the two sorting algorithms, and each sorting algorithm has its complexity which is mentioned above. \n1. Using the Counting Sort Algorithm:\n   - O(Length * Width * (Counting Sort + Average + N2) ) \n\t\t= O(Length * Width * (N + K + N + N2) ) \n\t\t= O(Length * Width * (N2 + K))\n\t\t- Length: It is the number of pixels on the x-axis that represent the length of the image to be processed.\n\t\t- Width: It is the number of pixels on the y-axis that represent the width of the image to be processed.\n\t\t- N: It is the number of the neighboring elements, also known as the WindowSize, in the collection.\n\t\t- K: It is the range of values.\n\t\t- Average: It is a function that calculates the average of the sorted array which is small compared to the whole algorithm, so it is ignored.\n\n3.\tUsing the Merge Sort Algorithm:\n\t- O(Length * Width * (Merge Sort + Average + N2)) \n= O(Length * Width * ((N Log N) + N + N2))\n= O(Length * Width * N2)\n\t\t- Length: It is the number of pixels on the x-axis that represent the length of the image to be processed.\n\t\t- Width: It is the number of pixels on the y-axis that represent the width of the image to be processed.\n\t\t- N: It is the number of the neighboring elements, also known as the WindowSize, in the collection.\n\t\t- Average: It is a function that calculates the average of the sorted array which is small compared to the whole algorithm, so it is ignored. \n## Adaptive Median Filter - Complexity: \nIt has two complexities due to the fact that the user chooses one of the two sorting algorithms, and each sorting algorithm has its complexity which is mentioned above. \n1.\tUsing the Insertion Sort Algorithm: \n\t- O(Length * Width * (WindowSize/2)* (Insertion Sort + N2) ) \n= O(Length * Width * (WindowSize/2)* (N2 + N2)) \n= O(Length * Width * WindowSize * N2)\n\t\t- Length: It is the number of pixels on the x-axis that represent the length of the image to be processed.\n\t\t- Width: It is the number of pixels on the y-axis that represent the width of the image to be processed.\n\t\t- WindowSize: It is the threshold value that is used to decide the number of neighbouring values, and it is divided by two because it gets incremented by 2 after every iteration. \n\t\t- N: It is the number of the neighboring elements, also known as the WindowSize, in the collection.\n\n2.\tUsing the Quick Sort Algorithm:\n\t- O(Length * Width * (WindowSize/2)* (Quick Sort + N2)) \n= O(Length * Width * (WindowSize/2)* (N2 + N2)) \n= O(Length * Width * WindowSize * N2)\n\t\t- Length: It is the number of pixels on the x-axis that represent the length of the image to be processed.\n\t\t- Width: It is the number of pixels on the y-axis that represent the width of the image to be processed.\n\t\t- WindowSize: It is the threshold value that is used to decide the number of neighbouring values, and it is divided by two because it gets incremented by 2 after every iteration. \n\t\t- N: It is the number of the neighboring elements, also known as the WindowSize, in the collection.\n\n# Which Sorting Algorithm is Better?\n## Alpha-Trim Filter:\n\nCounting Sort is a better Sorting Algorithm to be used in the Alpha-Trim Filter. Since “K” ranges from 0 to 255 (Constant), then it is clear that using either Counting Sort or Merge Sort, the complexity is the same. However, using Merge Sort, there are a lot more N’s, so it makes computation much slower than using Counting Sort. Through numerous trials, we found out that using Counting Sort takes considerably less time.\n\n## Adaptive Median Filter:\n\nQuick Sort is a better Sorting Algorithm to be used in the Adaptive Median Filter. Since Quick Sort’s average case is O(N log N) and Insertion Sort’s average case is O(N2), Quick Sort is the choice to go with! Noting that the Alpha Median Filter has the same complexity with each Sorting Algorithm, Quick Sort is likely to reach the average and/or best case than Insertion Sort is likely to reach its best case because Insertion Sort requires that the Array is sorted for it to be the best case which is not likely! Through numerous trials, we found out that using Quick Sort takes considerably less time.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdulrahman-k-s%2Fimage_filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabdulrahman-k-s%2Fimage_filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabdulrahman-k-s%2Fimage_filter/lists"}