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!