what happens if i increase the kernel to 5x5 or to 7x7?is there anyway to write that in matlab code.?

3 次查看(过去 30 天)
i am trying to do a programming for what happens when we increase a kernel to 5x5 or to 7x7. please let me know how to do the matlab programming
  7 个评论
Sat m
Sat m 2013-3-5
i do not have any code so far.... i am searching for code to increase kernel size so far....still working on that....can you help me please?
Sat m
Sat m 2013-3-5
this is my code...but it is not working. i am trying to increase the kernel to 5x5 so that the image can be blurred
baseFile = 'violet.bmp';
origimage = imread('violet','bmp');
origimage = origimage(:,:,1);
figure, imagesc(origimage)
axis square
colormap gray
title('Original Image')
set(gca, 'XTick', [], 'YTick', [])
%Blur Kernel
ksize = 5;
kernel1 = zeros(ksize);
%Gaussian Blur
s = 3;
m = ksize/2;
[X, Y] = meshgrid(1:ksize);
kernel = (1/(2*pi*s^2))*exp(-((X-m).^2 + (Y-m).^2)/(2*s^2));
%Display Kernel
figure, imagesc(kernel)
axis square
title('Blur Kernel')
colormap gray
%Embeding kernel in image that is size of original image
[h, w] = size(origimage);
kernelimage = zeros(h,w);
kernelimage(1:ksize, 1:ksize) = kernel;
%Performing 2D FFTs
fftimage = fft2(double(origimage));
fftkernel = fft2(kernelimage);
%Set all zero values to minimum value
fftkernel(fftkernel == 0) = 1e-6;
%Multiply FFTs
fftblurimage = fftimage.*fftkernel;
%Perform Inverse 2D FFT
blurimage = ifft2(fftblurimage);
%Display Blurred Image
figure, imagesc(blurimage)
axis square
title('Blurred Image')
colormap gray
set(gca, 'XTick', [], 'YTick', [])

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2013-3-5
For example, to create median filtered images:
filtered5x5Image = medfilt2(grayImage, [5, 5]);
filtered7x7Image = medfilt2(grayImage, [7, 7]);
Call imshow() to display the results.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Red 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by