【问题标题】:Detection of homogeneous area in term of connectivity in image根据图像中的连通性检测均匀区域
【发布时间】:2014-05-06 13:24:28
【问题描述】:

我正在寻找一些测量来区分这两个二进制图像(文本和噪声)。

频域的霍夫变换并不能告诉我太多(无论是骨架还是原始形状),如下所示!

在空间域中,我尝试测量给定像素是否参与直线或曲线,或参与随机形状,然后测量所有像素参与和不参与正常形状(直线和曲线)的百分比) 来区分这些图像,但我没有成功,在实现中。

你怎么看?

我使用matlab进行测试。

提前致谢

【问题讨论】:

    标签: matlab image-processing spatial feature-detection


    【解决方案1】:

    如果我们尝试使用原始形状而不是骨架,现在您的建议是什么(以避免信息丢失)。 我尝试通过计算顺时针从白色到黑色的过渡次数来测量给定像素的笔画(而不是笔直的分支)在整个像素中的伸长率。​​p>

    我正在考虑使用一个带半径的圆,并将考虑的像素作为原点,并将位于圆边缘的像素存储在有序列表中(顺时针),然后计算过渡次数(黑色到白色)从这个列表中。

    通过增加圆的半径,我们可以追踪拉长的斯托克斯的形状并知道他的方向。

    这是一个说明这一点的架构。 转换次数等于 0 或大于 2(红色)的像素必须分类为噪声,而转换次数为 2 或 1 的像素则分类为正常。

    您如何看待这种方法!

    【讨论】:

      【解决方案2】:

      查看骨架图像,可以注意到与文本图像相比,噪声图像中有很多分支,这看起来是可以利用的特征之一。下面显示的代码实验试图使用 OP 的图像来验证相同 -

      实验代码

      %%// Experiment to research what features what might help us 
      %%// differentiate betwen noise and text images
      
      %%// Read in the given images
      img1 = imread('noise.png');
      img2 = imread('text.png');
      
      %%// Since the given images had the features as black and rest as white, 
      %%// we must invert them
      img1 = ~im2bw(img1);
      img2 = ~im2bw(img2);
      
      %%// Remove the smaller blobs from both of the images which basically
      %%// denote the actual noise in them
      img1 = rmnoise(img1,60);
      img2 = rmnoise(img2,60);
      
      %// Get the skeleton images
      img1 = bwmorph(img1,'skel',Inf);
      img2 = bwmorph(img2,'skel',Inf);
      
      %%// Find blobs branhpoints for each blob in both images
      [L1, num1] = bwlabel(img1);
      [L2, num2] = bwlabel(img2);
      for k = 1:num1
          img1_bpts_count(k) = nnz(bwmorph(L1==k,'branchpoints'));
      end
      for k = 1:num2
          img2_bpts_count(k) = nnz(bwmorph(L2==k,'branchpoints'));
      end
      
      %%// Get the standard deviation of branch points count
      img1_branchpts_std = std(img1_bpts_count)
      img2_branchpts_std = std(img2_bpts_count)
      

      注意:上面的代码使用了一个函数——rmnoise,它是基于link讨论的问题构建的:

      function NewImg = rmnoise(Img,threshold)
      
      [L,num] = bwlabel( Img );
      counts = sum(bsxfun(@eq,L(:),1:num));
      B1 = bsxfun(@eq,L,permute(find(counts>threshold),[1 3 2]));
      NewImg = sum(B1,3)>0;
      
      return;
      

      输出

      img1_branchpts_std =
         73.6230
      
      img2_branchpts_std =
         12.8417
      

      可以看到两个输入图像的标准差之间的巨大差异,表明可以使用此功能。

      在其他一些样本上运行

      为了让我们的理论更具体一点,让我们使用纯文本图像并逐渐添加噪声,看看分支点的标准偏差是否有任何建议,命名为check_value

      (一)纯文字图片

      check_value = 1.7461

      (二)一些添加的噪声图像

      check_value = 30.1453

      (III) 再添加一些噪点图片

      check_value = 54.6446

      结论:可以看出,这个参数提供了一个很好的指标来判断图像的性质。

      最终代码

      可以编写一个脚本来测试另一个输入图像是文本还是噪声图像,像这样 -

      %%// Parameters
      %%// 1. Decide this based on the typical image size and count of pixels 
      %%// in the biggest noise blob
      rmnoise_threshold = 60; 
      
      %%// 2. Decide this based on the typical image size and how convoluted the
      %%// noisy images are 
      branchpts_count_threshold = 50; 
      
      %%// Actual processing
      %%// We are assuming input images as binary images with features as true 
      %%// and false in rest of the region
      img1 = im2bw(imread(FILE)); 
      img1 = rmnoise(img1,rmnoise_threshold);
      img1 = bwmorph(img1,'skel',Inf);
      
      [L1, num1] = bwlabel(img1);
      for k = 1:num1
          img1_bpts_count(k) = nnz(bwmorph(L1==k,'branchpoints'));
      end
      
      if std(img1_bpts_count) > branchpts_count_threshold
          disp('This is a noise image');
      else
          disp('This is a text image');
      end
      

      【讨论】:

        猜你喜欢
        • 2014-09-16
        • 1970-01-01
        • 2013-02-02
        • 2023-03-27
        • 1970-01-01
        • 2016-05-21
        • 1970-01-01
        • 2021-01-04
        • 1970-01-01
        相关资源
        最近更新 更多