Perform 3x3, 5x5 and 11x11 average filtering of the noisy the image in ImageSet3 ( image attached below). Do median filtering on the same data using 3x3,5x5 and 11x11 kernels. Compare your results.
You may use the matlab built-in functions/library to expedite your work
3*3 Average Filtering:
windowSize = 3; % Whatever odd number you want. Larger = more
blur.
kernel = ones(windowSize) / windowSize ^ 2 ;
y = imread('ImageSet3.png');
blurredImage = conv2(single(y), kernel, 'same');
imshow(blurredImage, []); % or imshow(uint8(blurredImage), [0
255]);
3*3 Averaged image:
:
5*5 Average Filtering:
windowSize = 5; % Whatever odd number you want. Larger = more
blur.
kernel = ones(windowSize) / windowSize ^ 2 ;
y = imread('ImageSet3.png');
blurredImage = conv2(single(y), kernel, 'same');
imshow(blurredImage, []); % or imshow(uint8(blurredImage), [0
255]);
5*5 averaged image:
11*11 Average Filtering:
windowSize = 11; % Whatever odd number you want. Larger = more
blur.
kernel = ones(windowSize) / windowSize ^ 2 ;
y = imread('ImageSet3.png');
blurredImage = conv2(single(y), kernel, 'same');
imshow(blurredImage, []); % or imshow(uint8(blurredImage), [0
255]);
11*11 averaged image:
3*3 Median Filtering:
I = imread('ImageSet3.png'); % Reading an Image
display(size(I)); %Shows the Size of read Image
figure,imshow(I);title('Grayscale Image'); %Shows the read
Image
%DEFINE THE WINDOW SIZE MXN
M=3;
N=3;
%PAD THE MATRIX WITH ZEROS ON ALL SIDES
modifyA=padarray(I,[floor(M/2),floor(N/2)]); %%padarray is a
builtin matlab
%%function to pad zeros and floor function rounds the number to
negative infinite, as M=3
%%N =3 , M/2 = N/2 = 1.5 which when floor applied to them gives 1
as
%%floor(1.5) is 1. So kernel matrix size is 1*1, so 0 is padded to
the
%%image
figure,imshow(uint8(modifyA)); title('PADDED WITH ZEROS'); %This is
the Zero Paddedimage
%%Median is the middle point of the series. The index that is
obtained by dividing the total number of elements in a window by 2
gives the position.
B = zeros([size(I,1) size(I,2)]);
med_indx = round((M*N)/2); %MEDIAN INDEX
%%A sliding window of size M x N is used and the elements in the
window are sorted and the middle element from the sorted array is
chosen.
for i=1:size(modifyA,1)-(M-1)
for j=1:size(modifyA,2)-(N-1)
temp=modifyA(i:i+(M-1),j:j+(N-1),:);
tmp_sort = sort(temp(:));%tmp(:) converts 2D matrix to 1D
matrix
B(i,j) = tmp_sort(med_indx);
end
end
%CONVERT THE IMAGE TO UINT8 FORMAT.
B=uint8(B);
figure,imshow(B);
title('IMAGE AFTER MEDIAN FILTERING');
3*3 Median Filtered Image:
5*5 Median Filtering:
I = imread('ImageSet3.png');
display(size(I));
figure,imshow(I);title('Grayscale Image');
%DEFINE THE WINDOW SIZE MXN
M=5;
N=5;
%PAD THE MATRIX WITH ZEROS ON ALL SIDES
modifyA=padarray(I,[floor(M/2),floor(N/2)]);
%%padarray is a builtin matlab
%%function to pad zeros and floor function rounds the number to
negative infinite, as M=3
%%N =5 , M/2 = N/2 = 2.5 which when floor applied to them gives 1
as
%%floor(2.5) is 2. So kernel matrix size is 2*2, so zero matrix of
size 2*2 is padded to the
%%image
figure,imshow(uint8(modifyA)); title('PADDED WITH ZEROS');
%%Median is the middle point of the series. The index that is
obtained by dividing the total number of elements in a window by 2
gives the position.
B = zeros([size(I,1) size(I,2)]);
med_indx = round((M*N)/2); %MEDIAN INDEX
%%A sliding window of size M x N is used and the elements in the
window are sorted and the middle element from the sorted array is
chosen.
for i=1:size(modifyA,1)-(M-1)
for j=1:size(modifyA,2)-(N-1)
temp=modifyA(i:i+(M-1),j:j+(N-1),:);
tmp_sort = sort(temp(:));%tmp(:) converts 2D matrix to 1D
matrix
B(i,j) = tmp_sort(med_indx);
end
end
%CONVERT THE IMAGE TO UINT8 FORMAT.
B=uint8(B);
figure,imshow(B);
title('IMAGE AFTER MEDIAN FILTERING');
5*5 Median Filtered Image:
11*11 Median Filtering:
I = imread('ImageSet3.png');
display(size(I));
figure,imshow(I);title('Grayscale Image');
%DEFINE THE WINDOW SIZE MXN
M=11;
N=11;
%PAD THE MATRIX WITH ZEROS ON ALL SIDES
modifyA=padarray(I,[floor(M/2),floor(N/2)]);
%%padarray is a builtin matlab
%%function to pad zeros and floor function rounds the number to
negative infinite, as M=3
%%N =5 , M/2 = N/2 = 2.5 which when floor applied to them gives 1
as
%%floor(2.5) is 2. So kernel matrix size is 2*2, so zero matrix of
size 2*2 is padded to the
%%image
figure,imshow(uint8(modifyA)); title('PADDED WITH ZEROS');
%%Median is the middle point of the series. The index that is
obtained by dividing the total number of elements in a window by 2
gives the position.
B = zeros([size(I,1) size(I,2)]);
med_indx = round((M*N)/2); %MEDIAN INDEX
%%A sliding window of size M x N is used and the elements in the
window are sorted and the middle element from the sorted array is
chosen.
for i=1:size(modifyA,1)-(M-1)
for j=1:size(modifyA,2)-(N-1)
temp=modifyA(i:i+(M-1),j:j+(N-1),:);
tmp_sort = sort(temp(:));%tmp(:) converts 2D matrix to 1D
matrix
B(i,j) = tmp_sort(med_indx);
end
end
%CONVERT THE IMAGE TO UINT8 FORMAT.
B=uint8(B);
figure,imshow(B);
title('IMAGE AFTER MEDIAN FILTERING');
11*11 Median Filtered Image:
Perform 3x3, 5x5 and 11x11 average filtering of the noisy the image in ImageSet3 ( image attached...
The purpose of the project is to perform a timing experiment. You are required to complete the following activities: Write a computer program that prompts the user for a number, creates an array for that number of random integers, and then usees the bubble sort to order the array. The program should print out the array prior to the call to the sorting algorithm and afterwards. You can write the program in either Java, C++, C#, or whatever language you...
Task 2: (2 Marks) Noisy Image Restoration You have been provided with seven images named IMG-5698. JPG to IMG-5704. JPG. These images were taken in low light conditions with a very high ISO setting which results in "noise" on the image (random fluctuations in pixel intensity) and "bright pixels" (pixels which appear bright in every image, despite not being hit by light) In addition to the seven source images you are also provided with a "dark frame", dark.png. This is...
PLEASE DO BOTH #5 AND #6. The purpose of the project is to perform a timing experiment. You are required to complete the following activities: Write a computer program that prompts the user for a number, creates an array for that number of random integers, and then usees the bubble sort to order the array. The program should print out the array prior to the call to the sorting algorithm and afterwards. You can write the program in either Java,...
1. [12 marks] In the following parts of this question, write a MATLAB code to solve a linear system A b (A is a square nonsingular matrix) using Jacobi and Gauss-Seidel algorithms. Do not use the built-in Matlab functions for solving linear systems (a) Write a Matlab function called Jacobi that consumes a square n x n matrix A, and an n x 1 vector b, and uses the Jacobi technique to solve the system Ax-b, starting with the zero...
2. Consider interpolating the data (x0,yo), . . . , (x64%) given by Xi | 0.1 | 0.15 | 0.2 | 0.3 | 0.35 | 0.5 | 0.75 yi 4.0 1.0 1.22.12.02.52.5 For all tasks below, please submit your MATLAB code and your plots. You can write all code in a single (a) Using MATLAB, plot the interpolating (6th degree) polynomial given these data on the domain .m-file [0.1,0.75] using the polyfit and polyval commands. To learn how to use...
solve part B
Note: Do not use MATLAB (or other programming languages) build-in functions for regression. (a) Write a MATLAB (or other programming languages) function that accepts n values of xi and Yi, perform Linear Regression and returns values of rand, the model parameters ao and a. (6) Write another MATLAB (or other programming languages) function that accepts n values of X, and y(provided as arrays), checks for Linear, Power (y = axBx) and Saturation growth- rate (y = a*)...
52.1 Three primary statistics are used to describe a variable's central tendency, defined as the average behavior of the variable. You can use these statistics, known as the mean, the median, and the mode, to draw meaningful conclusions about a variable's past behavior and to predict its future behaviar An investor is considering a stock with the following returns over the past 12 years: Year Annual Return Year Annual Return 12 10 12 The mean, also known as the arithmetic...
I need the answers for 6 and 7. Attached below is my work for
1-5. Thank you.
My work:
PART III Average rate of change of exponential functions near zero. (5) 1. Given f(x)- 2", find the average rate of change of f(x) fromx - 0 tox -0.1, so that Ax -0.1. Recall that the average rate of change is Show your steps and write your Δι answer on the first line of the table below. (5) 2. Continue finding...
the picture above is the one you are supposed to use for the
MATlab code please help
Problems. Grayscale images are composed of a 2D matrix of light intensities from O (Black) to 255 (White). In this lab you will be using grayscale images and do 2D-array operations along with loops and iflelse branches. 1. We can regard 2D grayscale images as 2D arrays. Now load the provided image of scientists at the Solvay Conference in 1927 using the imread)...
5A1: Analyzing Lab Results In the table below are the results from four analytical labs, each of which analyzed the same soil sample for its benzene content. The actual concentration of benzene in the soil is 25 ppt Reported Concentration of Benzene in a Soil Sample (ppb) Replicate Lab Lab Lab Lab 25 1. Compare the four sets of data a. Which lab do you think has the most accurate data? b. Which lab has the most precise data? c....