当前位置:网站首页>[chapter 06 MATLAB realizes lung cancer diagnosis based on watershed segmentation]
[chapter 06 MATLAB realizes lung cancer diagnosis based on watershed segmentation]
2022-06-22 01:54:00 【Haibao 7】
MATLAB Application instance
Source code download address :
https://download.csdn.net/download/dongbao520/85693518
The principle of watershed segmentation :
“ Watershed is a classical algorithm , Used for segmentation, that is , Used to separate different objects in an image . Start with a user-defined tag , Watershed algorithm regards pixel value as local terrain ( Altitude ). The algorithm starts from marking the flood basin , Until the watersheds belonging to different markers meet on the watershed . in many instances , The tag is selected as the local minimum of the image , Submerge the basin . In the following example , Two overlapping circles will be separated . Do that , Need to calculate an image , That is, the distance to the background . Select the maximum value of the distance ( namely , The opposite minimum of distance ) As a sign , The basin overflowing from these signs separates the two circles along the watershed line .”
This paper discusses image recognition based on watershed segmentation
The effect is as shown in the picture 



The program is relatively simple ..
Just customize the function
Watershed_Fun.m
function Watershed_Fun(fileName)
rgb = imread(fileName);
if ndims(rgb) == 3
I = rgb2gray(rgb);
else
I = rgb;
end
sz = size(I);
if sz(1) ~= 256
I = imresize(I, 256/sz(1));
rgb = imresize(rgb, 256/sz(1));
end
hy = fspecial('sobel');
hx = hy';
Iy = imfilter(double(I), hy, 'replicate');
Ix = imfilter(double(I), hx, 'replicate');
gradmag = sqrt(Ix.^2 + Iy.^2);
se = strel('disk', 3);
Io = imopen(I, se);
Ie = imerode(I, se);
Iobr = imreconstruct(Ie, I);
Ioc = imclose(Io, se);
Iobrd = imdilate(Iobr, se);
Iobrcbr = imreconstruct(imcomplement(Iobrd), imcomplement(Iobr));
Iobrcbr = imcomplement(Iobrcbr);
fgm = imregionalmax(Iobrcbr);
se2 = strel(ones(3,3));
fgm2 = imclose(fgm, se2);
fgm3 = imerode(fgm2, se2);
fgm4 = bwareaopen(fgm3, 15);
bw = im2bw(Iobrcbr, graythresh(Iobrcbr));
D = bwdist(bw);
DL = watershed(D);
bgm = DL == 0;
gradmag2 = imimposemin(gradmag, bgm | fgm4);
L = watershed(gradmag2);
Lrgb = label2rgb(L, 'jet', 'w', 'shuffle');
[pathstr, name, ext] = fileparts(fileName);
filefolder = fullfile(pwd, ' experimental result ', [name, '_ Experimental screenshot ']);
if ~exist(filefolder, 'dir')
mkdir(filefolder);
end
h1 = figure(1);
set(h1, 'Name', ' Image graying ', 'NumberTitle', 'off');
subplot(1, 2, 1); imshow(rgb, []); title(' Original image ');
subplot(1, 2, 2); imshow(I, []); title(' Grayscale image ');
fileurl = fullfile(filefolder, '1');
set(h1,'PaperPositionMode','auto');
print(h1,'-dtiff','-r200',fileurl);
h2 = figure(2);
set(h2, 'Name', ' Image morphology operation ', 'NumberTitle', 'off');
subplot(1, 2, 1); imshow(Iobrcbr, []); title(' Image morphology operation ');
subplot(1, 2, 2); imshow(bw, []); title(' Image binarization ');
fileurl = fullfile(filefolder, '2');
set(h2,'PaperPositionMode','auto');
print(h2,'-dtiff','-r200',fileurl);
h3 = figure(3);
set(h3, 'Name', ' Image gradient display ', 'NumberTitle', 'off');
subplot(1, 2, 1); imshow(rgb, []); title(' The image to be processed ');
subplot(1, 2, 2); imshow(gradmag, []); title(' Gradient image ');
fileurl = fullfile(filefolder, '3');
set(h3,'PaperPositionMode','auto');
print(h3,'-dtiff','-r200',fileurl);
h4 = figure(4); imshow(rgb, []); hold on;
himage = imshow(Lrgb);
set(h4, 'Name', ' Image watershed segmentation ', 'NumberTitle', 'off');
set(himage, 'AlphaData', 0.3);
hold off;
fileurl = fullfile(filefolder, '4');
set(h4,'PaperPositionMode','auto');
print(h4,'-dtiff','-r200',fileurl);

Download the source file and its data image –> Portal
边栏推荐
- Fabric.js IText 手动设置斜体
- es-object vs nested vs has_child and has_parent
- 2019 csp-j1 csp-s1 first round preliminary round answer analysis and summary, video, etc
- MBA-day24 最值问题
- 英特尔笔试题小整理DIY
- Mba-day18 elimination method
- Mathematical knowledge in the first round of noip preliminary round csp-j1 csp-s1 Xinjiang Olympic Games (II)
- 【英伟达发展历程纪实618-01】
- Machine learning pytoch implementation case LSTM case (flight number prediction)
- Rational rose 安装教程
猜你喜欢

The sandbox has reached a cooperation with Time magazine to establish "New York Times Square" in metauniverse

2022年中国手机银行年度专题分析

Commission contract on BSV (2)

一条短视频成本几十万元,虚拟数字人凭“实力”出圈

Scuba China trip - Suzhou station, online and offline limited time registration channel has been opened!

基于DPDK的高效包处理系统

第 03 章 基于多尺度形态学提取眼前节组织-全套系统MATLAB智能驾驶深度学习

acwing 836. 合并集合 (并查集)

1277_FreeRTOS中vTaskDelay的实现分析

Machine learning pytoch implementation case LSTM case (flight number prediction)
随机推荐
AHA C language Chapter 5 the good play is later (Lecture 24-25)
2022年Q1手机银行用户规模达6.5亿,加强ESG个人金融产品创新
【AMD 綜合求職經驗分享618】
第 24 章 基于 Simulink 进行图像和视频处理--matlab深度学习实战整理
Function test - Introduction to MySQL database
数电期末笔记
稳扎稳打学爬虫08—Selenium的使用方法详解
The way to build the efficiency platform of didi project
linxu 将文件夹的权限修改为所有人可以访问 777
Creating a successful paradigm for cross-border e-commerce: Amazon cloud technology helps sellers lay out the next growth point
[Chapter 10: a website digital verification code recognition based on moment invariants matlab deep learning practical application case]
heidisql 插入数据老是出错,怎么办
LeetCode+ 46 - 50
Redis cache exceptions and handling scheme summary
“早安、午安、晚安” Game Jam
【AMD 综合求职经验分享618】
第 03 章 基于多尺度形态学提取眼前节组织-全套系统MATLAB智能驾驶深度学习
Benchmarking copilot, the first in China: natural language one click generation method level code aixcoder XL is coming
测试apk-异常管控WiFi Scan攻击者开发
【虚幻引擎UE】打包报错出现!FindPin错误的解决办法