hi,
i'm trying to create a sparse matrix for an image.
i've given the command as,
a=imread('imagename.format')
b=sparse(a)
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
Shoaibur Rahman 2014년 12월 27일

2 개 추천

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

댓글 수: 4

lohith
lohith 2014년 12월 27일
thank you very much :)
Isra Anwar
Isra Anwar 2016년 3월 17일
This code is not working on pgm (greymap images) what should I be changing in this code to get a sparse representation of a grey image?
Guillaume
Guillaume 2016년 3월 17일
편집: Guillaume 2016년 3월 17일
@Isra, I suggest you start your own question posting the exact code you're using and explaining what 'not working' means exactly (you get an error? if so, which? no error but not the output you want? if so what output do you want? etc.)
Snigdha KN
Snigdha KN 2017년 1월 26일
This code shows an error when executed. It shows undefined function 'sparse' for argument type 'double'

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Sparse Matrices에 대해 자세히 알아보기

질문:

2014년 12월 27일

댓글:

2017년 1월 26일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by