MyriadFilter
Compute the Myriad filtering for specific sample and parameters.
Contents
Definition.
For ,
and
the defined objective function is
The myriad filtering of sample with weights
and parameter
is defined as
The generalized myriad filtering of sample with weights
is defined as
Syntax.
filtred = MyriadFilter( X , gamma); [filtred, gamma] = MyriadFilter( X, gamma, ... ); filtred = MyriadFilter( X , []); [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: ,
.
Example: compute Myriad filtering with known
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'), snapnow
-------------------------- Call Myriad filter -------------------------- size image: 1 x 1 gamma= 5.000000 --------------------------

Example: compute Myriad filtering and estimate
parameter.
% Read image. init= imread('squared.png'); % Add Cauchy noise. gamma=5; input=addCauchyNoise(init, gamma); % Compute local samples with 6 radius window. sampleLocal= localSample(input, 6); % Compute Myriad filtering. tic [filtred, Gamma] = MyriadFilter(sampleLocal, []); toc % Plot the filtred image and the local $\gamma$ parameter estimation. figure, imshow(uint8(input)), title('Image with Cauchy noise.'), snapnow figure, imshow(uint8(filtred)), title('Myriad filtering'), snapnow figure, imagesc(Gamma), colormap jet, axis , snapnow
------------------------------ Call Generalized Myriad filter ------------------------------ size image: 256 x 256 -------------------------- Elapsed time is 2.402637 seconds.


ans = 0.5000 256.5000 0.5000 256.5000

Example: compute Myriad filtering and estimate
parameter with specific weights.
% Read image. init= imread('squared.png'); % Add Cauchy noise. gamma=5; input=addCauchyNoise(init, gamma); % Compute local samples with 6 radius window. [sampleFromPatches, weights] = kCauchyNearestPatches(input, gamma,... 'SampleSize', 40,... 'PatchWidth', 3,... 'SearchWindowRadius', 15); % Weights normalization. alpha = 0.01; weights = exp(alpha*weights); weights = weights ./ ... repmat(sum(weights, 3), [1,1, size(weights,3)]) * size(weights,3); % Compute Myriad filtering. tic [filtred, Gamma] = MyriadFilter(sampleFromPatches, [], 'Weights', weights); toc % Plot the filtred image and the local $\gamma$ parameter estimation. figure, imshow(uint8(input)), title('Image with Cauchy noise.'), snapnow figure, imshow(uint8(filtred)), title('Myriad filtering'), snapnow figure, imagesc(Gamma), colormap jet, axis off, axis image title('\gamma parameter.'), snapnow
------------------------------ Call Generalized Myriad filter ------------------------------ size image: 256 x 256 -------------------------- Elapsed time is 0.143233 seconds.



Input arguments.
- gamma is the parameter
of the Cauchy similarity measure between patches. Should be empty (=[]) is estimation is needeed.
- 'Weights' represents the weights of the Myriad filtering. Default value is a vector of 1.
- 'SampleSize' is the number of retained patches. Default value is 30.
- 'PatchWidth' is the width of the patches used for comparison. Default value is 5.
- 'SearchWindowRadius' is the radius of search window. Default value is 10.