There is a mistake in counting the colour number. I sent the updated file to Matlabcentral but am not sure when they will update it.
Around line 198, please change the if statement to:
if length(size(Im))==3
Im(:,:,1)=im2double(Orig);
Orig=ntsc2rgb(Im);
[x xx]=imhist(Im(:,:,1));
xx(x==0)=0;
Array=xx(xx>0);
else
[x xx]=imhist(im2uint8(Orig(:,:,1)));% Corrected! There was a mistake here since it was written as: [x xx]=imhist(Im(:,:,1));
xx(x==0)=0;
Array=xx(xx>0);
end
%%%Please remove the following line 209
[x xx]=imhist(Im(:,:,1));
xx(x==0)=0;
Array=xx(xx>0);
Comment only