1 简介

​【图像分割】基于最小误差法实现胸片分割系统matlab代码_去噪

​【图像分割】基于最小误差法实现胸片分割系统matlab代码_去噪_02

​【图像分割】基于最小误差法实现胸片分割系统matlab代码_参考文献_03

2 部分代码

clc; clear all; close all;
warning off all;
% 读取图像
% filename = fullfile(pwd, 'images/test.jpg');
load 1.mat
Img =planC{1, 3}.scanArray;
% Img =imread(filename);
% 灰度化
if ndims(Img) == 3
I = rgb2gray(Img);
else
I = Img;
end
% 直接二值化
bw_direct = im2bw(I);
figure; imshow(bw_direct); title('直接二值化分割');
% 圈选胃区域空气
c = [1524 1390 1454 1548 1652 1738 1725 1673 1524];
r = [1756 1909 2037 2055 1997 1863 1824 1787 1756];
bw_poly = roipoly(bw_direct, c, r);
figure;
imshow(I, []);
hold on;
plot(c, r, 'r-', 'LineWidth', 2);
hold off;
title('胃区域空气选择');
% 设置胃内空气为255
J = I;
% 区域属性
stats = regionprops(L);
Ar = cat(1, stats.Area);
% 提取目标并清理
[Ar, ind] = sort(Ar, 'descend');
bw_temp(L ~= ind(1) & L ~= ind(2)) = 0;
% 去噪
bw_temp = imclose(bw_temp, strel('disk',20));
bw_temp = imfill(bw_temp, 'holes');
figure;
subplot(1, 2, 1); imshow(bw__kittler, []); title('待处理二值图像');
subplot(1, 2, 2); imshow(bw_temp, []); title('形态学后处理图像');
% 提取肺边缘
ed = bwboundaries(bw_temp);
% 显示
figure;
subplot(2, 2, 1); imshow(I, []); title('原图像');
subplot(2, 2, 2); imshow(J, []); title('增强图像');
subplot(2, 2, 3); imshow(bw_temp, []); title('二值化图像');
subplot(2, 2, 4); imshow(I, []); hold on;
for k = 1 : length(ed)
% 边缘
boundary = ed{k};
plot(boundary(:,2), boundary(:,1), 'g', 'LineWidth', 2);
end
title('肺边缘显示标记');
figure;
subplot(1, 2, 1); imshow(bw_temp, []); title('二值图像');
subplot(1, 2, 2); imshow(I, []); hold on;
for k = 1 : length(ed)
% 边缘
boundary = ed{k};
plot(boundary(:,2), boundary(:,1), 'g', 'LineWidth', 2);
end
title('肺边缘显示标记');

3 仿真结果

​【图像分割】基于最小误差法实现胸片分割系统matlab代码_参考文献_04

​【图像分割】基于最小误差法实现胸片分割系统matlab代码_二值化_05

4 参考文献

[1]殷保才, 王凤艳, and 程虎. "基于回归的X线胸片肺野自动分割算法." 移动信息 4:2.

​【图像分割】基于最小误差法实现胸片分割系统matlab代码_灰度_06