I wanted to partition watershed segmentation on original image using spatial criteria and I got this error message: "Subscript indices must either be real positive integers or logicals".
Show older comments
Hi pls can anyone help me. I am trying to partition a watershed segmentation image and merge it to the original image. But I got this error don't know how to resolve it. I will appreciate your solutions. This is the error message: "Subscript indices must either be real positive integers or logicals". I am applying spatial criteria for the partitioning so that I can reduce the number of partitions on the image.
NB: the error is in line: B(i,j)= mean(abs(ima(B(i)+B(i)-ima(B(j)+B(i)))));
Thank you in advance.
ima=dicomread('MRI');
LWS=bwlabel(WS); % initial partition
max=max(LWS(:)); % total number of partitions or size
N=max;
for i=1:N;
M(i)=mean(ima(LWS==i)); % calculate the mean intensity of each partition
end
for i=1:N;
j=1:N;
B(i,j)=(i(1,:)-j(1,:));
M(i,j)=abs(M(i)-M(j)); % difference in mean intensity partition i and j.
B(i,j)= mean(abs(ima(B(i)+B(i)-ima(B(j)+B(i)))));
% B(i,j)=mean(abs(ima(LWS==i))-(ima(LWS==j))); % difference intensity btw partition i & j.
p1=bwperim(i:N);
p2=bwperim(j:N);
H=mean(p1+p2);
ind=find(p1==1);
ind2=find(p2==1);
T=0.5;
indices=intersect(ind,ind2)<T; % merging partition
figure,imshow(p1,[]);
figure,imshow(H,[]);
end
Accepted Answer
More Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!