??? Undefined function or variable 'blur' Why is that

5 ビュー (過去 30 日間)
Shehan
Shehan 2014 年 5 月 21 日
コメント済み: Image Analyst 2014 年 5 月 21 日
when compiling this code I'm getting an error
Warning: Unable to determine the number of frames in this file. ??? Undefined function or variable 'blur'.
Error in ==> ReadVideo at 22 IDX = kmeans(blur,2);
vid = 'N1.mpg';
shainObj = mmreader(vid);
nFrames = shainObj.NumberOfFrames;
vidHeight = shainObj.Height;
vidWidth = shainObj.Width;
% Preallocate movie structure.
mov(1:nFrames) = ...
struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'),...
'colormap', []);
% Read one frame at a time.
for k = 1 : nFrames
mov(k).cdata = read(shainObj, k);
image = mov(k).cdata;
imagegray = rgb2gray(image);
imagegray = imresize(imagegray, 0.2);
blur(k) = fmeasure(imagegray, 'GRAE', '');
end
IDX = kmeans(blur,2);
sum1 = 0;
sum2 = 0;
for k = 1 : nFrames
if IDX(k) == 1
sum1 = sum1 + 1;
else
sum2 = sum2 + 1;
end
end
if sum1 > sum2
normal = sum1;
blured = sum2;
else
normal = sum2;
blured = sum1;
end
disp('blur metrics for the input video');
disp(sprintf('Total frames: %d',nFrames));
disp(sprintf('Normal frames: %d',normal));
disp(sprintf('Blured frames: %d',blured));

回答 (1 件)

Mischa Kim
Mischa Kim 2014 年 5 月 21 日
編集済み: Mischa Kim 2014 年 5 月 21 日
Shehan, the error message seems to indicate that MATLAB is not able to determine the number of frames in
nFrames = shainObj.NumberOfFrames;
which would mean that the for loop is not executed (I assume) and therefore no values are assigned to blur(k). As a result MATLAB is not able to execute
IDX = kmeans(blur,2);
To start debugging, remove the semi-colon in nFrames = shainObj.NumberOfFrames; to see the content of nFrames. You could do the same in the loops to see if they are execute.
Alternatively, use the debugger functionality in MATLAB to step through the code line by line.
  2 件のコメント
Shehan
Shehan 2014 年 5 月 21 日
I tried what you said But no luck. I change the input video then it works What can be the problem is
but then i got an error message saying
*??? Undefined function or method 'fmeasure' for input arguments of type 'uint8'.
Error in ==> ReadVideo at 20 blur(k) = fmeasure(imagegray, 'GRAE', '');*
Image Analyst
Image Analyst 2014 年 5 月 21 日
fmeasure() is probably some custom written function. Ask whomever you got this code for. They probably forgot to give you one of the m-files.

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

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by