This example illustrates the use of the method
Self Projected Matching Pursuit in 2D (SPMP2D), for approximating images.
The details of the algorithm are given in the paper:

'Sparse Representations of Astronomical Images'

by L. Rebollo-Neira and J. Bowley
The example can also be realised with the technique
Orthogonal Matching Pursuit in 2D (OMP2D).
The dictionary used in this example is specially designed to approximate
astronomical images in the categories of nebulae, galaxies and stars.
It is composed of a Redundant Discrete Cosine component and a
Redundant Discrete B-Spline based component.

The approximation error is set to produce a perceptually indistinguishable approximation
of the image. This is achieved for PSNR = 50dB and Mean Structural Similarity Index = 1.00.
The Sparsity Ratio (SR) yielded by the proposed dictionary is SR = 9.79, which represents a
massive gain with respect to the result obtained if the approximation is realised by the
Discrete Wavelet Transform (SR = 3.69).

All the source files for the routines to run the example in MATLAB are available in the archive SPAI.zip which demonstrates the use
of the routines SPMP2D and OMP2D for approximating images. The function Example.m, which runs the example shown below, is contained within the SPAI/MATLAB/Web/SPAI/ directory. The approximation is performed on the, "Spiral Galaxy NGC 4945" image, kindly provided by European Southern Observatory (ESO) website

For decreasing the execution time compile the C++ MEX versions of SPMP2D named SPMP2D_Mex and
the C++ MEX versions of OMP2D named OMP2D_Mex by calling the script SPAI/MATLAB/Web/SPAI/UseMex.m.

function Example
imagePath = '../../../Corpus/Images/Hubble_Top_100/Web/eso0931a_sc.jpg';
method = 1;
szBlock = 8;
useMEX = 0;
blockPSNR = 48.01;
ExamplePaths(0);
[mImApprox,PSNR,SSIM,SR,execTime,mIm] = ImApproxGreyW(imagePath,szBlock,method,useMEX,blockPSNR);
ExamplePaths(1);
fprintf('\n\nResults of approximation taking %.2f seconds\n',execTime);
fprintf(' Sparsity Ratio (SR) -> %.2f\n',SR);
fprintf(' Peak Signal to Noise Ratio (PSNR) -> %.2fdB\n',PSNR);
fprintf(' Mean Structural Similarity Index (MSSIM) -> %.2f\n',SSIM);
figure;imshow(uint8(mIm'));
figure;imshow(uint8(mImApprox'));

Results of approximation taking 89.81 seconds
Sparsity Ratio (SR) -> 9.79
Peak Signal to Noise Ratio (PSNR) -> 50.00dB
Mean Structural Similarity Index (MSSIM) -> 1.00
Original Image

Approximated Image