-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathYK16GrayImage.h
196 lines (140 loc) · 5.56 KB
/
YK16GrayImage.h
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#pragma once
//v20130830 : his header buffer, itk compatible
class QPixmap;
class QLabel;
class QPainter;
//class QImage;
#define DEFAULT_WINLEVEL_MID 10000
#define DEFAULT_WINLEVEL_WIDTH 20000
#define DEFAULT_ELEKTA_HIS_HEADER_SIZE 100
#include "itkImage.h"
#include <QImage>
#include <vector>
#include <QVector>
struct BADPIXELMAP{
int BadPixX;
int BadPixY;
int ReplPixX;
int ReplPixY;
};
enum enProfileDirection{
DIRECTION_HOR = 0,
DIRECTION_VER,
};
enum enSplitOption{
PRI_LEFT_TOP = 0, //Primary Left Top
PRI_RIGHT_TOP, //Primary Left Top
PRI_LEFT,
PRI_RIGHT,
PRI_TOP,
PRI_BOTTOM,
};
typedef itk::Image<unsigned short, 2> UnsignedShortImageType;
typedef itk::Image<float, 2> FloatImageType2D;
using namespace std;
class YK16GrayImage
{
public:
YK16GrayImage(void);
YK16GrayImage(int width, int height);
~YK16GrayImage(void);
int m_iWidth;
int m_iHeight;
//added: 20140206
double m_fSpacingX; //[mm/px]
double m_fSpacingY;
unsigned short* m_pData; // 0 - 65535
QPixmap* m_pPixmap; //Actually, no need!
QImage m_QImage;
//QPainter* m_pPainter;
bool LoadRawImage(const char *filePath, int width, int height);
bool CopyFromBuffer(unsigned short* pImageBuf, int width, int height);
bool CloneImage(YK16GrayImage& other);
bool CreateImage(int width, int height, unsigned short usVal);
bool FillPixMap(int winMid, int winWidth);
bool FillPixMapMinMax(int winMin, int winMax); //0-65535 Áß window level
bool FillPixMapDual(int winMid1, int winMid2,int winWidth1, int winWidth2);
bool FillPixMapMinMaxDual(int winMin1, int winMin2, int winMax1, int winMax2); //0-65535 Áß window level
bool SaveDataAsRaw (const char *filePath);
//bool DrawToLabel(QLabel* lbDisplay);
bool IsEmpty();
bool ReleaseBuffer();
//bool CalcImageInfo (double& meanVal, double& STDV, double& minVal, double& maxVal);
bool CalcImageInfo ();
double CalcAveragePixelDiff(YK16GrayImage& other);
// bool DoPixelReplacement(std::vector<BADPIXELMAP>& vPixelMapping); //based on pixel mapping information, some bad pixels will be replaced with median pixel value near by
static void CopyYKImage2ItkImage(YK16GrayImage* pYKImage, UnsignedShortImageType::Pointer& spTarImage);
static void CopyItkImage2YKImage(UnsignedShortImageType::Pointer& spSrcImage, YK16GrayImage* pYKImage);
QString m_strFilePath;
double m_fPixelMean;
double m_fPixelSD;
double m_fPixelMin;
double m_fPixelMax;
static void Swap(YK16GrayImage* pImgA, YK16GrayImage* pImgB);
QRect m_rtROI;
bool setROI(int left, int top, int right, int bottom); //if there is error, go to default: entire image
bool CalcImageInfo_ROI();
double m_fPixelMean_ROI;
double m_fPixelSD_ROI;
double m_fPixelMin_ROI;
double m_fPixelMax_ROI;
bool m_bDrawROI;
void DrawROIOn(bool bROI_Draw); //only rectangle
//Elekta CBCT recon
char* m_pElektaHisHeader;
void CopyHisHeader(const char *hisFilePath);
//bool SaveDataAsHis (const char *filePath);
bool SaveDataAsHis( const char *filePath, bool bInverse );
bool m_bShowInvert;
void MultiplyConstant(double multiplyFactor);
void SetSpacing(double spacingX, double spacingY)
{
m_fSpacingX = spacingX;
m_fSpacingY = spacingY;
};
QPoint m_ptProfileProbe; //Mouse Clicked Position --> Data
bool m_bDrawProfileX;
bool m_bDrawProfileY;
QPoint m_ptFOVCenter; // data pos
int m_iFOVRadius;//data pos (pixel)
bool m_bDrawFOVCircle;
int m_iTableTopPos;//data pos
bool m_bDrawTableLine;
QPoint m_ptCrosshair; //data position
bool m_bDrawCrosshair;
////ZOOM and PAN function. Using these information below, prepare the m_QImage for displaying
//in qlabel in FillPixMap function
int m_iOffsetX; //for Pan function.. this is data based offset
int m_iOffsetY;
void SetOffset(int offsetX, int offsetY){m_iOffsetX = offsetX; m_iOffsetY = offsetY;}
double m_fZoom;
void SetZoom(double fZoom);
//SPLIT VIEW
QPoint m_ptSplitCenter; //Fixed image with Moving image. center is based on dataPt.//Fixed Image: Left Top + Right Bottom, Moving: Right Top + Left Bottom
int m_enSplitOption;
//This cetner is moved while Left Dragging //All split and crosshair are data point based!
void SetSplitOption(enSplitOption option) {m_enSplitOption = option;}
void SetSplitCenter(QPoint& ptSplitCenter); //From mouse event, data point
//void SetSplitCenter(int centerX, int centerY) {m_ptSplitCenter.setX(centerX); m_ptSplitCenter.setY(centerY);}//From mouse event, data point
bool ConstituteFromTwo(YK16GrayImage& YKImg1,YK16GrayImage& YKImg2); //YKImg1 and two should be in exactly same dimension and spacing
bool isPtInFirstImage(int dataX, int dataY);
void SetProfileProbePos(int dataX, int dataY);
unsigned short GetProfileProbePixelVal();
void GetProfileData(int dataX, int dataY, QVector<double>& vTarget, enProfileDirection direction);
void GetProfileData(QVector<double>& vTarget, enProfileDirection direction);
void EditImage_Flip();
void EditImage_Mirror();
double m_fResampleFactor;//if it is not the 1.0, the data is already resampled.
UnsignedShortImageType::Pointer CloneItkImage();
void ResampleImage(double fResampleFactor);
void UpdateFromItkImage(UnsignedShortImageType::Pointer& spRefItkImg);
void UpdateFromItkImageFloat(FloatImageType2D::Pointer& spRefItkImg);
void InvertImage();
//will be added later
/*void EditImage_CW90();
void EditImage_CCW90();
void EditImage_Rotation(double angle);*/
//should be implemented later
//Flip
//mirror
};