|  | 
 
| 图像CT序列,提取每一张图像的某一部分,将该部分重建。 视频链接:http://pan.baidu.com/s/1qYG8ajM
 录制的视频是算法底层原理讲解,底层代码实现,方便大家真正掌握算法实质,开发出更加出色的算法。录制视频的初衷是:避免读者朋友利用大把时间学习已有常见算法,本系列视频旨在让读者朋友快速深入了解这些常见算法原理,有更多的时间去研究更加高大上算法(价值)。
 
 具体链接在halcom.cn论坛,联系人QQ:3283892722
 该论坛是一个学习交流平台,我会逐一的和大家分享学习。
 欢迎大家录制视频,并提交给我,我来设置视频,你可在论坛进行打赏分享。
 视频专用播放器:http://halcom.cn/forum.php?mod=viewthread&tid=258&extra=page%3D1
 
 运行环境:win7+32bit+matlab2014a
 
 复制代码% 分割石头
clc,clear,close all
D0 = 5; % 阻止的频率点与频域中心的距离
n = 1;  % 阶次
file_path =  './试件/';% 图像文件夹路径
img_path_list = dir(strcat(file_path,'*.jpg')); % 获取该文件夹中所有bmp格式的图像
img_num = length(img_path_list);  % 获取图像总数量
if img_num > 0                    % 有满足条件的图像
    k=1;
    for j = 1 : 2 : img_num                   % 逐一读取图像
        image_name = img_path_list(j).name;   % 图像名
        fprintf('正在处理的图像: %d %s\n',j,strcat(file_path,image_name));  % 显示正在处理的图像名
        img =  imread(strcat(file_path,image_name));
        if size(img,3)>1
            img = rgb2gray(img);
        end
        img = imresize(img,[512,512]);  % 缩小处理
        bw=img>10;
        % 连通域检测,计算特征
        cc = bwconncomp(bw);         % 连通域操作
        s  = regionprops(cc, {'centroid','area'});  % 面积特征
        [A, id] = max([s.Area]);     % 面积最大
        bw(labelmatrix(cc)~=id)=0;   % 只保留最大二值化块
        bw = bwfill(bw,'holes');     % 填充孔洞 
        img1 = immultiply(img,bw);   % 交运算
%         figure(1),imshow(img1); title('目标图像');
        
        img_med = medfilt2(img1);
        img_btw = freqfilter_btw_Hp(img_med, D0, n);     % 巴特沃斯高通滤波器
%         figure(2), imshow(img_btw,[]); title('巴特沃斯高通滤波图像');
        
        % 分割石头
        stone_bw = img_btw>=12;
        stone_bw = bwareaopen(stone_bw,100);  % 去掉面积小于100的小块
%         figure(3),        imshow(stone_bw); title('石头成分图像');
        
        % 分割空气
        air_bw = img_med<60 & img_med>0;   % 分割空气分割
        % 边缘不存在空气
        se = strel('disk',5);  % 形态学操作
        bw_air = imerode(bw, se);
        air_bw = immultiply(air_bw,bw_air);   % 交运算
        air_bw = bwareaopen(air_bw,50);    % 去掉面积小于50的小块
        air_bw = bwfill(air_bw,'holes');   % 填充空洞
        air_part = immultiply(img1,air_bw);   % 交运算
%         figure(4),        imshow(air_bw); title('空气成分图像');
        
        % 分割凝胶部分
        gel_bw = img_btw<12;                  % 分割凝胶部分
        gel_bw = immultiply(gel_bw,bw_air);   % 交运算
        gel_bw = gel_bw-air_bw;           % 去除空气部分
        gel_bw = bwareaopen(gel_bw,50);   % 去掉面积小于50的小块
        gel_part = immultiply(img1,gel_bw);   % 交运算
%         figure(5),        imshow(gel_bw); title('凝胶成分图像');
        
        % 修正石头
        stone_bwz = bw-gel_bw-air_bw;
        stone_bwz = bwareaopen(stone_bwz,100);   % 去掉面积小于100的小块
        stone_part = immultiply(img1,stone_bwz);   % 交运算
%         figure(6),        imshow(stone_bwz); title('石头成分图像');
        
        D(:,:,k) = img1;
        stone(:,:,k) = stone_part;
        gel(:,:,k) = gel_part;
        air(:,:,k) = air_part;
        k=k+1;
    end
end
save D.mat D stone gel air
%% 空气部分
clear all;
load('D.mat');
figure(10),
[x,y,z,air1] = reducevolume(air,[8,8,1]);
p1 = patch(isosurface(x,y,z,air1, 5,'verbose'),...
    'FaceColor','c','EdgeColor','none');
isonormals(x,y,z,air1,p1);
p2 = patch(isocaps(x,y,z,air1, 5),...
    'FaceColor','c','EdgeColor','none');
view(3); axis tight; 
daspect([1,1,0.4]);
colormap('jet');
camlight; 
lighting gouraud;
hold off
% 获取点坐标
[t, p, pxZoom, pyZoom, pzZoom] = get_3D_points(x,y,z,air1);
% triangulation
figure(103),plot3(p(:,1)*pxZoom,p(:,2)*pyZoom,p(:,3)*pzZoom,'b.','MarkerSize',3);
xlabel('x'); ylabel('y'); zlabel('z'); 
title('空气部分');
figure(104),hold on;
trisurf(t, p(:,1)*pxZoom,p(:,2)*pyZoom,p(:,3)*pzZoom, 'edgecolor','none')
view(-37.5,30);
% axis tight;
xlabel('x'); ylabel('y'); zlabel('z'); 
camlight; 
lighting gouraud;
colormap('lines');
box on;
hold off;
 
 
 | 
 
x本帖子中包含更多资源您需要 登录 才可以下载或查看,没有帐号?立即注册  |