区域生长(冈萨雷斯数字图像处理)

本文介绍了一个基于区域生长的图像分割算法实现过程。该算法通过定义种子点和阈值来进行图像的区域标记,利用MATLAB函数regiongrow进行图像分割,并展示了实际应用案例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

区域生长 

regiongrow函数的使用,在使用之前先定义函数功能,http://book.51cto.com/art/201304/391313.htm,

  1. function [g, NR, SI, TI] = regiongrow(f, S, T)  
  2. %REGIONGROW Perform segmentation by region growing.  
  3. %   [G, NR, SI, TI] = REGIONGROW(F, S, T). S can be an array (the  
  4. %   same size as F) with a 1 at the coordinates of every seed point  
  5. %   and 0s elsewhere. S can also be a single seed value. Similarly,  
  6. %   T can be an array (the same size as F) containing a threshold  
  7. %   value for each pixel in F. T can also be a scalar, in which case  
  8. %   it becomes a global threshold. All values in S and T must be in  
  9. %   the range [0, 1]  
  10. %  
  11. %   G is the result of region growing, with each region labeled by a  
  12. %   different integer, NR is the number of regions, SI is the final  
  13. %   seed image used by the algorithm, and TI is the image consisting  
  14. %   of the pixels in F that satisfied the threshold test, but before  
  15. %   they were processed for connectivity.  
  16.  
  17. if = tofloat(f);  
  18. % If S is a scalar, obtain the seed image.  
  19. if numel(S) == 1  
  20.    SI = f == S;  
  21.    SS1 = S;  
  22. else  
  23.    % S is an array. Eliminate duplicate, connected seed locations  
  24.    % to reduce the number of loop executions in the following  
  25.    % sections of code.  
  26.    SI = bwmorph(S, 'shrink', Inf);  
  27.    S1 = f(SI); % Array of seed values.  
  28. end  
  29.  
  30. TI = false(size(f));  
  31. for K = 1:length(S1)  
  32.    seedvalue = S1(K);  
  33.    S = abs(f ? seedvalue) <= T; % Re-use variable S.  
  34.    TITI = TI | S;  
  35. end  
  36. % Use function imreconstruct with SI as the marker image to  
  37. % obtain the regions corresponding to each seed in S. Function  
  38. % bwlabel assigns a different integer to each connected region.  
  39. [g, NR] = bwlabel(imreconstruct(SI, TI));  
bwmorph函数的作用,提取二进制图像的轮廓,对二值图象的形态学操作,http://blog.youkuaiyun.com/a1075863454/article/details/45646187


i=imread('X-ray.png');
I1 = rgb2gray(i);
figure(1);imshow(I1);
% i=doulbe(i);
[m,n]=size(I1);
S=1;
T=0.26;
[g, NR, SI, TI ]=regiongrow(I1,S,T);
figure(2);imshow(g);title('区域增长');
figure(3);imshow(SI);
figure(4);imshow(TI);

然后对定义regiongrow里的tofloat,https://zhidao.baidu.com/question/499990534173948084.html,就可以运行程序了。











































































































评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值