What is the issue in my dictionary map in matlab?
5 views (last 30 days)
Show older comments
Hi
I wrote this code in matlab to take an image and convert it into a vector of integers these numbers I put it in dictionary map the key value I want it to be a string of the numbers from 0 to 255. Therefore, I convert the number to a string and put it as a key to the dictionary why I have these two errors below and how to fix it please
if true
%
[filename pathname] = uigetfile({'*.tiff';'*.bmp'},'File Selector');
image=strcat(pathname,filename);
pic=imread(image);
Imgvector=pic(:);
c=256;
for j=0:255
d=int2str(j);
DictionaryMap(d)=j;
end
keyset=keys(DictionaryMap);
disp(keyset);
ws=Imgvector(1);
for i=2:length(Imgvector)
w=Imgvector(i);
w=int2str(w);
ws=strcat(ws,w);
tf=iskey(DictionaryMap,ws);
if tf==1
elseif tf==0
c=c+1;
ms=ws;
DictionaryMap(ms)=c;
ws=str(2:end);
end
end
end
and I got these two errors:
1.??? Undefined function or method 'keys' for input arguments of type 'double'. in this line: keyset=keys(DictionaryMap);
2.??? Undefined function or method 'iskey' for input arguments of type 'double'. in this line tf=iskey(DictionaryMap,ws);
Regards Wadoo
0 Comments
Accepted Answer
Walter Roberson
on 11 May 2013
mapObj Object of class containers.Map.
However, your variable DictionaryMap is not a container.Map . You did not initialize DictionaryMap, so as usual for MATLAB, it defaults to type double()
4 Comments
More Answers (1)
students
on 16 Mar 2014
Dear Wadha can you resend the code after solving the errors i am a student and the doctor asks us to do something simillar to your work can you please help me to understand the code because my information in Matlab is not very good, but what i understand that this is only the encoder part of the LZW compression , what about the decoder if you had any idea please help me, thanks
0 Comments
See Also
Categories
Find more on Dictionaries in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!