필터 지우기
필터 지우기

Have I done some mistake in the following line

조회 수: 1 (최근 30일)
Poonam
Poonam 2013년 9월 22일
function y = meanShiftseg(x,hs,hr,th,plotOn)
%%Argument Check
if nargin < 3
error('please type help for function syntax');
elseif nargin == 3
th = .25; plotOn = 1;
elseif nargin == 4
if th<0 || th >255
error('threshold should be in [0,255]');
else
plotOn = 1;
end
elseif nargin == 5
if sum(ismember(plotOn,[0,1])) == 0
error('plotOn option has to be 0 or 1');
end
elseif nargin>5
error('too many input arguments');
end
%%initialization
%x = double(x);
[height,width,depth] = size(x);
y = x;
done = 0;
iter = 0;
if plotOn
*figure(randi(1000)+1000);*
end
  • Getting error *Undefined function or method 'randi' for input arguments of type 'double'.
Error in ==> meanShiftseg at 27 figure(randi(1000)+1000);
Error in ==> meanshiftdemo at 6 y = meanShiftseg(x,8,10)
  댓글 수: 1
dpb
dpb 2013년 9월 22일
You've aliased the builtin randi function somehow...
To check first
which randi
Or, just
clear randi
and try again

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

답변 (1개)

Image Analyst
Image Analyst 2013년 9월 22일
The call to randi() is fine - check it yourself by typing randi(1000) into the command window. The problem is randi(1000)+1000 is some random number. But you don't have a figure with that handle ID number. You may have figures with handles of 1, 2, 3, etc. but you don't have one with an ID of 1397 (some random number). Don't even call figure unless you already have multiple figures and you need to switch to a specific one because functions like plot(), bar(), scatter(), etc. will automatically create a figure if one is not open yet. So just get rid of it.

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by