superpixel matlab,3-D superpixel oversegmentation of 3-D image

Load 3-D MRI data, remove any singleton dimensions, and convert the data into a grayscale intensity image.

load mri;

D = squeeze(D);

A = ind2gray(D,map);

Calculate the 3-D superpixels. Form an output image where each pixel is set to the mean color of its corresponding superpixel region.

[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)

82c59f195c4448481a2279ede64be7ba.png

Set the color of each pixel in output image to the mean intensity of the superpixel region. Show the mean image next to the original. If you run this code, you can use implay to view each slice of the MRI data.

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);

f061b94b6644458a38a37e5bd53dc502.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值