Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用R匹配图像子集和较大图像_R_Image Processing - Fatal编程技术网

用R匹配图像子集和较大图像

用R匹配图像子集和较大图像,r,image-processing,R,Image Processing,我使用R进行一些非常简单的图像分析。具体来说,我试图确定一个图像是否是另一个图像的裁剪版本 在R中必须有一个“简单”的方法来做到这一点,但我没有找到它。我怀疑我对这个问题想得太多了,所以我想寻找我所缺少的指导 具体而言,考虑以下几点: install.packages("jpeg") library(jpeg) image.main <- readJPEG("path to a jpeg image") image.main.sub <- readJPEG("path to ano

我使用R进行一些非常简单的图像分析。具体来说,我试图确定一个图像是否是另一个图像的裁剪版本

在R中必须有一个“简单”的方法来做到这一点,但我没有找到它。我怀疑我对这个问题想得太多了,所以我想寻找我所缺少的指导

具体而言,考虑以下几点:

install.packages("jpeg")
library(jpeg)

image.main <- readJPEG("path to a jpeg image")
image.main.sub <- readJPEG("path to another jpeg image, cropped version of the first")

if (someMagicFunctionThatFindsSubImage(image.main,image.main.sub)) {
    # TRUE - image.main.sub is a subset of image.main 
} else {
    # FALSE - image.main.sub is NOT a subset of image.main
}

someMagicFunctionThatFindsSubImage <- function (bigImage,smallImage) {
  # the matrix of values that represent smallImage is also present
  # in the matrix of values that represent bigImage
  # bigImage and smallImage can be megabytes in size
  # bigImage and smallImage can be limited to RGB Jpeg data (array of X,Y and 3 layers)
}
install.packages(“jpeg”)
图书馆(jpeg)

image.main事实上,是一种“简单”的方法。我很幸运地与一位图像分析教授共度圣诞节。他花了超过一分钟的时间建议使用互协方差互相关。两者都作为stats包的一部分出现在R中

>? ccf
下面是它的工作原理:

在上面的示例中,我使用

> install.packages("jpeg")
> library(jpeg)

> image.main <- readJPEG("path to a jpeg image")
> image.main.sub <- readJPEG("path to another jpeg image, cropped version of the first")
为了便于讨论,我将创建此数据的高度简化版本。请容忍我一会儿

> image.main <- sample(1:20,20)
> image.main.sub <- image.main[5:8]
现在,我们可以使用ccf函数确定image.main.sub在image.main中的位置

> ccf(image.main,image.main.sub,plot=FALSE)

Autocorrelations of series ‘X’, by lag

   -3     -2     -1      0      1      2      3 
0.440 -0.332  0.295 -0.935  0.327 -0.010  0.215 
ccf以不同的偏移量(滞后)显示两个数据集之间的距离。值1表示100%的相关性。如果我们将image.main子集以匹配image.main.sub

> ccf(image.main[5:8],image.main.sub,plot=FALSE)

Autocorrelations of series ‘X’, by lag

    -3     -2     -1      0      1      2      3 
-0.398  0.281 -0.382  1.000 -0.382  0.281 -0.398 
注意滞后0时的值1.000。比赛

与此程序相关的是

我已经在我的页面上构建了整个解决方案


mnr

事实上,是一种“简单”的方法。我很幸运地与一位图像分析教授共度圣诞节。他花了超过一分钟的时间建议使用互协方差互相关。两者都作为stats包的一部分出现在R中

>? ccf
下面是它的工作原理:

在上面的示例中,我使用

> install.packages("jpeg")
> library(jpeg)

> image.main <- readJPEG("path to a jpeg image")
> image.main.sub <- readJPEG("path to another jpeg image, cropped version of the first")
为了便于讨论,我将创建此数据的高度简化版本。请容忍我一会儿

> image.main <- sample(1:20,20)
> image.main.sub <- image.main[5:8]
现在,我们可以使用ccf函数确定image.main.sub在image.main中的位置

> ccf(image.main,image.main.sub,plot=FALSE)

Autocorrelations of series ‘X’, by lag

   -3     -2     -1      0      1      2      3 
0.440 -0.332  0.295 -0.935  0.327 -0.010  0.215 
ccf以不同的偏移量(滞后)显示两个数据集之间的距离。值1表示100%的相关性。如果我们将image.main子集以匹配image.main.sub

> ccf(image.main[5:8],image.main.sub,plot=FALSE)

Autocorrelations of series ‘X’, by lag

    -3     -2     -1      0      1      2      3 
-0.398  0.281 -0.382  1.000 -0.382  0.281 -0.398 
注意滞后0时的值1.000。比赛

与此程序相关的是

我已经在我的页面上构建了整个解决方案


mnr

请编辑您的问题以解决两个问题:“图像子集”的含义是什么?readJPEG来自哪个软件包?为什么您认为这对于任何软件来说都是一个“简单”的任务?如果你非常确定永远不会有再压缩、位深度等,那么你可以在卷积运算中使用小图像作为核心。至少可以说,这是处理器密集型的;好的匹配算法通常需要花钱,这是有道理的。@BondedDust:添加了安装包(“jpeg”)和库(jpeg)。@CarlWitthoft:当然-图像分析很困难。但在我跳到复杂的东西之前,我要确保我已经把简单的东西都吃光了。“编程是避免复杂解决方案的艺术”当你在编程时,请不要用“复杂”来表示“复杂”。复数在数学中是一个非常具体的概念,因此在软件中也是如此。请编辑你的问题以解决两个问题:“图像子集”是什么意思?readJPEG来自哪个软件包?为什么您认为这对于任何软件来说都是一个“简单”的任务?如果你非常确定永远不会有再压缩、位深度等,那么你可以在卷积运算中使用小图像作为核心。至少可以说,这是处理器密集型的;好的匹配算法通常需要花钱,这是有道理的。@BondedDust:添加了安装包(“jpeg”)和库(jpeg)。@CarlWitthoft:当然-图像分析很困难。但在我跳到复杂的东西之前,我要确保我已经把简单的东西都吃光了。“编程是避免复杂解决方案的艺术”当你在编程时,请不要用“复杂”来表示“复杂”。复数在数学中是一个非常具体的概念,因此在软件中也是如此。仅供参考:github链接似乎不是最新的,…仅供参考:github链接似乎不是最新的,。。。