MATLAB 运行时出现下列错误?index must be a positive integer or logical.程序在这,一个图像分割程序map=reshape([1:n_pixels],size_image(1:2));gap=zeros(size(map));treerank=zeros(size_image(1:2));size_segments=ones(size_image(1:2));ima

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 03:49:27

MATLAB 运行时出现下列错误?index must be a positive integer or logical.程序在这,一个图像分割程序map=reshape([1:n_pixels],size_image(1:2));gap=zeros(size(map));treerank=zeros(size_image(1:2));size_segments=ones(size_image(1:2));ima
MATLAB 运行时出现下列错误?index must be a positive integer or logical.
程序在这,一个图像分割程序
map=reshape([1:n_pixels],size_image(1:2));
gap=zeros(size(map));
treerank=zeros(size_image(1:2));
size_segments=ones(size_image(1:2));
image_seg=image;
%Building pairs
n_pairs=numel(index);
idx2=reshape(map(:,1:end-1),[],1);
idx1=reshape(map(1:end-1,:),[],1);
pairs1=[ idx1;idx2 ];
pairs2=[ idx1+1;idx2+size_image(1) ];
for Q=Qlevels
iter=find(Q==Qlevels);
for i=1:n_pairs
C1=pairs1(index(i));
C2=pairs2(index(i));
%Union-Find structure,here are the finds,average complexity O(1)
while (map(C1)~=C1 ) C1=map(C1); end
while (map(C2)~=C2 ) C2=map(C2); end
% Compute the predicate,region merging test
g=256;
logdelta=2*log(6*n_pixels);
dR=(image_seg(C1)-image_seg(C2))^2;
dG=(image_seg(C1+n_pixels)-image_seg(C2+n_pixels))^2;
dB=(image_seg(C1+2*n_pixels)-image_seg(C2+2*n_pixels))^2;
logreg1 = min(g,size_segments(C1))*log(1.0+size_segments(C1));
logreg2 = min(g,size_segments(C2))*log(1.0+size_segments(C2));
dev1=((g*g)/(2.0*Q*size_segments(C1)))*(logreg1 + logdelta);
dev2=((g*g)/(2.0*Q*size_segments(C2)))*(logreg2 + logdelta);
dev=dev1+dev2;
predicat=( (dR

MATLAB 运行时出现下列错误?index must be a positive integer or logical.程序在这,一个图像分割程序map=reshape([1:n_pixels],size_image(1:2));gap=zeros(size(map));treerank=zeros(size_image(1:2));size_segments=ones(size_image(1:2));ima
下标越界了 仔细查查