Diff of /src/seamer.c [000000] .. [24dce1] Maximize Restore

  Switch to unified view

a b/src/seamer.c
1
#include "filter.h"
2
3
void SetDistance8( Image* im, Image* pano, PTRect *theRect, int showprogress );
4
void SetDistanceImage8 ( Image* im, Image* pano, PTRect *theRect, int showprogress, int feather );
5
int  merge8 (  Image *dst, Image *src,  int feather, int showprogress, int seam );
6
void mergeAlpha8 ( Image *im, unsigned char *alpha, int feather, PTRect *theRect );
7
8
void SetDistance16( Image* im, Image* pano, PTRect *theRect, int showprogress );
9
void SetDistanceImage16 ( Image* im, Image* pano, PTRect *theRect, int showprogress, int feather );
10
int  merge16 (  Image *dst, Image *src,  int feather, int showprogress, int seam );
11
void mergeAlpha16 ( Image *im, unsigned char *alpha, int feather, PTRect *theRect );
12
13
14
15
#define PIXEL_TYPE                unsigned char
16
#define PIXEL_MAX             UCHAR_MAX
17
#define DBL_TO_PIX(a,b)           DBL_TO_UC(a,b)
18
#define _SetDistance          SetDistance8
19
#define _SetDistanceImage     SetDistanceImage8
20
#define _merge                merge8
21
#define _mergeAlpha           mergeAlpha8
22
23
#include "seamer_.c"
24
25
#undef PIXEL_TYPE             
26
#undef PIXEL_MAX              
27
#undef DBL_TO_PIX         
28
#undef _SetDistance           
29
#undef _SetDistanceImage      
30
#undef _merge                 
31
#undef _mergeAlpha            
32
33
#define PIXEL_TYPE            unsigned short
34
#define PIXEL_MAX         USHRT_MAX
35
#define DBL_TO_PIX(a,b)           DBL_TO_US(a,b)
36
#define _SetDistance          SetDistance16
37
#define _SetDistanceImage     SetDistanceImage16
38
#define _merge                merge16
39
#define _mergeAlpha           mergeAlpha16
40
41
42
#include "seamer_.c" 
43
44
45
int  merge (  Image *dst, Image *src,  int feather, int showprogress, int seam )
46
{
47
  if( dst->bitsPerPixel == 48 || dst->bitsPerPixel == 64 )
48
      return merge16 (  dst, src,   feather,  showprogress,  seam );
49
  else
50
      return  merge8 (  dst, src,   feather,  showprogress,  seam );
51
}
52
53
void mergeAlpha ( Image *im, unsigned char *alpha, int feather, PTRect *theRect )
54
{
55
  if( im->bitsPerPixel == 48 || im->bitsPerPixel == 64 )
56
      mergeAlpha16 (  im, alpha, feather, theRect );
57
  else
58
      mergeAlpha8 (  im, alpha, feather, theRect );
59
}
60
61
62
63
double GetBlendfactor( int d, int s, int feather ) 
64
{
65
  double sfactor;
66
  sfactor = (-1.0 / (2.0*feather)) * d + 0.5 * ( (double)s / (double)feather + 1.0 );
67
  // randomize
68
  return sfactor * ( 1.0 - BLEND_RANDOMIZE * rand() / (double)RAND_MAX );
69
}
70
71
72