MATLAB: I want to write a matlab program for building detection using fuzzy c mean clustering. it work for only one band. My image contain 8 band. I want to apply this code for all bands. How to do it?How to write a for loop for different bands in the imag

img=imread('F:\10ss055\2_27_2016\New folder\process\subset2.tif');
img=img(:,:,4);
figure(1)
imshow(img);
title('original image');
nregions=4;
h=single(img(:));
%for h=img(:,:,1):img(:,:,3)
options=[3 100 1e-5 0];
[center,u,obj_fnc]=fcm(h,nregions,options);

Best Answer

Madusha - are your bands in the third dimension of the subset2.tif? For example, could you do something like
img=imread('F:\10ss055\2_27_2016\New folder\process\subset2.tif');
numBands = size(img,3);
for k=1:numBands
bandData = img(:,:,k);
% do something...
end
Related Question