localSample

Extract the neighborhood of a pixel.

Contents

Syntax.

sample = localSample( X, r );

Description.

sample = localSample( X, r ) returns, for each pixel of the image, the values of the pixels in a search window of radius r around the pixel.

Example: compute a median filtering.

% Read image.
init= imread('squared.png');

% Add Cauchy noise and display.
gamma=5;
input=addCauchyNoise(init, gamma);
figure, imshow(uint8(input)), title('Image with Cauchy noise.')

% Compute local samples with 6 radius window.
sampleLocal=  localSample(input, 6);

% Compute median filtering.
filtred = median(sampleLocal,3);

% Plot the filtred image.
figure, imshow(uint8(filtred)), title('Median filtering')