基于区域生长的图像分割 matlab 源码

基于区域生长的图像分割算法,本程序可以对核磁扫描到的一个序列图像进行半自动分割,选取的参考图像格式为nii,并给出了nii格式文件的保存方法,一些程序相关函数可联系微博@田问渠Carlnait 私信免费获取

clear;clc

global R BW counter row col
    %读取图像,初始G用于保存分割后的文件
    nii = load_nii('a00d15.nii');
    a = nii.img;
    G = zeros(256,256,20);
for i=1:1:20
    Ig = double(uint16(rot90(a(:,:,i))));
    PQ = paddedsize(size(Ig));
    D0 = 0.005 * PQ(1);
    HBW = hp2filter('btw', PQ(1), PQ(2), D0, 1);
    I = uint16(dftfilt(Ig, HBW)); %频域滤波
    [row, col] = size(I);
    figure, imshow(I, [])


    level = graythresh(I);
    BW = im2bw(I, level);
    [y0, x0] = getpts;
    x0 = int16(x0);
    y0 = int16(y0);
    counter = 0;
    R = zeros(row,col);
    R = uint8(R);
    fsrRegiongrow(x0,y0,4);
    figure,imshow(R)
    M = logical(R);
    Im = uint16(Ig .* M);
    figure, imshow(Im,[])
    figure,imshowpair(Im,Ig)
    
    G(:,:,i) = Im;
    
end
%nii文件的保存
datatype = 4;
origin = [0 0 0];
g = make_nii(G, [], origin, datatype);
save_nii(g, 'newa00d15.nii')



猜你喜欢

转载自blog.csdn.net/sinat_34653971/article/details/79713493