Department of Software Engineering
University of Sialkot
Assignment #2
Submitted By:
Name Hammad
Roll No. 20101001-166
Section Yellow
Semester 8th
Submitted To:
Ma’am Azka Mir
Submission date: 07th , 2024
Task 1 Using any image that has been corrupted by salt and pepper noise, your
goal is to implement a MATLAB algorithm that effectively removes this type of
noise while preserving the important details of the image. Write the process and
evaluate the performance of each algorithm. Finally, write your observations
and display the denoised image and noisy image.
Process:
• To begin with, Studied the loud picture from a record named "boisterous [Link]" and store it
within the variable I..
• At that point, we get the number of lines (r) and columns (c) of the picture I..
• At that point, we Initialize the yield picture J with the same values as the input picture I..
• At that point, we apply for circles to iterate over each pixel within the picture, barring the border
pixels to dodge boundary issues.
• For each pixel at position (i,j), extricate the 3x3 neighborhood centered at (i, j).Performance of
algorithm.
• Sort the values within the neighborhood.
• Set the pixel esteem at (i,j) within the yield picture J to the middle esteem of the sorted
neighborhood, which is the center esteem (5th component within the sorted list).
• Then, we change over the output image J from twofold to uint8 organize for legitimate show.
• At that point, we show the initial boisterous picture within the to begin with subplot (position
2,3,1) and show the sifted picture within the moment subplot (position 2,3,2).
This algorithm is called median filtering. And it removes the salt and pepper noise efficiently.
Result screenshot:
Task 2 Take any image that has been corrupted with gaussian noise. Your
objective is to develop a MATLAB algorithm that restores the image to its
original quality by reducing the gaussian noise. You can explore various
algorithms and compare the results of each method. Write your observations
and analyze their effectiveness in the noise reduction. Finally, display the
denoised image and noisy image?
I. Average filter:
First, we use average filter for reducing noise from image. The step to apply this method are:
Sure, here are the steps without the code:
1. Stack the picture record into MATLAB.
2. Check in case the picture is colored (RGB). On the off chance that so, changeover it to
grayscale.
3. Change over the picture information to twofold accuracy for preparing.
4. Decide the number of lines and columns within the picture.
5. Make a network to store the sifted picture, initialized to zeros.
6. Circle through each pixel of the picture (barring the borders).
- For each pixel, calculate the normal esteem of its 3x3 neighborhood.
- Dole out the normal esteem to the comparing pixel within the sifted picture network.
7. Change over the sifted picture framework back to uint8 format for show.
8. Show the first loud picture.
- Show the sifted (denoised) picture for comparison.
Result:
II. Min filter:
Now, we apply min channel on the picture. The steps are:
1. Stack the picture record into MATLAB.
2. Change over the picture to grayscale.
3. Change over the grayscale picture information to twofold accuracy for preparing.
4. Set the channel measure to 3x3.
5. Calculate the cushioning estimate, which is half the channel estimate.
6. Make a lattice min_filter to store the sifted picture, initialized to zeros and with the same
measure as the grayscale picture.
7. Circle through each pixel of the picture (barring the borders).
8. For each pixel, calculate the least esteem inside its 3x3 neighborhood.
9. Allot this least esteem to the comparing pixel within the min_filter matrix.
10. Show the first boisterous picture.
11. Show the picture after applying the least channel.
Result:
III. Max filter:
Thirdly we apply max filter to evacuate commotion. Its steps are:
1. Stack the picture record into MATLAB.
2. Change over the picture to grayscale.
3. Change over the grayscale picture information to twofold accuracy for preparing.
4. Set the channel estimate to 3x3.
5. Calculate the cushioning estimate, which is half the channel estimate.
6. Make a lattice max_filter to store the sifted picture, initialized to zeros and with the same
estimate as the grayscale picture.
7. Circle through each pixel of the picture (barring the borders).
8. For each pixel, calculate the most extreme esteem inside its 3x3 neighborhood.
9. Dole out this most extreme esteem to the comparing pixel within the max_filter matrix.
10. Show the initial loud picture.
11. Show the picture after applying the Max filter.
Result:
IV. Median filter:
Presently, we apply median filter on picture. Its steps are:
1. Stack the picture record into MATLAB.
2. Change over the picture to grayscale.
3. Change over the grayscale picture information to twofold exactness for preparing.
4. Set the channel estimate to 3x3.
5. Calculate the cushioning estimate, which is half the channel measure.
6. Make a network median_filter to store the sifted picture, initialized to zeros and with the same
estimate as the grayscale picture.
7. Circle through each pixel of the picture (barring the borders).
8. For each pixel, calculate the middle esteem inside its 3x3 neighborhood.
9. Allot this middle esteem to the comparing pixel within the median_filter matrix.
10. Show the first loud picture.
11. Show the picture after applying the median filter.
Result:
Comparison:
Average filter, min filter, max filter, and median filter all aim to remove noise, but they differ in
their approach and effectiveness. Median filter is typically better at preserving edges compared to
average, min, and max filters. Median filter is also better at preserving fine details in the image.
Median filter can be computationally more expensive compared to average, min, and max filters,
especially for larger filter sizes. The choice of filter depends on the specific characteristics of the noise
and the desired trade-off between noise reduction and preservation of image details. Median filter is often
preferred when preserving edges and fine details is crucial, while average, min, and max filters can be used
for simpler noise reduction tasks.