My requirement is to find the volume of the sample within the MRI image which consists of the sample, water and air. I have the data in the form of intensities in a 3D array of size 128*128*128 in which the sample corresponds to black pixels and the water volume corresponds to lighter pixels. Also, the outside air volume and the air bubbles present which are black. I am trying to use watershed function to find the connected sequence of pixels and finding the one with maximum frequency (I assume the sample to be the largest connected sequence of dark pixels), but somehow it is not detecting the sample volume as connected one. Also, bwconncomp and the labelmatrix are not of much help. Any suggestions/ideas on how to find this ?