how to sparse represent a image?
15 views (last 30 days)
i'm trying to create a sparse matrix for an image.
i've given the command as,
i'm getting the output for the first command and for the second command i'm getting a error as mentioned below,
Undefined function 'sparse' for input arguments of type 'uint8'
please help thanks in advance
Shoaibur Rahman on 27 Dec 2014
Convert a to double first, and the use that in sparse. Make sure that a is not in 3D, if so, then make it 2D before using in sparse.
a = double(a);
b = sparse(a); % for 3D a, you may use b = sparse(a(:,:,1)); or 2 or 3 instead of 1 here.
spy(b) % see the sparsity pattern