Vectorizing Help (Fuzzy C Means for Image Data)

1 visualización (últimos 30 días)
Erica McCune
Erica McCune el 25 de Sept. de 2017
Hi, I’m looking for some help vectorizing my code. Currently I’m writing my own fuzzy c means algorithm for categorizing the intensities of a stack of CT slices. My program is fairly slow right now (around 6-8 minutes to run) and I know the speed issues come down to one for loop I have in the algorithm. Currently I’m using a for loop to update U. (For those who are not familiar with this algorithm, the part I’m trying to code is step 3 from here , but with a three dimensional data set instead of a one dimensional one)
This is the for loop I have:
for l=1:numCluster
denombottom=denomTop(:,:,:,l)./denomTop;
denomPower=denombottom.^power;
uDenom=sum(denomPower, 4);
newU(:,:,:,l)=1./uDenom;
end
I tried vectorizing the code, but the program ran at the same speed as my vectorized version, which makes me think there might be a better way to go about vectorizing the code or possibly a better way to speed up the program. Here’s my vectorized version:
denombottom = repmat(denomTop, [1 1 1 1 numCluster]);
DenomTop = repmat(permute(denomTop,[1,2,3,5,4]),[1,1,1,numCluster,1]);
denomBottom = DenomTop./denombottom;
denomPower=denomBottom.^power;
uDenom = sum(denomPower, 4);
UDenom = reshape(uDenom, [imageHeight, imageWidth, slices, numCluster]);
newU = 1./UDenom;
Thanks in advance for any help!

Respuestas (0)

Categorías

Más información sobre Fuzzy Logic Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by