simple_seg_demo.m
上传用户:liuping58
上传日期:2022-06-05
资源大小:105k
文件大小:1k
源码类别:

3D图形编程

开发平台:

Visual C++

  1. %region_seg(I,init_mask,max_its,E,T)
  2. %coded by hormuz mostofi
  3. %I = imread('liver.bmp');               %-- load the image
  4. %m = zeros(size(I,1),size(I,2));          %-- create initial mask
  5. %m= imread('mask.bmp');
  6. %I = imresize(I,0.2);
  7. %m = imresize(m,0.2);
  8. %m=zeros(30,30,30);m(10:20,10:20,10:20)=1;
  9. %I=zeros(30,30,30);I(13:16,13:16,13:16)=1;
  10. cla;
  11. res=3;
  12. load mristack.mat;
  13. [XI,YI,ZI] = meshgrid(0:res:size(mristack,1), 0:res:size(mristack,2), 0:1:size(mristack,3));
  14. mristack=cast(mristack,'double');
  15. I = interp3(mristack,XI,YI,ZI);I(isnan(I))=0;
  16. m = zeros(size(I,1),size(I,2),size(I,3));
  17. m(size(I,1)/3:2*size(I,1)/3,size(I,2)/3:2*size(I,2)/3,size(I,3)/3:2*size(I,3)/3)=1;
  18. subplot(2,2,1); slice(I,15,5,5); title('Input Image');view(3);
  19. subplot(2,2,2);
  20. isosurface(m); title('Initial Mask'); view(3); %camlight; lighting gouraud;
  21. seg = simpleseg(I, m, 400, 30, 100); %-- Run segmentationm, set last parameter = 205
  22. subplot(2,2,1);cla; isosurface(seg); camlight; lighting gouraud; title('Final Mask of phi<=0');