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