File: seamer.c

package info (click to toggle)
libpano13 2.9.12.dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 8,616 kB
  • ctags: 3,403
  • sloc: ansic: 31,169; sh: 8,383; cpp: 1,714; makefile: 236; perl: 202
file content (72 lines) | stat: -rw-r--r-- 2,204 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "filter.h"

void SetDistance8( Image* im, Image* pano, PTRect *theRect, int showprogress );
void SetDistanceImage8 ( Image* im, Image* pano, PTRect *theRect, int showprogress, int feather );
int  merge8 (  Image *dst, Image *src,  int feather, int showprogress, int seam );
void mergeAlpha8 ( Image *im, unsigned char *alpha, int feather, PTRect *theRect );

void SetDistance16( Image* im, Image* pano, PTRect *theRect, int showprogress );
void SetDistanceImage16 ( Image* im, Image* pano, PTRect *theRect, int showprogress, int feather );
int  merge16 (  Image *dst, Image *src,  int feather, int showprogress, int seam );
void mergeAlpha16 ( Image *im, unsigned char *alpha, int feather, PTRect *theRect );



#define PIXEL_TYPE				unsigned char
#define PIXEL_MAX				UCHAR_MAX
#define DBL_TO_PIX(a,b)			DBL_TO_UC(a,b)
#define _SetDistance			SetDistance8
#define _SetDistanceImage		SetDistanceImage8
#define _merge				merge8
#define _mergeAlpha 			mergeAlpha8

#include "seamer_.c"

#undef PIXEL_TYPE				
#undef PIXEL_MAX				
#undef DBL_TO_PIX			
#undef _SetDistance			
#undef _SetDistanceImage		
#undef _merge					
#undef _mergeAlpha 			

#define PIXEL_TYPE			unsigned short
#define PIXEL_MAX			USHRT_MAX
#define DBL_TO_PIX(a,b)			DBL_TO_US(a,b)
#define _SetDistance			SetDistance16
#define _SetDistanceImage		SetDistanceImage16
#define _merge				merge16
#define _mergeAlpha 			mergeAlpha16


#include "seamer_.c" 


int  merge (  Image *dst, Image *src,  int feather, int showprogress, int seam )
{
	if( dst->bitsPerPixel == 48 || dst->bitsPerPixel == 64 )
		return merge16 (  dst, src,   feather,  showprogress,  seam );
	else
		return  merge8 (  dst, src,   feather,  showprogress,  seam );
}

void mergeAlpha ( Image *im, unsigned char *alpha, int feather, PTRect *theRect )
{
	if( im->bitsPerPixel == 48 || im->bitsPerPixel == 64 )
		mergeAlpha16 (  im, alpha, feather, theRect );
	else
		mergeAlpha8 (  im, alpha, feather, theRect );
}



double GetBlendfactor( int d, int s, int feather ) 
{
	double sfactor;
	sfactor = (-1.0 / (2.0*feather)) * d + 0.5 * ( (double)s / (double)feather + 1.0 );
	// randomize
	return sfactor * ( 1.0 - BLEND_RANDOMIZE * rand() / (double)RAND_MAX );
}