MATLAB小操作

      这个是参与研究生的左心分割项目,我所做的一些代码。这个项目目的就是为了自动识别左心轮廓,这个代码的作用就是将深度学习产生的预测以图片形式保存下来,然后人工修改预测不好的部分,作为标签,再用来产生模型。预测新的轮廓。

言归正传,以下是功能实现:

%有内外两轮廓以及原图,方法是把内外两轮廓覆盖到原图上,
clc;close all;clear;
path='F:\show_counter\matfile';
path=strrep(path,'\','/');
GEColormap=loadGEColormap();
B=cell(1,8);



%% show both

for i=1:8       %心肌灌注成像,每个病人又分为8个gate
    for s=0:9    %每个gate又有10个slice
    % get pred contour : ML contour  外
    Seg_name=sprintf('epi/Patient002481_data_0%d_pred_0%d.mat',i,s);
     %sprintf 拼接路径
    workpath=fullfile(path,Seg_name);
    load(workpath); 
    BW=bwboundaries(pred);
    B{i}=BW{:}(:,:);
    contour_path1=zeros(32,32); 
    iter=size(B{i},1);
    for j=1:iter
        contour_path1(B{i}(j,1),B{i}(j,2))=1;%contour_path1为DL产生的外轮廓
    end
    
    %内
    Seg_name=sprintf('endo/Patient002481_data_0%d_pred_0%d.mat',i,s);
    workpath=fullfile(path,Seg_name);
    load(workpath); 
    BW=bwboundaries(pred);
    B{i}=BW{:}(:,:);
    contour_path2=zeros(32,32);
    iter=size(B{i},1);
    for j=1:iter
        contour_path2(B{i}(j,1),B{i}(j,2))=1;
    end
    
    % get original image
    Im_name=sprintf('epi/Patient002481_data_0%d_img_0%d.mat',i,s);
    workpath=fullfile(path,Im_name);
    load(workpath);    
    process_img=img.*(1-contour_path1);
    ones=find(contour_path2==1);
    process_img(ones)=0;
    figure(i);
    %subplot();
    save_path=sprintf('test%d.png',s); 
    saveas(gca,save_path);             %保存图片
    R_process_img=rot90(process_img,1);
    imagesc(R_process_img);
    colormap(GEColormap);
    axis off;

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值