map.h 2.07 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
#ifndef BIOEM_MAP_H
#define BIOEM_MAP_H

#include "defs.h"
#include <complex>
#include <math.h>

class bioem_param;

class bioem_RefMap
{
public:
13
14
	bioem_RefMap()
	{
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
		maps = NULL;
		RefMapsFFT = NULL;
		sum_RefMap = NULL;
		sumsquare_RefMap = NULL;
	}

	void freePointers()
	{
		if (maps) free(maps);
		if (sum_RefMap) free(sum_RefMap);
		if (sumsquare_RefMap) free(sumsquare_RefMap);
		if (RefMapsFFT) delete[] RefMapsFFT;
		maps = NULL;
		sum_RefMap = NULL;
		sumsquare_RefMap = NULL;
30
31
		RefMapsFFT = NULL;
	}
32
33
	int readRefMaps(bioem_param& param);
	int PreCalculateMapsFFT(bioem_param& param);
34
35

	mycomplex_t* RefMapsFFT;
36
37

	int ntotRefMap;
38
39
40
41
42
	int numPixels;
	int refMapSize;
	myfloat_t* maps;
	myfloat_t* sum_RefMap;
	myfloat_t* sumsquare_RefMap;
43

44
45
46
	__host__ __device__ inline myfloat_t get(int map, int x, int y) const {return(maps[map * refMapSize + x * numPixels + y]);}
	__host__ __device__ inline const myfloat_t* getp(int map, int x, int y) const {return(&maps[map * refMapSize + x * numPixels]);}
	__host__ __device__ inline myfloat_t* getmap(int map) {return(&maps[map * refMapSize]);}
47
48
49
50
51
};

class bioem_RefMap_Mod
{
public:
52
53
54
55
56
	int ntotRefMap;
	myfloat_t Ref[BIOEM_MAP_SIZE_X][BIOEM_MAP_SIZE_Y][BIOEM_MAX_MAPS];
	myfloat_t sum_RefMap[BIOEM_MAX_MAPS];
	myfloat_t sumsquare_RefMap[BIOEM_MAX_MAPS];

57
	__host__ __device__ inline myfloat_t get(int map, int x, int y) const {return(Ref[x][y][map]);}
58

59
	bioem_RefMap_Mod() {ntotRefMap = 0;}
60

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
	bioem_RefMap_Mod(const bioem_RefMap& map)
	{
		ntotRefMap = map.ntotRefMap;
		memcpy(sum_RefMap, map.sum_RefMap, sizeof(sum_RefMap));
		memcpy(sumsquare_RefMap, map.sumsquare_RefMap, sizeof(sumsquare_RefMap));
#pragma omp parallel for
		for (int i = 0;i < ntotRefMap;i++)
		{
			for (int j = 0;j < BIOEM_MAP_SIZE_X;j++)
			{
				for (int k = 0;k < BIOEM_MAP_SIZE_Y;k++)
				{
					Ref[j][k][i] = map.get(i, j, k);
				}
			}
		}
	}
};

class bioem_Probability
{
public:
83
84
85
86
87
	myfloat_t forAngles[MAX_ORIENT];
	myfloat_t Total;
	myfloat_t Constoadd;
	myfloat_t ConstAngle[MAX_ORIENT];
	myfloat_t max_prob;
88
89
	int max_prob_cent_x, max_prob_cent_y, max_prob_orient, max_prob_conv;
};
90

91
#endif