color image quantization between ABC algorithm and Fuzzy c-means fcm

I have a hybrid approach that combines the algorithm of the artificial bees and K-Means algorithm.
The problem is that I want to replace k-Means Algorithm and replace it with fuzzy c-means Algorithm(fcm in matlab) , knowing that the code has been implemented to quantized the color image.
This particular code is the k-means function. I want to replace it with (fcm) without changing the ABC code.
function [pos, cost,IDX] = fns1(X,pos,nColor,MaxIter)
for i=1:size(pos,1)
% perfrom kmeans
startCentroidTemp(1:nColor,1:3) = pos(i,:,:); % initial centroid should be k by p
[idx,C,sumd] = kmeans(X, nColor, 'MaxIter', MaxIter, 'Display','off', 'Start', startCentroidTemp);
cost(i) = 1/nColor * sum(sumd); % average distance
pos(i,:,:) = C;
IDX(i,:) = idx;
end
end
PARAMETERS
size of image=512x512 RGB
population=10=N
pos=10x4x3 double
cost=1x10 double
IDX=10x262144 double
X=262144x3 double
NColor=4
MaxIter=2
idx=?
C=4X3 double
Sumd=?
Use matlab 2019a

Answers (0)

Community Treasure Hunt

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

Start Hunting!