related to image processing

1 回表示 (過去 30 日間)
aman
aman 2014 年 3 月 13 日
コメント済み: Image Analyst 2014 年 3 月 13 日
hi, I have made the following program which is used for refinement in image coding. mark=zeros(1,4); out1=zeros(1,4); out=zeros(1,4); x=[1 3 7 8]; for n=3:-1:1; t=2^n; for i=1:4; if (x(i)>=t);
switch mark(i)
case 0
out1(i)=sign(x(i));
mark(i)=1;
case 1
z=dec2bin(x(i),4);
out1(i)=z(1);
mark(i)=2;
case 2
z1=dec2bin(x(i),4);
out1(i)=z1(2);
mark(i)=3;
otherwise
end
else
out1(i)=0;
end
end
end
when I run this program I get finally out1 as 0 1 48 48 . Instead I should get 0 1 0 0. Can any body tell me what is the problem with my program.
  2 件のコメント
John D'Errico
John D'Errico 2014 年 3 月 13 日
編集済み: John D'Errico 2014 年 3 月 13 日
Please don't title every post of yours exactly the same "related to image processing". This is confusing and it does not help anyone else who may be able to learn from your post.
As well, please don't ask the same question twice!
Image Analyst
Image Analyst 2014 年 3 月 13 日

サインインしてコメントする。

採用された回答

Mischa Kim
Mischa Kim 2014 年 3 月 13 日
Aman, use
out1(i) = str2num(z(1));
instead (and similar for the other out1(i) command. dec2bin outputs a string, which you need to convert back to numeric format.
  1 件のコメント
aman
aman 2014 年 3 月 13 日
Thanks a lot. God bless you.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by