【问题标题】:Cropping Circular region of interest around a point in MATLAB在 MATLAB 中围绕一个点裁剪圆形感兴趣区域
【发布时间】:2013-04-07 13:46:12
【问题描述】:

我有一张图像,我想围绕一个点裁剪感兴趣的圆形区域。我在 MATLAB 中做了以下操作:

  vessel=imread('vessel.jpg');
  imshow( vessel)
  t = 0:pi/20:2*pi;
  xc=230; % point around which I want to extract/crop image
  yc=79;
  r=20;   %Radium of circular region of interest
  xcc = r*cos(t)+xc;
   ycc =  r*sin(t)+yc;
   roimaskcc = poly2mask(double(xcc),double(ycc), size(vessel,1),size(vessel,2));
   pr_gccc = find(roimaskcc);
   roimean_cc= mean(vessel(pr_gccc));
  figure, imshow(roimaskcc)

roimaskcc 是正确的,但是当我执行以下操作时,它会给出 nX1 矩阵,而不是掩码下的感兴趣区域:

  vessel_undermask=vessel(roimaskcc==1);

任何人都可以请。帮助提取兴趣点(xc,yc)周围的圆形兴趣区域。 谢谢

【问题讨论】:

    标签: matlab image-processing


    【解决方案1】:

    您正在做的是从 vessel 中提取掩码之外的所有内容。由于没有圆形矩阵这样的东西,Matlab 的解决方案是输出掩码内所有值的 vector

    虽然这在技术上是正确的,但该向量可能很难使用。另一种解决方案是将数据矩阵保留为正方形,并将掩码外的所有内容设置为NaN

    % make a copy      
    vessel_undermask = vessel;
    
    % NaN everything outside the mask (in R, G and B layers)  
    vessel_undermask(repmat(~roimaskcc,[1,1,3])) = NaN;
    
    imshow(vessel_undermask)
    

    这应该会为您提供一个更易于使用的矩阵。

    注意

    vessel_undermask(~isnan(vessel_undermask)) ==  vessel(roimaskcc)
    

    【讨论】:

      【解决方案2】:

      是的,我明白了。我做了类似的事情:

                 vesseltry=vessel;
                vesseltry(~roimaskcc)=0;
      

      vesseltry 现在是我的新图像,带有圆形感兴趣区域...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-03-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-17
        • 2018-08-15
        • 2014-12-23
        相关资源
        最近更新 更多