【问题标题】:Covariogram Method for a Binary Image in RR中二值图像的协变函数方法
【发布时间】:2016-11-15 12:27:31
【问题描述】:

我正在尝试获取协方差图以计算其上的一些值。这是之前完成的工作; Quantitative Analysis of Banded Structures in Dual-Phase Steels

只需阅读2.页面,就足以理解该方法。

有一张图片用于说明本文档中的方法,如下所示:

你可以看到作者在情节的例子中使用了一张图片,然后他们得到了那个情节。

这是我正在使用的图像,作为二进制图像:

我只想通过使用我的图像来获得该图。

代码:

setwd(".../Project/R/Workspace/Task1")
library("EBImage", lib.loc="~/R/win-library/3.2")
img <- readImage(".../Project/Beispielbilder/example.jpg")
display(img,  title='Image')
M <- img_ithr
plot(cov(M),xlim=c(0,1), ylim=c(0,300))

感谢您的帮助和时间,各位。

【问题讨论】:

    标签: r image-processing covariance covariogram


    【解决方案1】:

    根据您的示例文件和论文中的描述,我想出了以下内容。

    library("EBImage")
    
    img <- readImage("https://i.stack.imgur.com/YMBQO.jpg")
    
    ## discard color channels by collapsing to grayscale, and binarize
    bin <- channel(img, "gray") > .5
    
    ## function calculating the overlap between the original structure
    ## and the structure shifted by a vector v
    C <- function(img, v) {
      sum(img & translate(img, v)) / prod(dim(img)[1:2]-v)
    }
    
    h <- 1:300
    
    ## horizontal
    C_h <- sapply(h, function(h) C(bin, c(h, 0)))
    
    ## vertical
    C_v <- sapply(h, function(h) C(bin, c(0, h)))
    
    matplot(h, cbind(C_h, C_v), xlim = range(h), ylim = range(C_h, C_v),
             ylab = "C", col = c("red", "blue"), type = "l", lty = 1)
    

    在两个垂直方向上分别测量协方差。不过,我不确定在论文的情节中如何考虑 β 方向。

    【讨论】:

    • 感谢您的回答!蓝线是我需要检查的垂直线。在那之后,我应该找到最大最小点并对其进行一些数学运算。
    猜你喜欢
    • 1970-01-01
    • 2022-06-15
    • 2018-06-10
    • 1970-01-01
    • 1970-01-01
    • 2021-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多