In this code, I have a cluster image with 10 classes and i want to extract 10 different images for each level and save as a 10 images Below is the code, I used
ticnumberOfClasses = 10;segment_label_images = cell(1,numberOfClasses);pixelCount = zeros(1,numberOfClasses);[rs, cs] = size(classImage);% classImage has intensity range from 1-numberOfClasses
for k = 1:numberOfClasses for i = 1:rs for j = 1:cs if classImage(i,j) == k segment_label_images{k}(i,j) = 1; else segment_label_images{k}(i,j) = 0; end end endpixelCount(k) = sum(segment_label_images{k}(:));%figure, imshow(segment_label_images{k},[]);
endtoc
Here, I have 3 for loops and I think that is affecting computational time. Elapsed time is 0.089413 seconds.
Any suggestions to avoid for loop to improve comp time.? Thanks, Gopi
Best Answer