CSE logo University of Washington Computer Science & Engineering
 SKL file format
  CSE Home   About Us    Search    Contact Info 
 
<back to spatially variant non-blind deconvolution>
 
Loading and Saving the Blur Matrix in the .skl format
 
The blur matrix, K, for an image of size n pixels is an nXn matrix where each row corresponds to the vectorized blur kernel for that particular pixel of the vectorized image. The blurred image is the result of multiplying a vectorized form of the latent image, L, with K. This is commonly written as -
B = K L
where K is the blur matrix, L is the latent image and B is the blurred image.
 
The matrix K is very sparse since the size of the blur kernel is quite small compared to the image. For our non-blind deconvolution executable, we assume that the matrix has been stored in a special format which we now explain.
 
Representation of a sparse matrix
 
We define two structures which store the sparse blur matrix.
 
/*
 * mData
 * - size = number of non-zero entries
 * - linear array which stores the non-zero entries of the matrix in a row-major order.
 * columns
 * - size = number of non-zero entries
 * - columns(i) = column in which the i'th element of mData occurs in the matrix.
 * rowIndex
 * - size = number of rows + 1.
 * - rowIndex(i) = The position of the first non-zero element in the i'th row of the matrix in the mData array. The last element of this array is (number of non-zero entries)+1.
*/
 
typedef struct tag_SPARSE_MATRIX_STRUCT {
   int eleNum; // number of non-zero entries
   int rowNum; // number of rows
   int colNum; // number of columns
   double * mData;
   int * columns;
   int * rowIndex;
} SparseMatrix;
 
typedef struct tag_SPATIALLY_VARIANT_SPARSE_KERNEL_STRUCT {
   int imWidth;
   int imHeight;
   int kw;
   int kh;
   SparseMatrix sparseKernelMatrix;
} SpvKernelSparse;
 
An example matrix written in this format is shown in the figure below:
 
Sparse matrix:
 
[ 1  -1  0  -3  0
  -2  5  0  0  0
  0   0  4  6  4
  -4  0  2  7  0
  0  8  0  0  -5 ]
 
Representation:
 
eleNum = 13    
rowNum = 5
colNum = 5
mData = [1; -1; -3; -2; 5; 4; 6; 4; -4; 2; 7; 8; -5]
columns = [1; 2; 4; 1; 2; 3; 4; 5; 1; 3; 4; 2; 5]
rowIndex = [1; 4; 6; 9; 12; 14]
 
The following is a wrapper structure to use the above sparse matrix in the deconvolution framework.
 
typedef struct tag_SPATIALLY_VARIANT_SPARSE_KERNEL_STRUCT {
   int imWidth; // image width
   int imHeight; // image height
   int kw; // max blur kernel width  (approximate measure)
   int kh; // max blur kernel height (approximate measure)

   SparseMatrix sparseKernelMatrix;

} SpvKernelSparse;

File format
 
We provide here two functions in C++ to save and load the SpvKernelSparse object to and from binary files. Basically, for saving the object, the code just writes all the values in the structure sequentially as a binary file and loads accordingly. In case you want to write your own code, please use the code snippets as reference.
 
<Link to the code snippets>


CSE logo Computer Science & Engineeringg
Box 352350, University of Washington
Seattle, WA  98195-2350
(206) 543-1695
[comments to Qi Shan]
Privacy policy and terms of use