Segmenting an image into homogenous compartments

4 views (last 30 days)
Hello all.
I have an MRI scan that I need to segment into N homogenous compartments for later reconstruction. The challenge here is that it's not whatever organ, and the rest is background, but it has to be compartments.
What tool can be used for that?

Accepted Answer

Image Analyst
Image Analyst on 26 Feb 2023
I believe you're describing superpixels3
help superpixels3
SUPERPIXELS3 3-D superpixel over-segmentation of 3-D images [L,NumLabels] = superpixels3(A,N) computes 3-D superpixels of 3-D image A using N as the requested number of superpixels. N must be between 1 and the number of pixels in the image A. The first output argument, L, is a label matrix of type double. The second output argument, NumLabels, is the actual number of 3-D superpixels that were computed. [L,NumLabels] = superpixels3(___,Name,Value,...) computes superpixels of A with Name-Value pairs used to control aspects of the segmentation. Parameters include: 'Compactness' - Numeric scalar specifying the compactness parameter of the SLIC algorithm. Compactness controls the shape of superpixels. A higher value for compactness makes superpixels more regularly shaped/square. A lower value makes superpixels adhere to boundaries better, making them irregularly shaped. The allowed range of Compactness is (0 Inf). Typical values for Compactness are in the range [0.01, 0.1]. If this parameter is not specified, the default value is chosen as 0.001 if METHOD is 'slic0' and 0.05 if METHOD is 'slic'. 'Method' - String specifying the algorithm used to compute superpixels. Supported options are 'slic' and 'slic0'. When 'Method' is 'slic0', the SLIC0 algorithm is used to adaptively refine 'Compactness' after the first iteration. When 'Method' is 'slic', 'compactness' is constant during clustering. Default: 'slic0' 'NumIterations' - Numeric scalar specifying the number of iterations used in the clustering phase of the algorithm. For most problems it is not necessary to adjust this parameter. Default: 10 Class Support ------------- The input image A must be a real, non-sparse matrix of the following classes: int8, uint8, int16, uint16, int32, uint32, single, or double. Notes ----- 1. When using the 'slic0' method, it is generally not necessary to adjust 'Compactness' parameter. The intention of 'slic0' is to adaptively refine 'Compactness' automatically and eliminate the need for users to determine a good value of 'Compactness' for themselves. References: ----------- [1] Radhakrishna Achanta, Appu Shaji, Kevin Smith, Aurelien Lucchi, Pascal Fua, and Sabine Susstrunk, SLIC Superpixels Compared to State-of-the-art Superpixel Methods, IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 34, num. 11, p. 2274 - 2282, May 2012. [2] Radhakrishna Achanta, Appu Shaji, Kevin Smith, Aurelien Lucchi, Pascal Fua, and Sabine Susstrunk, SLIC Superpixels, EPFL Technical Report no. 149300, June 2010. Example ------- % Compute 3-D superpixels of input volumetric intensity image. Form an % output image where each pixel is set to the mean color of its % corresponding superpixel region. load mri; D = squeeze(D); A = ind2gray(D,map); [L,N] = superpixels3(A, 34); % Show all xy-planes progressively with superpixel boundaries. imSize = size(A); % Create a stack of RGB images to display the boundaries in color. imPlusBoundaries = zeros(imSize(1),imSize(2),3,imSize(3),'uint8'); for plane = 1:imSize(3) BW = boundarymask(L(:, :, plane)); % Create an RGB representation of this plane with boundary shown % in cyan. imPlusBoundaries(:, :, :, plane) = imoverlay(A(:, :, plane), BW, 'cyan'); end implay(imPlusBoundaries,5) % Set color of each pixel in output image to the mean intensity of % the superpixel region. % Show the mean image next to the original. pixelIdxList = label2idx(L); meanA = zeros(size(A),'like',D); for superpixel = 1:N memberPixelIdx = pixelIdxList{superpixel}; meanA(memberPixelIdx) = mean(A(memberPixelIdx)); end implay([A meanA],5); See also superpixels, boundarymask, imoverlay, label2idx, implay. Documentation for superpixels3 doc superpixels3
  7 Comments
Image Analyst
Image Analyst on 28 Feb 2023
I haven't used that tool so I don't know if there is a way to manually change the regions it found.
Zinoviy
Zinoviy on 28 Feb 2023
I understand. Do have an idea what I can do instead?
Thanks!

Sign in to comment.

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!