资源简介
matlab实现的三维医学图像分割,处理的是MRI的dicom图像,能有效分割脑白质和灰质,并计算体积,内附测试图像,可直接运行。
代码片段和文件信息
%analyze_series8.m
% Copyright 2004-2010 The MathWorks Inc.
%start with clean slate (nobkpt)
clear %no variables
close all %no figures
clc %empty command window
%% Data Access
%----------------------------------------------------------------------
%DICOM support (nobkpt)
web([docroot ‘/toolbox/images/intro19.html‘])
%filename convention used in image series (nobkpt)
prefix = ‘Series 8\I0000‘;
fnum = 417:476;
ext = ‘_anon.dcm‘;
%first filename in series (nobkpt)
fname = [prefix num2str(fnum(1)) ext];
%examine file header (nobkpt)
info = dicominfo(fname)
%extract size info from metadata (nobkpt)
voxel_size = [info.PixelSpacing; info.SliceThickness]‘
%read slice images; populate XYZ matrix
hWaitBar = waitbar(0‘Reading DICOM files‘);
for i=length(fnum):-1:1
fname = [prefix num2str(fnum(i)) ext];
D(::i) = uint16(dicomread(fname));
waitbar((length(fnum)-i)/length(fnum))
end
delete(hWaitBar)
whos D
%% Visualization
%----------------------------------------------------------------------
%explore image data using Image Viewer GUI tool
i = 30; %middle slice
im = squeeze(D(::i));
max_level = double(max(D(:)));
imview(im[0 max_level])
%custom display - image data
fig1 = figure;
max_level = double(max(D(:)));
imshow(im[0 max_level])
title(‘Coronal Slice #30‘)
set(fig1‘position‘[601 58 392 314])
imview close all
%add intensity legend
colorbar
%change colormap
colormap jet
%3D visualization (doc: contourslice isosurface & isocap)
docsearch(‘visualizing mri data‘)
%explore 3D volumetric data using Slice-O-Matic GUI tool (nobkpt)
addpath(‘D:\work\Demos\others\sliceomatic‘)
sliceomatic(double(D))
%ref: submission #780 @ www.mathworks.com/matlabcentral (nobkpt)
hSlico1 = gcf;
daspect(1./voxel_size)
movegui(‘northwest‘)
%reorient data for easier interpretation (stand patient up)
D = permute(D[3 2 1]);
voxel_size = voxel_size([1 3 2]);
for i=1:3
D = flipdim(Di);
end
whos D
%explore rotated 3D volume (new Slice-O-Matic viwer) - nobkpt
if ishandle(hSlico1) delete(hSlico1) end
sliceomatic(double(D))
daspect(1./voxel_size)
hSlico2 = gcf;
set(hSlico2‘position‘[455 63 560 420])
%intensity distribution also useful (more custom graphics)
%max_level = double(max(D(:)));
my_map = jet(max_level);
fig2 = figure;
%intensity distribution - top 2/3 (nobkpt)
subplot(311:2)
hist(double(im(:))max_level)
axis([0 max_level 0 900])
title(‘Distribution‘)
%color scale - bottom 1/3 (nobkpt)
subplot(313)
imagesc(1:max_level)
colormap(my_map)
xlim([0 max_level])
set(gca‘ytick‘[])
ylabel(‘Color Map‘)
xlabel(‘Intensity‘)
set(fig2‘position‘[22 60 560 300]‘render‘‘zbuffer‘)
set(fig1‘position‘[601 68 392 314])
figure(fig1)
%% Segmentation
%----------------------------------------------------------------------
%ignore low levels (backround air CSF & other soft? tissues)
%using custom GUI tool to select b
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6845 2010-01-13 12:12 MRI Brain Scan\analyze_series8.m
文件 427 2010-01-13 12:12 MRI Brain Scan\isinteger.m
文件 775 2010-01-13 12:12 MRI Brain Scan\limits.m
文件 1559 2010-01-13 12:12 MRI Brain Scan\move_vline.m
文件 297 2010-01-13 12:12 MRI Brain Scan\movex_text.m
文件 5421 2010-01-13 12:09 MRI Brain Scan\ReadMe.txt
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000417_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000418_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000419_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000420_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000421_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000422_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000423_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000424_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000425_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000426_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000427_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000428_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000429_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000430_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000431_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000432_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000433_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000434_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000435_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000436_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000437_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000438_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000439_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000440_anon.dcm
文件 132740 2010-01-13 12:09 MRI Brain Scan\Series 8\I0000441_anon.dcm
............此处省略39个文件信息
评论
共有 条评论