fixed fextracker normalization

added copyright notice

Originally committed to SVN as r196.
This commit is contained in:
tentacle 2006-03-04 15:26:09 +00:00
parent 302b89d1eb
commit 627a85bd69
21 changed files with 79 additions and 126 deletions

View file

@ -1,3 +1,6 @@
// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
#include <math.h> #include <math.h>
#include "FexGenericFilter_Include.h" #include "FexGenericFilter_Include.h"
@ -21,19 +24,24 @@ f(x) = e^(-x^2 / t)
width: width:
SOLVE(0.1 = f(x), x, Real) SOLVE(0.1 = f(x), x, Real)
x = - sqrt(t LN(10) ? x = sqrt(t LN(10) x = - sqrt(t LN(10) ? x = sqrt(t LN(10)
x = - 1.517427129·sqrt t ? x = 1.517427129·sqrt t
x = - sqrt(2*s*s* LN(10)) ? x = sqrt(2*s*s* LN(10))
x = - 2.145966026·s ? x = 2.145966026·s
sum: sum:
Integral from -sqrt(t LN(10) to sqrt(t LN(10) of f(x) dx Integral from -sqrt(t LN(10) to sqrt(t LN(10) of f(x) dx
1.715955662·sqrt(t) 1.715955662·sqrt(t)
2.426727768·s
*/ */
FexFilter_Gauss::FexFilter_Gauss( double sigma ) FexFilter_Gauss::FexFilter_Gauss( double sigma )
{ {
Sigma = sigma; Sigma = sigma;
TwoSigmaSq = 2*sigma*sigma; TwoSigmaSq = 2*sigma*sigma;
Width = sqrt( TwoSigmaSq*log(10) ); Width = 2.145966026 * sigma;
Normalize = 1.0 / (1.715955662 * sqrt( TwoSigmaSq )); Normalize = 1.0 / (2.426727768 * sigma);
Normalize *= 1.0 + 0.1 / Width; //its the 0.1 we left out
} }
FexFilter_Gauss::~FexFilter_Gauss() FexFilter_Gauss::~FexFilter_Gauss()
{ {

View file

@ -1,3 +1,6 @@
// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
#include "stdio.h" #include "stdio.h"
#include "math.h" #include "math.h"
#include "memory.h" #include "memory.h"

View file

@ -1,3 +1,6 @@
// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
{ {
#define PixelType float #define PixelType float
#define PixelMin 0 #define PixelMin 0

View file

@ -1,3 +1,6 @@
// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
{ {
double width = FilterWidth; double width = FilterWidth;
#ifdef CONTRIB_XSCALE #ifdef CONTRIB_XSCALE

View file

@ -1,3 +1,6 @@
// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
#include "stdafx.h" #include "stdafx.h"
#include "FexSystem.h" #include "FexSystem.h"
#include "ext\imdebug.h" #include "ext\imdebug.h"

View file

@ -1,3 +1,6 @@
// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
{ {
#define PixelType BYTE #define PixelType BYTE
#define PixelMin 0 #define PixelMin 0

View file

@ -1,3 +1,6 @@
// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
{ {
FexFilterContribution* Contrib = new FexFilterContribution[ ImageOutSX ]; FexFilterContribution* Contrib = new FexFilterContribution[ ImageOutSX ];
double XScale = (double)ImageOutSX / (double) ImageInSX; double XScale = (double)ImageOutSX / (double) ImageInSX;

View file

@ -1,3 +1,6 @@
// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
class FexFilter { class FexFilter {
public: public:
FexFilter(); FexFilter();

View file

@ -1,3 +1,6 @@
// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
#if ImagePlanes==1 #if ImagePlanes==1
#define STATIC_FOR {DOFOR(0)} #define STATIC_FOR {DOFOR(0)}
#elif ImagePlanes==3 #elif ImagePlanes==3

View file

@ -1,3 +1,6 @@
// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
// FexImgPyramid.cpp: implementation of the FexImgPyramid class. // FexImgPyramid.cpp: implementation of the FexImgPyramid class.
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -15,6 +18,11 @@ void BaseFloatImage_LanczosRescale( float* in, int inSx, int inSy, float* out, i
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
//turn off image debugging
#ifndef imdebug
#define imdebug //
#endif
FexImgPyramidLevel::FexImgPyramidLevel( int isx, int isy ) FexImgPyramidLevel::FexImgPyramidLevel( int isx, int isy )
{ {
@ -34,12 +42,6 @@ FexImgPyramidLevel::~FexImgPyramidLevel()
void FexImgPyramidLevel::Fill( float* iImg, float DetectSmoothSigma ) void FexImgPyramidLevel::Fill( float* iImg, float DetectSmoothSigma )
{ {
/*
for( int y=0;y<sy;y++ )
for( int x=0;x<sx;x++ )
Img[ sx*y + x ] = iImg[ sx*y + x ];
*/
imdebug("lum b=32f w=%d h=%d %p /255", sx, sy, iImg); imdebug("lum b=32f w=%d h=%d %p /255", sx, sy, iImg);
BaseFloatImage_GaussSmooth( iImg, sx, sy, DetectSmoothSigma, Img ); BaseFloatImage_GaussSmooth( iImg, sx, sy, DetectSmoothSigma, Img );
imdebug("lum b=32f w=%d h=%d %p /255", sx, sy, Img); imdebug("lum b=32f w=%d h=%d %p /255", sx, sy, Img);

View file

@ -1,3 +1,6 @@
// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
// FexImgPyramid.h: interface for the FexImgPyramid class. // FexImgPyramid.h: interface for the FexImgPyramid class.
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////

View file

@ -1,3 +1,6 @@
// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
// FexMovement.cpp: implementation of the FexMovement class. // FexMovement.cpp: implementation of the FexMovement class.
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -69,25 +72,7 @@ FEXTRACKER_API void SaveMovement( FexMovement* me, const unsigned short* Filenam
} }
fclose( fi ); fclose( fi );
} }
/*
const WCHAR* FEXTRACKER_API GetUniqueName()
{
static WCHAR Name[512];
time_t long_time;
time( &long_time );
swprintf( Name, L"%x%x\n", timeGetTime(), long_time );
for( DWORD i=0;i<wcslen(Name);i++ )
{
Name[i] = towlower( Name[i] );
if( Name[i]<'a' || Name[i]>'z' )
Name[i] = '_';
}
wcscat( Name, L".fexmove" );
return Name;
}
*/
FEXTRACKER_API void DeleteMovement( FexMovement* delme ) FEXTRACKER_API void DeleteMovement( FexMovement* delme )
{ {
delete delme; delete delme;

View file

@ -1,3 +1,6 @@
// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
// FexMovement.h: interface for the FexMovement class. // FexMovement.h: interface for the FexMovement class.
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -32,6 +35,5 @@ FEXTRACKER_API FexMovement* CreateMovement();
FEXTRACKER_API void LoadMovement( FexMovement* me, const unsigned short* Filename ); FEXTRACKER_API void LoadMovement( FexMovement* me, const unsigned short* Filename );
FEXTRACKER_API void SaveMovement( FexMovement* me, const unsigned short* Filename ); FEXTRACKER_API void SaveMovement( FexMovement* me, const unsigned short* Filename );
FEXTRACKER_API void DeleteMovement( FexMovement* delme ); FEXTRACKER_API void DeleteMovement( FexMovement* delme );
//WCHAR* FEXTRACKER_API GetUniqueName();
#endif // !defined(AFX_FEXMOVEMENT_H__63D8ADD8_4EA1_4C56_8D6F_7B587A1A61A4__INCLUDED_) #endif // !defined(AFX_FEXMOVEMENT_H__63D8ADD8_4EA1_4C56_8D6F_7B587A1A61A4__INCLUDED_)

View file

@ -1,9 +1,11 @@
// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
// FexTracker.cpp : Defines the entry point for the DLL application. // FexTracker.cpp : Defines the entry point for the DLL application.
// //
#include "StdAfx.h" #include "StdAfx.h"
#include "stdio.h" #include "stdio.h"
//#include "mmsystem.h"
FexTracker::FexTracker( int sx, int sy, int inFeatures ) FexTracker::FexTracker( int sx, int sy, int inFeatures )
{ {
@ -45,10 +47,6 @@ FexTracker::FexTracker( int sx, int sy, int inFeatures )
PyramidMaxLevels = (int) (val + 0.99); PyramidMaxLevels = (int) (val + 0.99);
PyramidSubsampling = 8; PyramidSubsampling = 8;
} }
/*
PyramidMaxLevels = 2;
PyramidSubsampling = 2;
*/
} }
FexTracker::~FexTracker() FexTracker::~FexTracker()
{ {
@ -58,7 +56,6 @@ FexTracker::~FexTracker()
void FexTracker::ProcessImage( float *Img, bool bFirst ) void FexTracker::ProcessImage( float *Img, bool bFirst )
{ {
//DWORD t = timeGetTime();
if( bFirst || !CurImg ) if( bFirst || !CurImg )
{ {
CurFrame = 0; CurFrame = 0;
@ -80,8 +77,6 @@ void FexTracker::ProcessImage( float *Img, bool bFirst )
NextImg = 0; NextImg = 0;
} }
CurFrame++; CurFrame++;
//DWORD t2 = timeGetTime();
//printf( "ProcessImage: %d ms\n", (t2-t) );
} }
void FexTracker::ProcessingDone() void FexTracker::ProcessingDone()

View file

@ -1,3 +1,6 @@
// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
// The following ifdef block is the standard way of creating macros which make exporting // The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the FEXTRACKER_EXPORTS // from a DLL simpler. All files within this DLL are compiled with the FEXTRACKER_EXPORTS

View file

@ -1,9 +1,11 @@
// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
// FexTrackerMovement.cpp // FexTrackerMovement.cpp
// //
#include "StdAfx.h" #include "StdAfx.h"
#include "stdio.h" #include "stdio.h"
//#include "mmsystem.h"
@ -28,97 +30,7 @@ void FexTracker::InfluenceFeatures( int Frame, float x, float y, float off )
} }
} }
/*
void LineTracing( haAssLine *c, vec2& TracePos, vec2& TraceScale, int Frame, vec2 InScreenPlace )
{
TracePos = vec2(0,0);
TraceScale = vec2(0,0);
vec2 Sum1Pos = vec2(0,0);
vec2 Sum2Pos = vec2(0,0);
float TraceScaleV=0;
float wsum = 0;
for( int i=0;i<c->FeatureIdList.GetSize();i++ )
{
tenFeatureLink l = c->FeatureIdList[i];
tenFeature f = Trace_GetFeatureByID( l.id, Frame );
if( f.id < 0 || l.weight<0.01 )
continue;
Sum1Pos += vec2(
(f.x)/float(ncols)*float(AssRes[0]),
(f.y)/float(nrows)*float(AssRes[1])
)*l.weight;
Sum2Pos += vec2(
(l.sub.x)/float(ncols)*float(AssRes[0]),
(l.sub.y)/float(nrows)*float(AssRes[1])
)*l.weight;
wsum += l.weight;
}
if( wsum>0.01 )
{
Sum1Pos /= wsum;
Sum2Pos /= wsum;
TracePos = Sum1Pos - Sum2Pos;
wsum = 0;
CArray<float, float&> DistList;
CArray<float, float&> WeightList;
//now we know weighted mid point, gen vectors from points to mid
for( int i=0;i<c->FeatureIdList.GetSize();i++ )
{
tenFeatureLink l = c->FeatureIdList[i];
tenFeature f = Trace_GetFeatureByID( l.id, Frame );
if( f.id < 0 || l.weight<0.01 )
continue;
vec2 mid = vec2(
(f.x)/float(ncols)*float(AssRes[0]),
(f.y)/float(nrows)*float(AssRes[1])
);
vec2 midToMe = mid - Sum1Pos;
vec2 stdMidToMe = vec2(
(l.sub.x)/float(ncols)*float(AssRes[0]),
(l.sub.y)/float(nrows)*float(AssRes[1])
) - Sum2Pos;
float stdlen = sqrtf( stdMidToMe.x*stdMidToMe.x + stdMidToMe.y*stdMidToMe.y );
if( stdlen < 3 )
{//too much error amplification.skip
continue;
}
float len = sqrtf( midToMe.x*midToMe.x + midToMe.y*midToMe.y );
float scale = len/stdlen;
// TRACE( "%f\n", scale );
float addme = scale*l.weight;
TraceScaleV += addme;
DistList.Add( scale );
WeightList.Add( l.weight );
wsum += l.weight;
}
TraceScaleV /= wsum;
float TraceScaleV2=0;
for( i=0;i<DistList.GetSize();i++ )
{
TraceScaleV2 += ((DistList[i]-TraceScaleV)*0.5f+TraceScaleV)*WeightList[i];
}
TraceScaleV2 /= wsum;
TraceScale = vec2(1,1)*TraceScaleV2;
vec2 MidToItemStd = InScreenPlace - Sum2Pos;
TracePos += MidToItemStd*(TraceScaleV2-1);
}
else
{
TracePos = vec2(0,0);
TraceScale = vec2(1,1);
}
}
*/
#define VEC2LEN(a) sqrtf( (a).x*(a).x+(a).y*(a).y ) #define VEC2LEN(a) sqrtf( (a).x*(a).x+(a).y*(a).y )

View file

@ -1,3 +1,6 @@
// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
// FexTrackingFeature.cpp: implementation of the FexTrackingFeature class. // FexTrackingFeature.cpp: implementation of the FexTrackingFeature class.
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////

View file

@ -1,3 +1,6 @@
// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
// FexTrackingFeature.h: interface for the FexTrackingFeature class. // FexTrackingFeature.h: interface for the FexTrackingFeature class.
// //
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////

View file

@ -1,3 +1,6 @@
// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
// stdafx.cpp : source file that includes just the standard includes // stdafx.cpp : source file that includes just the standard includes
// FexTracker.pch will be the pre-compiled header // FexTracker.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information // stdafx.obj will contain the pre-compiled type information

View file

@ -1,3 +1,6 @@
// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
// stdafx.h : include file for standard system include files, // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but // or project specific include files that are used frequently, but
// are changed infrequently // are changed infrequently
@ -24,7 +27,11 @@
#include "FexTrackingFeature.h" #include "FexTrackingFeature.h"
#include "FexMovement.h" #include "FexMovement.h"
#ifdef IMAGE_DEBUGGER
#include "ext/imdebug.h" #include "ext/imdebug.h"
#else
#define imdebug //
#endif
// TODO: reference additional headers your program requires here // TODO: reference additional headers your program requires here

View file

@ -1,3 +1,6 @@
// This file is part of FexTracker and (C) 2006 by Hajo Krabbenhöft (tentacle)
// All rights reserved but the aegisub project is allowed to use it.
#pragma once #pragma once
template< class type > template< class type >