point spread function in matlab

To obtain the Point Spread Function (PSF) in Matlab, you can use the fspecial function to generate a predefined filter such as a Gaussian, or you can create an arbitrary PSF. After defining the PSF, you can use the conv2 function to perform the 2D convolution of the PSF with an input image. The Fourier transform can also be used to obtain the PSF of an imaging system.

Here is an example code snippet that generates a Gaussian PSF with a standard deviation of 2 pixels and convolves it with a grayscale image:

main.m
% Define the Gaussian PSF
PSF = fspecial('gaussian', [11, 11], 2);

% Load the image
I = imread('image.jpg');
I = im2double(rgb2gray(I));

% Convolve the image with the PSF
I_conv = conv2(I, PSF, 'same');

% Display the original and convolved image
figure;
subplot(1,2,1); imshow(I); title('Original Image');
subplot(1,2,2); imshow(I_conv); title('Convolved Image');
367 chars
15 lines

Note that the conv2 function is used with the 'same' option to ensure that the output has the same size as the input image.

gistlibby LogSnag