Using Euclidean Distance in Resizable Filter Window for Noise Reduction

6 views (last 30 days)
Hi.
I am trying to generate an resizable matrix (3×3), (5×5), ..., etc. Used as a kernel that sliding on a an image from right to left and from top to bottom ( I can sliding this kernel by using conv2 function ). But I want to use the euclidean distance to calculate the distances between the central pixel and the rest of pixels inside this window or kernel and then replace the central pixel with the closest pixel to the center according to euclidean distance.
If I define the kernel as the for loop below, how can I create euclidean distance function for this purpose?
n = inpute('inter the value of n');
for i = 1:n
for j=1:n
%%%% using ecladian distinct function to calculate distance between center and other window pixels
end
end
and then using this kernel to remove gaussian noise as shown below
Original_Image = imread('any color image');
Noisy_Image = imnoise(Original_Image, 'gaussian', 0, 0.01);
Noise_R = Noisy_Image(:,:,1);
Noise_G = Noisy_Image(:,:,2);
Noise_B = Noisy_Image(:,:,3);
New_R = conv2((Noise_R), Kernel, 'same');
New_G = conv2((Noise_G), Kernel, 'same');
New_B = conv2((Noise_B), Kernel, 'same');
New_Image = cat(3, New_R, New_G, New_B);
montage({Original_Image, Noisy_Image, New_Image})
thanks a lot

Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!