blur an image of a mandrill in matlab

To blur an image of a mandrill in Matlab, you can follow these steps:

  1. Load the image using imread function
  2. Convert the image to grayscale using rgb2gray function
  3. Create a Gaussian filter using fspecial function
  4. Apply the filter to the grayscale image using imfilter function

Here's the code:

main.m
% Load the image
im = imread('mandrill.png');

% Convert to grayscale
im_gray = rgb2gray(im);

% Create a Gaussian filter
h = fspecial('gaussian', [5 5], 2);

% Apply the filter
im_blur = imfilter(im_gray, h);

% Display the original and blurred images
figure
subplot(1, 2, 1)
imshow(im_gray)
title('Original Image')

subplot(1, 2, 2)
imshow(im_blur)
title('Blurred Image')
374 chars
22 lines

You can adjust the size and standard deviation of the Gaussian filter to control the amount of blur in the image.

related categories

gistlibby LogSnag