I am trying to obtain a covariogram plot in order to calculate some values over it. Here is the work which is done before; Quantitative Analysis of Banded Structures in Dual-Phase Steels
Just read the 2. page, that will be enough to understand the method.
There is an image for illustrating the method in this document as follows:
You can see that the authors used an image in the example on plot, then they obtained that plot.
Here is the image that I am using, as a binary image:
I just want to obtain that plot by using my image.
Code:
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))
Thank you for your help and time, people.
Based on your sample file and the description from the paper, I came up with the following.
library("EBImage")
img <- readImage("https://i.sstatic.net/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)
The covariance is measured separately in the two perpendicular directions. I'm not sure, though, how the directions β were taken into account in the plot from the paper.