自动对比两个系列-Dissimilarity测试 [英] automatically compare two series -Dissimilarity test

查看:118
本文介绍了自动对比两个系列-Dissimilarity测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个系列,系列1和系列2。我的目标是要找到多系列2如何不同于系列1,上仓至仓的基础上,(每个箱子重presents的具体特征,)自动/定量。 //img713.imageshack:此图像可以通过的点击这里。

I have two series, series1 and series2. My aim is to find how much Series2 is different from Series1,on a bin to bin basis, (each bin represents a particular feature,) automatically/quantitatively. This image can be seen in its original size by clicking here.

系列1是预期的结果。 系列2是测试/传入系列

Series1 is the expected result. Series2 is the test/incoming series.

我提供直方图,其中系列2重新psented在深褐色$ P $。你还可以注意到在x轴之间221和353有一个显著变化。即系列2小于系列1。我编码使用C ++。

I am providing a histogram plot, where Series2 is represented in dark brown colour. You can also note in the x-axis between 221 and 353 there is a significant variation. ie Series2 is less than Series1. I am coding using C++.

我想,互帮助,但会产生基于相似性而非差异性的值。我看到人们谈论洛夫 - 斯米尔诺夫测试。这是在测试我应该执行?

I think, crosscorrelation will help, but produces a value based on similarity rather than dissimilarity. I see people talk about Kolmogorov-Smirnov Test. Is this the test which i should be performing?

更新1: 我想执行模板匹配。我已经分了我的模板图像中的8×8块,以及我收到的测试图像。我想在模板图像的一个块与测试图像相同的块(基于空间的像素位置)进行比较。我计算强度和每一block.I中取得系列1为模板图像,并有系列2的测试图像。

UPDATE 1: I am trying to perform a template matching. I have divided my template image in to 8x8 blocks as well as my incoming test image. I am trying to compare one block in template image with the same block(based on the spatial pixel positions) in the test image. I calculate the intensity sum within each block.I obtain series1 for the Template image and have Series2 for the test image.

推荐答案

下面是一个用C实现的算法来计算实际数据从$ P $分歧pdicted数据。该算法来自于一本名为实用的基本程序的奥斯本/麦格劳 - 希尔版权1980年。

Here is a C implementation of an algorithm to compute the divergence of actual data from predicted data. The algorithm comes from a book entitled Practical BASIC Programs from Osborne/McGraw-Hill copyright 1980.

下面是.h文件中:

/*
 * divergence.h
 *
 *  Created on: Jan 13, 2011
 *      Author: Erik Oosterwal
 */

#ifndef DIVERGENCE_H_
#define DIVERGENCE_H_

typedef struct
{
    int DataSize;
    float TotalError;
    float AbsError;       //< Total Absolute Error
    float SqError;        //< Total Squared Error
    float MeanError;
    float MeanAbsError;
    float MeanSqError;
    float RMSError;     //< Root Mean Square Error
}DIVERGENCE_ERROR_TYPE;

void Divergence__Error(int size, float expected[], float actual[], DIVERGENCE_ERROR_TYPE *error);


// Prefer to use abs() from "stdlib.h"
#ifndef ABS
    #define ABS(x) ((x)>0) ? (x) : (0-(x))     //< Not safe!!! - Do not increment parameter inside ABS()!
#endif


#endif /* DIVERGENCE_H_ */

... .c文件:

...the .c file:

/*
 * divergence.c
 *
 *  Created on: Jan 13, 2011
 *      Author: Erik Oosterwal
 */

#include "math.h"
#include "divergence.h"

/**
 *      @brief  Compute divergence from expected values.
 *
 *      @details    Compute the raw errors, absolute errors, root mean square errors,
 *                  etc. for a series of values.
 *
 *      @param  size - integer value defines the number of values to compare.
 */
void Divergence__Error(int size, float expected[], float actual[], DIVERGENCE_ERROR_TYPE *error)
{
    double total_err = 0.0;
    double abs_err = 0.0;
    double abs_sqr_err = 0.0;
    double temp = 0.0;
    int index = 0;

    for(index=0; index<size; index++)
    {
        temp = (double)(actual[index])-(double)(expected[index]);
        total_err+=temp;
        abs_err+=ABS(temp);
        abs_sqr_err+=pow(ABS(temp),2);
    }

    temp = (double)size;
    error->DataSize = (int)size;
    error->TotalError = (float)total_err;
    error->AbsError = (float)abs_err;
    error->SqError = (float)abs_sqr_err;
    error->MeanError = (float)(total_err/temp);
    error->MeanAbsError = (float)(abs_err/temp);
    error->MeanSqError = (float)(abs_sqr_err/temp);
    error->RMSError = (float)(sqrt(abs_sqr_err/temp));
}

...和样品的main()用于测试功能:

...and a sample main() for testing the function:

/*
 * main.c
 *
 *  Created on: Jan 13, 2011
 *      Author: Erik Oosterwal
 */

#include <stdio.h>
#include "divergence.h"

float vote[]={40.3, 22.5, 16.3, 10.5, 7.2, 3.2};
float poll[]={42.7, 21.4, 18.2, 6.0, 7.4, 4.3};
float actual[] ={74, 70, 58, 60, 65, 73, 70};
float predict[]={49, 62, 75, 82, 37, 58, 92};

int main(int argc, char *argv[])
{
    DIVERGENCE_ERROR_TYPE stats;

    Divergence__Error(6, poll, vote, &stats);
    printf("%i\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n\n\n",stats.DataSize,stats.TotalError,stats.AbsError,stats.SqError,stats.MeanError,stats.MeanAbsError,stats.MeanSqError,stats.RMSError);

    Divergence__Error(7, predict, actual, &stats);
    printf("%i\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n\n\n",stats.DataSize,stats.TotalError,stats.AbsError,stats.SqError,stats.MeanError,stats.MeanAbsError,stats.MeanSqError,stats.RMSError);

    return(0);
}

我不能保证这是最快的方法和功能,可以使用一些调整,使之更友好的不同的数据类型,但它的工作原理和结果对书中所提供的样品进行验证。

I can't guarantee that this is the fastest method and the function could use some tweaking to make it more friendly to different data types, but it works and the results were verified against the samples provided in the book.

这篇关于自动对比两个系列-Dissimilarity测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆