R中二值图像的协方差图方法

Covariogram Method for a Binary Image in R

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

Just read the 2. page, that will be enough to understand the method.

本文档中的方法有图说明如下:

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

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

我只是想通过我的图像获得那个情节。

代码:

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))

感谢大家的帮助和时间。

根据您的示例文件和论文中的描述,我得出以下结论。

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)

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