Undefined function or variable

조회 수: 2 (최근 30일)
hanaa
hanaa 2014년 7월 15일
편집: James Tursa 2014년 7월 15일
I'm trying to run SPIHT algorithm without arithmetic coding with Matlab function block. there is error occurred at the following code statement:
MSE = sum(sum((img_spiht-Orig_I).^2))/nRow / nColumn;
error format is: Undefined function or variable 'MSE'. The first assignment to a local variable determines its class.
I tried to initialize MSE with zero value before the previous statement, but nothing changed. please help thanks
  댓글 수: 2
dpb
dpb 2014년 7월 15일
Need to see the function up to that point...
hanaa
hanaa 2014년 7월 15일
편집: James Tursa 2014년 7월 15일
this is Matlab Function:
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));

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Denoising and Compression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by