Problem while using encoding an image file with cyclic code
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Geoff Hayes
on 27 Nov 2015
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 Comments
See Also
Categories
Find more on Import, Export, and Conversion 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!