How to creat a sparse matrix?

sir,i have an image and want to find out its "SPARSE-MATRIX".i have tried the code like S=sparse(a);where 'a' is my image.but i got an error like "Undefined function or method 'sparse' for input arguments of type 'uint8'."MY AIM IS JUST TO FIND OUT THE SPARSE MATRIX OF THE IMAGE.Thanks in advance

답변 (1개)

Youssef  Khmou
Youssef Khmou 2013년 5월 18일

0 개 추천

hi,
i think you have to transform your matrix from Unsigned integer 8 to double, try :
G=sparse(im2double(a)); % or simply double(a)

댓글 수: 4

jagannath mishra
jagannath mishra 2013년 5월 19일
i am using it and it also give me outputs without error.thank you very much.
Youssef  Khmou
Youssef Khmou 2013년 5월 19일
편집: Youssef Khmou 2013년 5월 19일
hi jagannath,
I think it works, here is an example using the picture 'circuit.tf' whose class is uint8 :
I=imread('circuit.tif');
G=sparse(im2double(I));
jagannath mishra
jagannath mishra 2013년 5월 20일
편집: jagannath mishra 2013년 5월 20일
but sir the image while converting to double it lost data and becomes white .this is the url of my original image"http://tinypic.com/r/1hotvo/5"and after applying the double it will be like "http://tinypic.com/r/f57lg7/5".so i want to ask if i finding out its sparse is correct or is there any problem with my implimentation of program .
the result you have is something else different, maybe you are applying binary transformation, try :
I=imread('test.jpg'); % where test.jpg is your sample
doubleI=im2double(I);
F=rgb2gray(doubleI);
G=sparse(F);

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

카테고리

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

제품

질문:

2013년 5월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by