Problem while using encoding an image file with cyclic code
2 ビュー (過去 30 日間)
古いコメントを表示
I am trying to encode a image with cyclic channel coding. But apparently an error is coming when i ran this code. This is my code:
[X,map]= imread('xxxx.jpg');
msg = im2bw(X,map,0.3);
imshow(X,map), figure,
% m = 4; n = 2^m-1; % Codeword length = 15
% k = 11;
n=31;
k=2;
%codeLin = encode(msg(1,:),n,k,'linear/binary');
codeCyc = encode(msg,n,k,'cyclic/binary');
Error:
Undefined function 'floor' for input arguments of type 'logical'.
Error in encode (line 87)
if ~isempty([find(msg > 1); find(msg < 0); find(floor(msg)~=msg)]
apparently the function expecting other input ..but dont know what is the problem with matrix msg !!! Can anyone help with that? Thank you
0 件のコメント
回答 (1 件)
Geoff Hayes
2015 年 11 月 27 日
amit - is the encode function something that you have written or is it from the Communications System Toolbox? If the latter, then you may have to cast msg before passing it into the function. The output from im2bw will be a binary image of zeros and ones. The data type for each element in this image is logical.
The error message is telling you that because the data type of the input is logical then the call to floor fails since it is not defined for this type. Try casting the input as double instead
codeCyc = encode(double(msg),n,k,'cyclic/binary');
The input will still be binary (ones and zeros) but the call to floor will be defined for inputs of this type.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Import, Export, and Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!