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 "FexGenericFilter_Include.h"
@ -21,19 +24,24 @@ f(x) = e^(-x^2 / t)
width:
SOLVE(0.1 = f(x), x, Real)
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:
Integral from -sqrt(t LN(10) to sqrt(t LN(10) of f(x) dx
1.715955662·sqrt(t)
2.426727768·s
*/
FexFilter_Gauss::FexFilter_Gauss( double sigma )
{
Sigma = sigma;
TwoSigmaSq = 2*sigma*sigma;
Width = sqrt( TwoSigmaSq*log(10) );
Normalize = 1.0 / (1.715955662 * sqrt( TwoSigmaSq ));
Width = 2.145966026 * sigma;
Normalize = 1.0 / (2.426727768 * sigma);
Normalize *= 1.0 + 0.1 / Width; //its the 0.1 we left out
}
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 "math.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 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;
#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 "FexSystem.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 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 ];
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 {
public:
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
#define STATIC_FOR {DOFOR(0)}
#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.
//
//////////////////////////////////////////////////////////////////////
@ -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 )
{
@ -34,12 +42,6 @@ FexImgPyramidLevel::~FexImgPyramidLevel()
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);
BaseFloatImage_GaussSmooth( iImg, sx, sy, DetectSmoothSigma, 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.
//
//////////////////////////////////////////////////////////////////////

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.
//
//////////////////////////////////////////////////////////////////////
@ -69,25 +72,7 @@ FEXTRACKER_API void SaveMovement( FexMovement* me, const unsigned short* Filenam
}
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 )
{
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.
//
//////////////////////////////////////////////////////////////////////
@ -32,6 +35,5 @@ FEXTRACKER_API FexMovement* CreateMovement();
FEXTRACKER_API void LoadMovement( FexMovement* me, const unsigned short* Filename );
FEXTRACKER_API void SaveMovement( FexMovement* me, const unsigned short* Filename );
FEXTRACKER_API void DeleteMovement( FexMovement* delme );
//WCHAR* FEXTRACKER_API GetUniqueName();
#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.
//
#include "StdAfx.h"
#include "stdio.h"
//#include "mmsystem.h"
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);
PyramidSubsampling = 8;
}
/*
PyramidMaxLevels = 2;
PyramidSubsampling = 2;
*/
}
FexTracker::~FexTracker()
{
@ -58,7 +56,6 @@ FexTracker::~FexTracker()
void FexTracker::ProcessImage( float *Img, bool bFirst )
{
//DWORD t = timeGetTime();
if( bFirst || !CurImg )
{
CurFrame = 0;
@ -80,8 +77,6 @@ void FexTracker::ProcessImage( float *Img, bool bFirst )
NextImg = 0;
}
CurFrame++;
//DWORD t2 = timeGetTime();
//printf( "ProcessImage: %d ms\n", (t2-t) );
}
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
// 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
//
#include "StdAfx.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 )

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.
//
//////////////////////////////////////////////////////////////////////

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.
//
//////////////////////////////////////////////////////////////////////

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
// FexTracker.pch will be the pre-compiled header
// 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,
// or project specific include files that are used frequently, but
// are changed infrequently
@ -24,7 +27,11 @@
#include "FexTrackingFeature.h"
#include "FexMovement.h"
#ifdef IMAGE_DEBUGGER
#include "ext/imdebug.h"
#else
#define imdebug //
#endif
// 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
template< class type >