Errors occurred during parsing of MATLAB function

6 ビュー (過去 30 日間)
hanaa
hanaa 2014 年 7 月 15 日
コメント済み: hanaa 2014 年 7 月 18 日
I'm trying to run SPIHT algorithm without arithmetic coding with Matlab function block, an error occurred: Errors occurred during parsing of MATLAB function 'MATLAB Function'(#24) Component: MATLAB Function | Category: Coder error
below the function code:
function func_SPIHT_Main
% Matlab implementation of SPIHT (without Arithmatic coding stage)
%
% Main function
%
% input: Orig_I : the original image.
% rate : bits per pixel
% output: img_spiht
%
fprintf('----------- Welcome to SPIHT Matlab Demo! ----------------\n');
fprintf('----------- Load Image ----------------\n');
infilename = '11.bmp';
outfilename = '1_reconstruct.bmp';
Orig_I = double(imread(infilename));
rate = 1;
OrigSize = size(Orig_I, 1);
max_bits = floor(rate * OrigSize^2);
OutSize = OrigSize;
image_spiht = zeros(size(Orig_I));
[nRow, nColumn] = size(Orig_I);
fprintf('done!\n');
fprintf('----------- Wavelet Decomposition ----------------\n');
n = size(Orig_I,1);
n_log = log2(n);
level = n_log;
% wavelet decomposition level can be defined by users manually.
type = 'bior4.4';
[Lo_D,Hi_D,Lo_R,Hi_R] = wfilters(type);
[I_W, S] = func_DWT(Orig_I, level, Lo_D, Hi_D);
fprintf('done!\n');
fprintf('----------- Encoding ----------------\n');
img_enc = func_SPIHT_Enc(I_W, max_bits, nRow*nColumn, level);
fprintf('done!\n');
fprintf('----------- Decoding ----------------\n');
img_dec = func_SPIHT_Dec(img_enc);
fprintf('done!\n');
fprintf('----------- Wavelet Reconstruction ----------------\n');
img_spiht = func_InvDWT(img_dec, S, Lo_R, Hi_R, level);
fprintf('done!\n');
fprintf('----------- PSNR analysis ----------------\n');
Q = 255;
MSE = sum(sum((img_spiht-Orig_I).^2))/nRow / nColumn;
fprintf('The psnr performance is %.2f dB\n', 10*log10(Q*Q/MSE));
please help, thanks

採用された回答

Brian B
Brian B 2014 年 7 月 17 日
編集済み: Brian B 2014 年 7 月 17 日
The code you have posted may work just fine in MATLAB, but will not work in Simulink. Not all functions are supported for use in a MATLAB function block. In fact, you should have seen other errors (in addition to the one you described) telling you exactly which unsupported function the compiler first detected, such as:
"The function 'imread' is not supported for standalone code generation."
For a list of those functions that are supported, see http://www.mathworks.com/help/simulink/ug/functions-supported-for-code-generation--alphabetical-list.html. In particular, you cannot use imread or wfilters. There may be calls to other unsupported functions inside func_SPIHT_Enc, func_SPIHT_Dec, func_InvDWT
For other general information about the block, see http://www.mathworks.com/help/simulink/slref/matlabfunction.html.
  1 件のコメント
hanaa
hanaa 2014 年 7 月 18 日
attached the whole code and all errors appear are those:
Function 'MATLAB Function' (#25.2051.2057), line 82, column 26: "Orig_I" Launch diagnostic report. Component: MATLAB Function | Category: Coder error
Undefined function or variable 'MSE'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#25.2138.2141), line 83, column 59: "MSE" Launch diagnostic report. Component: MATLAB Function | Category: Coder error
Errors occurred during parsing of MATLAB function 'MATLAB Function'(#24)
Component: MATLAB Function | Category: Coder error
Code Directory :
"C:\Users\hanaa\Documents\MATLAB\slprj\_sfprj\spiht_try\_self\sfun\src"
Machine (#21): "spiht_try" Target : "sfun"
Chart "MATLAB Function" (#24):
. Code generation failed Errors occurred during parsing of MATLAB function 'MATLAB Function'(#24)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWavelet Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by