MyriadFilter

Compute the Myriad filtering for specific sample and parameters.

Contents

Definition.

For $\gamma \in R$, $w=(w_1, \dots, w_n) \in R^n$ and $X=(x_1, \dots, x_n) \in R^n$ the defined objective function is

$$f(\theta, \gamma) = \sum_{i=1}^n \log(\gamma ^2 + w_i (x_i - \theta)^2)$$

The myriad filtering of sample $X$ with weights $w$ and parameter $\gamma$ is defined as

$$\hat \theta = {argmin }_{\theta \in R} f(\theta, \gamma)$$

The generalized myriad filtering of sample $X$ with weights $w$ is defined as

$$(\hat \theta, \hat \gamma) = {argmin }_{(\theta, \gamma) \in R^2} f(\theta, \gamma)$$

Syntax.

filtred = MyriadFilter( X , gamma);
[filtred, gamma] = MyriadFilter( X );

Description.

filtred = MyriadFilter( X, gamma ) computes the myriad filtering of sample vector X with parameter gamma.

[filtred, gamma] = MyriadFilter( X ) computes the generalized myriad filtering of sample vector X and estimates the parameter gamma for each pixel.

X is a three dimensional matrix of size MxNxK. MxN is the image size. K is the size sample in each pixel.

Values of weights: $\forall i$, $w_i=1$.

Example: compute Myriad filtering with known $\gamma$ parameter.

% Define parameter.
gamma= 5;

% Define a sample.
sample_in_one_pixel = [64 47 56 56 57 69 56 61 47 48 50 49 44 63 50 55 61 38 51 62];

% Make a one-pixel sample.
sample_in_one_pixel=...
    reshape(sample_in_one_pixel, [1, 1, length(sample_in_one_pixel(:))]);

% Compute Myriad filtering.
filtred = MyriadFilter(sample_in_one_pixel, gamma);

% Compute the objective function for drawing.
[Q,t] = ComputeObjectiveFunction(sample_in_one_pixel,...
                                                     'Gamma', gamma);

% Compute the objective function for the Myriad filter output.
[y,x] = ComputeObjectiveFunction(sample_in_one_pixel,...
                                                     'Gamma', gamma,...
                                                     'Theta', filtred);

% Compute the objective function for sample points.
[ y1, x1 ] = ComputeObjectiveFunction( sample_in_one_pixel ,...
                                        'Theta', sample_in_one_pixel,...
                                        'Gamma', gamma);

% Draw the objective function and the interest points.
figure, plot(t, Q), hold on,  plot(x1(:), y1(:), 'x','Color', [0,100,0]/255)
plot(x, y, 'or')
legend('Objective function',...
       'Sample points',...
       'Myriad filtering of the sample')
--------------------------
Call Myriad filter
--------------------------
size image:	 1 x 1 
gamma=		 5.000000 
--------------------------

Example: compute Myriad filtering and estimate $\gamma$ parameter.

% 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 Myriad filtering.
[filtred, Gamma] = MyriadFilter(sampleLocal);

% Plot the filtred image and the local $\gamma$ parameter estimation.
figure, imshow(uint8(filtred)), title('Myriad filtering')
figure, imagesc(Gamma), colormap jet, axis off, axis image
        title('\gamma parameter.')
------------------------------
Call Generalized Myriad filter
------------------------------
size image:	 256 x 256 
--------------------------