Hello Mohd Akmal Masud
From what I gather, you are using gradient weight segmentation with a 3D DICOM image. You want to find the total counts, mean count, max count inside the volume.
Given that you have already segmented the image, you can use the segment mask to find the counts inside the volume. You can use the following code snippet as addition to your code and to find the necessary information.
% Index into the original image to get the counts inside the segmented volume.
countsInsideVolume = spect(BW1);
% Calculate the total counts by summing the values inside the volume.
totalCounts = sum(countsInsideVolume(:));
% Calculate the mean count by dividing the total counts by the number of voxels.
meanCount = totalCounts / nnz(BW1); % nnz(BW1) gives the number of non-zero (true) elements in BW1.
% Find the maximum count inside the volume.
maxCount = max(countsInsideVolume(:));
% Display the results.
fprintf('Total Counts: %f\n', totalCounts);
fprintf('Mean Count: %f\n', meanCount);
fprintf('Max Count: %f\n', maxCount);
I hope you find the above explanation and suggestions useful!