10 #include <QScriptEngine>
12 #include <QMetaProperty>
25 m_Width(saver, this,
"width", width,
"Image Width"),
26 m_Height(saver, this,
"height", height,
"Image Height"),
27 m_HStart(saver, this,
"hStart", 0.0,
"H Start Coord"),
28 m_HStep(saver, this,
"hStep", 1.0,
"H Step"),
29 m_VStart(saver, this,
"vStart", 0.0,
"V Start Coord"),
30 m_VStep(saver, this,
"vStep", 1.0,
"V Step"),
31 m_HLabel(saver, this,
"hLabel",
"X",
"H Label"),
32 m_HUnits(saver, this,
"hUnits",
"pix",
"H Units"),
33 m_VLabel(saver, this,
"vLabel",
"Y",
"V Label"),
34 m_VUnits(saver, this,
"vUnits",
"pix",
"V Units"),
35 m_DataType(saver, this,
"dataType",
UndefinedData,
"Data Type of Image"),
36 m_FileBase(saver, this,
"fileBase",
"",
"File Base of Image"),
37 m_Title(saver, this,
"title",
"",
"Title of Image"),
38 m_ReadoutMode(saver, this,
"readoutMode", 0,
"Image Readout Mode"),
39 m_ExposureTime(saver, this,
"exposureTime", 0,
"Image Exposure Time"),
40 m_SummedExposures(saver, this,
"summedExposures", 0,
"Summed Exposures in Image"),
41 m_ImageSequenceNumber(saver, this,
"imageSequenceNumber", -1,
"Image Sequence Number"),
42 m_ImageNumber(saver, this,
"imageNumber", 0,
"Image Number"),
43 m_PhaseNumber(saver, this,
"phaseNumber", -1,
"Image Phase Number"),
44 m_NPhases(saver, this,
"nPhases", -1,
"Number of Image Phases"),
45 m_DateTime(saver, this,
"dateTime", QDateTime::currentDateTime(),
"Image Creation Date and Time"),
46 m_TimeStamp(saver, this,
"timeStamp",
secondsSinceEpoch(),
"Image creation time (secs after UNIX epoch)"),
47 m_HBinning(saver, this,
"hBinning", 1,
"Image Horizontal Binning Factor"),
48 m_VBinning(saver, this,
"vBinning", 1,
"Image Vertical Binning Factor"),
49 m_CameraGain(saver, this,
"cameraGain", 0,
"Image Detector Gain"),
50 m_Triggered(saver, this,
"triggered", 0,
"Triggered Flag"),
51 m_UserComment1(saver, this,
"userComment1",
"",
"User Comment 1"),
52 m_UserComment2(saver, this,
"userComment2",
"",
"User Comment 2"),
53 m_UserComment3(saver, this,
"userComment3",
"",
"User Comment 3"),
54 m_UserComment4(saver, this,
"userComment4",
"",
"User Comment 4"),
55 m_Normalization(saver, this,
"normalization",
QcepDoubleList(),
"Normalization Values"),
56 m_ExtraInputs(saver, this,
"extraInputs",
QcepDoubleList(),
"Extra Input Values"),
57 m_Used(saver, this,
"used", true,
"Image Used?"),
65 printf(
"QcepImageDataBase::QcepImageDataBase(%p)\n",
this);
74 printf(
"QcepImageDataBase::~QcepImageDataBase(%p)\n",
this);
88 return tr(
"[%1 x %2] elements").arg(get_Width()).arg(get_Height());
96 s->printMessage(msg, ts);
98 printf(
"%s\n", qPrintable(msg));
104 #if QT_VERSION >= 0x040700
105 return QDateTime::currentMSecsSinceEpoch()/1000.0;
107 QDateTime dt = QDateTime::currentDateTime();
108 time_t dt_t = dt.toTime_t();
109 int msec = dt.time().msec();
111 return ((
double) dt_t) + msec/1000.0;
122 dest -> set_Type(get_Type());
123 dest -> set_Creator(get_Creator());
124 dest -> set_Version(get_Version());
125 dest -> set_QtVersion(get_QtVersion());
126 dest -> set_DataType(get_DataType());
127 dest -> set_FileBase(get_FileBase());
128 dest -> set_FileName(get_FileName());
129 dest -> set_Title(get_Title());
130 dest -> set_ReadoutMode(get_ReadoutMode());
131 dest -> set_ExposureTime(get_ExposureTime());
132 dest -> set_SummedExposures(get_SummedExposures());
133 dest -> set_ImageSequenceNumber(get_ImageSequenceNumber());
134 dest -> set_ImageNumber(get_ImageNumber());
135 dest -> set_PhaseNumber(get_PhaseNumber());
136 dest -> set_NPhases(get_NPhases());
137 dest -> set_DateTime(get_DateTime());
138 dest -> set_HBinning(get_HBinning());
139 dest -> set_VBinning(get_VBinning());
140 dest -> set_CameraGain(get_CameraGain());
141 dest -> set_Triggered(get_Triggered());
142 dest -> set_UserComment1(get_UserComment1());
143 dest -> set_UserComment2(get_UserComment2());
144 dest -> set_UserComment3(get_UserComment3());
145 dest -> set_UserComment4(get_UserComment4());
146 dest -> set_ObjectSaved(get_ObjectSaved());
147 dest -> set_Normalization(get_Normalization());
148 dest -> set_ExtraInputs(get_ExtraInputs());
149 dest -> set_Used(get_Used());
153 foreach(name, dynamicPropertyNames()) {
154 dest -> setProperty(name.data(), property(name.data()));
160 set_Type(src -> get_Type());
161 set_Creator(src -> get_Creator());
162 set_Version(src -> get_Version());
163 set_QtVersion(src->get_QtVersion());
164 set_DataType(src -> get_DataType());
165 set_FileBase(src -> get_FileBase());
166 set_FileName(src -> get_FileName());
167 set_Title(src -> get_Title());
168 set_ReadoutMode(src -> get_ReadoutMode());
169 set_ExposureTime(src -> get_ExposureTime());
170 set_SummedExposures(src -> get_SummedExposures());
171 set_ImageSequenceNumber(src -> get_ImageSequenceNumber());
172 set_ImageNumber(src -> get_ImageNumber());
173 set_PhaseNumber(src -> get_PhaseNumber());
174 set_NPhases(src -> get_NPhases());
175 set_DateTime(src -> get_DateTime());
176 set_HBinning(src -> get_HBinning());
177 set_VBinning(src -> get_VBinning());
178 set_CameraGain(src -> get_CameraGain());
179 set_Triggered(src -> get_Triggered());
180 set_UserComment1(src -> get_UserComment1());
181 set_UserComment2(src -> get_UserComment2());
182 set_UserComment3(src -> get_UserComment3());
183 set_UserComment4(src -> get_UserComment4());
184 set_ObjectSaved(src -> get_ObjectSaved());
185 set_Normalization(src -> get_Normalization());
186 set_ExtraInputs(src -> get_ExtraInputs());
187 set_Used(src -> get_Used());
191 foreach(name, src -> dynamicPropertyNames()) {
192 setProperty(name.data(), src -> property(name.data()));
204 set_Creator(
"Unknown");
205 set_Version(
"Unknown");
206 set_QtVersion(
"Unknown");
210 QSettings settings(get_FileName()+
".metadata", QSettings::IniFormat);
214 if (settings.contains(
"metadata/qxrdVersion")) {
216 set_Version(settings.value(
"metadata/qxrdVersion").toString());
240 QSettings settings(name+
".metadata", QSettings::IniFormat);
244 settings.beginWriteArray(
"normalization");
247 for (
int i=0; i<norm.length(); i++) {
248 settings.setArrayIndex(i);
249 settings.setValue(
"val",norm[i]);
260 set_Title(QFileInfo(path).
fileName());
265 switch (get_DataType()) {
271 return "16 Bit Raw Data";
274 return "32 Bit Raw Data";
283 return "Subtracted Data";
286 return "Pixel Gain Data";
289 return "Bad Pixel Data";
304 return "TIFF (*.tif, *.tiff)";
309 return "Tab delimited (*.txt.*.dat)";
314 return "Transposed Tab delimited (*.txt,*.dat)";
319 return "CSV (*.csv)";
324 return "Transposed CSV (*.csv)";
329 return get_HStart() + n*get_HStep();
334 return get_VStart() + n*get_VStep();
337 template <
typename T>
350 .arg(
typeid(T).
name())
358 set_Type(
"Image Data");
361 template <
typename T>
366 .arg(
typeid(T).
name())
371 template <
typename T>
375 QSharedPointer< QcepImageData<T> > res(
new QcepImageData<T>(saver, width, height, 0, parent));
377 res->setObjectName(name);
382 template <
typename T>
388 template <
typename T>
391 if (x >= 0 && x < get_Width() && y >= 0 && y < get_Height()) {
392 return m_Image.value((get_Height()-y-1)*get_Width()+x);
398 template <
typename T>
401 int ix = ((int) x), iy = ((int) y);
402 double dx = x-ix, dy = y-iy;
404 double f00 =
value((ix) , (iy));
405 double f10 =
value((ix+1) , (iy));
406 double f01 =
value((ix) , (iy+1));
407 double f11 =
value((ix+1) , (iy+1));
409 double f0 = f00*(1-dx)+f10*dx;
410 double f1 = f01*(1-dx)+f11*dx;
412 double f = f0*(1-dy)+f1*dy;
417 template <
typename T>
422 for (
int y=y0; y<y1; y++) {
423 for (
int x=x0; x<x1; x++) {
424 res << this->
value(x,y);
431 template <
typename T>
434 return this->
value(x,y);
443 template <
typename T>
449 template <
typename T>
452 if (x >= 0 && x < get_Width() && y >= 0 && y < get_Height()) {
453 m_Image[(get_Height()-y-1)*get_Width()+x] = v;
457 template <
typename T>
460 if (x >= 0 && x < get_Width() && y >= 0 && y < get_Height()) {
461 m_Image[(get_Height()-y-1)*get_Width()+x] = val;
465 template <
typename T>
468 if (x >= 0 && x < get_Width() && y >= 0 && y < get_Height()) {
469 m_Image[(get_Height()-y-1)*get_Width()+x] += val;
473 template <
typename T>
476 if (x >= 0 && x < get_Width() && y >= 0 && y < get_Height()) {
477 m_Image[(get_Height()-y-1)*get_Width()+x] -= val;
481 template <
typename T>
484 if (x >= 0 && x < get_Width() && y >= 0 && y < get_Height()) {
485 m_Image[(get_Height()-y-1)*get_Width()+x] *= val;
489 template <
typename T>
492 if (x >= 0 && x < get_Width() && y >= 0 && y < get_Height()) {
493 m_Image[(get_Height()-y-1)*get_Width()+x] /= val;
509 template <
typename T>
519 for (
int i = 0; i<total; i++) {
536 template <
typename T>
541 double cx = get_Width()/2, cy = get_Height()/2;
546 for (
int y=0; y<get_Height(); y++) {
547 double dy = (((double)y)-cy)/cy;
548 double dx = sqrt(1-dy*dy);
549 int x0 = (int) (cx-dx*cx);
550 int x1 = (int) (cx+dx*cx);
552 for (
int x=x0; x<x1; x++) {
570 template <
typename T>
573 for (
int y=y0; y<y1; y++) {
574 for (
int x=x0; x<x1; x++) {
575 printf(
"%g ", (
double)
value(x,y));
581 template <
typename T>
586 int oldwidth = get_Width();
587 int oldheight= get_Height();
589 for (
int y=0; y<oldheight; y++) {
590 for (
int x=0; x<oldwidth; x++) {
600 for (
int y=0; y<
height; y++) {
601 for (
int x=0; x<
width; x++) {
606 set_ByteSize(width*height*
sizeof(T));
611 template <
typename T>
617 template <
typename T>
623 template <
typename T>
629 template <
typename T>
636 bool res = loader -> loadFile(path,
this);
639 QString
fileBase = QFileInfo(path).fileName();
641 set_FileBase(fileBase);
644 set_ObjectSaved(
true);
653 template <
typename T>
654 template <
typename T2>
658 if (dark->get_ExposureTime() != this->get_ExposureTime()) {
659 printMessage(
"Exposure times of acquired data and dark image are different, skipping");
663 if (dark->get_Width() != this->get_Width() ||
664 dark->get_Height() != this->get_Height()) {
665 printMessage(
"Dimensions of acquired data and dark image are different, skipping");
669 if (dark->get_CameraGain() != this->get_CameraGain()) {
670 printMessage(
"Gains of acquired data and dark image are different, skipping");
683 int height = this->get_Height();
684 int width = this->get_Width();
685 int nres =
this -> get_SummedExposures();
686 int ndrk = dark -> get_SummedExposures();
687 int npixels = width*
height;
689 if (nres <= 0) nres = 1;
691 double ratio = ((double) nres)/((double) ndrk);
696 double *result = this->
data();
697 T2 *dk = dark->data();
701 for (
int i=0; i<npixels; i++) {
704 result[i] = result[i]-ratio*dk[i];
714 template <
typename T>
719 QString
name = info.dir().filePath(info.completeBaseName()+
".raw.tif");
724 template <
typename T>
725 template <
typename T2>
729 int ncols =
this -> get_Width();
730 int nrows =
this -> get_Height();
731 int npix = ncols*nrows;
733 dest ->
resize(ncols, nrows);
737 T *srcp =
this ->
data();
738 T2 *destp = dest ->
data();
740 for (
int i=0; i<npix; i++) {
746 template <
typename T>
747 template <
typename T2>
751 int ncols = img -> get_Width();
752 int nrows = img -> get_Height();
753 int npix = ncols*nrows;
755 this ->
resize(ncols, nrows);
759 T2 *srcp = img ->
data();
760 T *destp =
this ->
data();
762 for (
int i=0; i<npix; i++) {
768 template <
typename T>
769 template <
typename T2>
773 int ncols =
this -> get_Width();
774 int nrows =
this -> get_Height();
776 this->prop_SummedExposures()->incValue(image->get_SummedExposures());
778 if (ncols == image->get_Width() && nrows == image->get_Height()) {
779 int npix = ncols*nrows;
781 T *srcp =
this ->
data();
782 T2 *destp = image ->
data();
784 for (
int i=0; i<npix; i++) {
788 for (
int row=0; row<nrows; row++) {
789 for (
int col=0; col<ncols; col++) {
790 this ->
addValue(col, row, image->value(col, row));
800 for (
int i=0; i<norm.count(); i++) {
801 norm[i] += norm2.value(i);
804 for (
int i=0; i<extra.count(); i++) {
805 extra[i] += extra2.value(i);
808 this->set_Normalization(norm);
809 this->set_ExtraInputs(extra);
814 template <
typename T>
815 template <
typename T2>
819 int ncols =
this -> get_Width();
820 int nrows =
this -> get_Height();
822 this->prop_SummedExposures()->incValue(image->get_SummedExposures());
824 if (ncols == image->get_Width() && nrows == image->get_Height()) {
825 int npix = ncols*nrows;
827 T *srcp =
this ->
data();
828 T2 *destp = image ->
data();
830 for (
int i=0; i<npix; i++) {
834 for (
int row=0; row<nrows; row++) {
835 for (
int col=0; col<ncols; col++) {
836 this ->
addValue(col, row, image->value(col, row));
843 template <
typename T>
844 template <
typename T2>
848 int ncols =
this -> get_Width();
849 int nrows =
this -> get_Height();
851 this->prop_SummedExposures()->incValue(image->get_SummedExposures());
853 if (ncols == image->get_Width() && nrows == image->get_Height()) {
854 int npix = ncols*nrows;
856 T *srcp =
this ->
data();
857 T2 *destp = image ->
data();
859 for (
int i=0; i<npix; i++) {
863 for (
int row=0; row<nrows; row++) {
864 for (
int col=0; col<ncols; col++) {
872 template <
typename T>
873 template <
typename T2>
877 int ncols =
this -> get_Width();
878 int nrows =
this -> get_Height();
880 this->prop_SummedExposures()->incValue(image->get_SummedExposures());
882 if (ncols == image->get_Width() && nrows == image->get_Height()) {
883 int npix = ncols*nrows;
885 T *srcp =
this ->
data();
886 T2 *destp = image ->
data();
888 for (
int i=0; i<npix; i++) {
892 for (
int row=0; row<nrows; row++) {
893 for (
int col=0; col<ncols; col++) {
901 template <
typename T>
902 template <
typename T2>
906 int ncols =
this -> get_Width();
907 int nrows =
this -> get_Height();
909 this->prop_SummedExposures()->incValue(image->get_SummedExposures());
911 if (ncols == image->get_Width() && nrows == image->get_Height()) {
912 int npix = ncols*nrows;
914 T *srcp =
this ->
data();
915 T2 *destp = image ->
data();
917 for (
int i=0; i<npix; i++) {
921 for (
int row=0; row<nrows; row++) {
922 for (
int col=0; col<ncols; col++) {
923 this ->
divideValue(col, row, image->value(col, row));
930 template <
typename T>
936 int wd = this->get_Width();
937 int ht = this->get_Height();
939 for (
int y=my; y<ht-my; y++) {
940 for (
int x=mx; x<wd-mx; x++) {
941 sum += this->
value(x,y)*image->value(x+dx,y+dy);
949 template <
typename T>
953 int wd = this->get_Width();
954 int ht = this->get_Height();
956 for (
int y=0; y<ht; y++) {
957 for (
int x=0; x<wd; x++) {
958 this->
setValue(x,y, image->value(x+dx,y+dy));
964 template <
typename T>
971 template <
typename T>
977 template <
typename T>
983 template <
typename T>
989 template <
typename T>
995 template <
typename T>
998 int ncols =
this -> get_Width();
999 int nrows =
this -> get_Height();
1003 for (
int row=0; row<nrows; row++) {
1004 for (
int col=0; col<ncols; col++) {
1006 T val = this->
value(col, row);
1012 }
else if (val < minv){
1023 template <
typename T>
1026 int ncols =
this -> get_Width();
1027 int nrows =
this -> get_Height();
1031 for (
int row=0; row<nrows; row++) {
1032 for (
int col=0; col<ncols; col++) {
1034 T val =
this ->
value(col, row);
1040 }
else if (val > maxv){
1051 template <
typename T>
1054 int ncols =
this -> get_Width();
1055 int nrows =
this -> get_Height();
1059 for (
int row=0; row<nrows; row++) {
1060 for (
int col=0; col<ncols; col++) {
1062 double val =
this ->
value(col, row);
1079 template <
typename T>
1082 const int histSize = 65536;
1083 QVector<int> histogramVec(histSize+1);
1084 histogramVec.fill(0.0);
1085 int *histogram = histogramVec.data();
1087 int ncols =
this -> get_Width();
1088 int nrows =
this -> get_Height();
1093 double histStep = (maxVal - minVal + 2)/histSize;
1094 int nAbove = 0, nBelow = 0, nTotal = 0;
1096 for (
int row=0; row<nrows; row++) {
1097 for (
int col=0; col<ncols; col++) {
1099 double val =
value(col, row);
1102 double bin = (val - minVal)/histStep;
1106 }
else if (bin >= histSize) {
1109 histogram[(int) bin] += 1;
1118 double lowCount = ((double) nTotal) * lowpct / 100.0;
1119 double highCount = ((double) nTotal) * highpct / 100.0;
1120 double count = nBelow;
1124 for (
int i=0; i<histSize; i++) {
1125 double binVal = minVal + i*histStep;
1127 count += histogram[i];
1129 if (count < lowCount) {
1133 if (count < highCount) {
1138 if (res.y() <= res.x()) {
1139 res.setY(res.x() + 1);
1145 template <
typename T>
1148 int ncols =
this -> get_Width();
1149 int nrows =
this -> get_Height();
1151 double badRatio = ((double) this->get_SummedExposures())/((
double) dark->get_SummedExposures());
1152 double goodRatio = ((double) nImgExposures)/((double) nDarkExposures);
1154 for (
int row=0; row<nrows; row++) {
1155 for (
int col=0; col<ncols; col++) {
1156 double darkValue = dark->value(col,row);
1157 double imgValue = this->
value(col,row);
1159 imgValue += darkValue*badRatio;
1160 imgValue -= darkValue*goodRatio;
1162 this->
setValue(col, row, imgValue);
1166 this->set_SummedExposures(nImgExposures);
1169 template <
typename T>
1172 return engine->newQObject(
data.data());
1175 template <
typename T>
1178 QObject *qobj = obj.toQObject();
1187 QSharedPointer<QcepImageData<T> > cs = qSharedPointerDynamicCast< QcepImageData<T> >(p);
1197 #define TIFFCHECK(a) if (res && ((a)==0)) { res = 0; }
1202 int nrows = get_Height();
1203 int ncols = get_Width();
1205 TIFF* tif = TIFFOpen(qPrintable(name),
"w");
1209 TIFFCHECK(TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, ncols));
1210 TIFFCHECK(TIFFSetField(tif, TIFFTAG_IMAGELENGTH, nrows));
1211 TIFFCHECK(TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1));
1213 TIFFCHECK(TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG));
1214 TIFFCHECK(TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 32));
1215 TIFFCHECK(TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP));
1217 TIFFCHECK(TIFFSetField(tif, TIFFTAG_DOCUMENTNAME, qPrintable(get_FileName())));
1218 TIFFCHECK(TIFFSetField(tif, TIFFTAG_DATETIME, qPrintable(get_DateTime().toString(
"yyyy:MM:dd hh:mm:ss"))));
1220 QVector<float> buffvec(ncols);
1221 float* buffer = buffvec.data();
1223 for (
int y=0; y<nrows; y++) {
1224 for (
int x=0; x<ncols; x++) {
1225 buffer[x] =
value(x,y);
1228 TIFFCHECK(TIFFWriteScanline(tif, buffer, y, 0));
1234 set_ObjectSaved(
true);
1240 template <
typename T>
1243 int nrows = get_Height();
1244 int ncols = get_Width();
1246 TIFF* tif = TIFFOpen(qPrintable(name),
"w");
1250 int nsum = get_SummedExposures();
1252 TIFFCHECK(TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, ncols));
1253 TIFFCHECK(TIFFSetField(tif, TIFFTAG_IMAGELENGTH, nrows));
1254 TIFFCHECK(TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1));
1256 TIFFCHECK(TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG));
1259 TIFFCHECK(TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8));
1260 }
else if (nsum == 1) {
1261 TIFFCHECK(TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16));
1263 TIFFCHECK(TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 32));
1266 TIFFCHECK(TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT));
1268 TIFFCHECK(TIFFSetField(tif, TIFFTAG_DOCUMENTNAME, qPrintable(get_FileName())));
1269 TIFFCHECK(TIFFSetField(tif, TIFFTAG_DATETIME, qPrintable(get_DateTime().toString(
"yyyy:MM:dd hh:mm:ss"))));
1272 QVector<quint8> buffvec(ncols);
1273 quint8* buffer = buffvec.data();
1275 for (
int y=0; y<nrows; y++) {
1276 for (
int x=0; x<ncols; x++) {
1277 buffer[x] =
value(x,y);
1280 TIFFCHECK(TIFFWriteScanline(tif, buffer, y, 0));
1282 }
else if (nsum == 1) {
1283 QVector<quint16> buffvec(ncols);
1284 quint16* buffer = buffvec.data();
1286 for (
int y=0; y<nrows; y++) {
1287 for (
int x=0; x<ncols; x++) {
1288 buffer[x] =
value(x,y);
1291 TIFFCHECK(TIFFWriteScanline(tif, buffer, y, 0));
1294 QVector<quint32> buffvec(ncols);
1295 quint32* buffer = buffvec.data();
1297 for (
int y=0; y<nrows; y++) {
1298 for (
int x=0; x<ncols; x++) {
1299 buffer[x] =
value(x,y);
1302 TIFFCHECK(TIFFWriteScanline(tif, buffer, y, 0));
1309 set_ObjectSaved(
true);
1317 FILE *f = fopen(qPrintable(name),
"w+");
1320 const QMetaObject *meta = metaObject();
1322 int count = meta->propertyCount();
1323 int offset = QObject::staticMetaObject.propertyOffset();
1325 for (
int i=offset; i<count; i++) {
1326 QMetaProperty metaproperty = meta->property(i);
1327 const char *name = metaproperty.name();
1328 QVariant
value = property(name);
1330 fprintf(f,
"#%s = %s\n", name, qPrintable(value.toString()));
1333 foreach (QByteArray name, dynamicPropertyNames()) {
1334 QVariant
value = property(name);
1336 fprintf(f,
"#%s = %s\n", name.data(), qPrintable(value.toString()));
1339 int nrows = get_Height();
1340 int ncols = get_Width();
1342 if (transp ==
false) {
1343 for (
int y=0; y<nrows; y++) {
1344 for (
int x=0; x<ncols; x++) {
1348 fprintf(f,
"%s%g", qPrintable(sep),
getImageData(x,y));
1354 for (
int y=0; y<ncols; y++) {
1355 for (
int x=0; x<nrows; x++) {
1359 fprintf(f,
"%s%g", qPrintable(sep),
getImageData(y,x));
1370 template <
typename T>
1392 template <
typename T>
1395 int l = qRound(rect.left());
1396 int t = qRound(rect.top());
1397 int r = qRound(rect.right());
1398 int b = qRound(rect.bottom());
1401 l = qRound(rect.right());
1402 r = qRound(rect.left());
1406 b = qRound(rect.top());
1407 t = qRound(rect.bottom());
1413 for (
int row=b; row<=t; row++) {
1414 for (
int col=l; col<=r; col++) {
1416 T val =
value(col, row);
1429 template <
typename T>
1432 int l = qRound(rect.left());
1433 int t = qRound(rect.top());
1434 int r = qRound(rect.right());
1435 int b = qRound(rect.bottom());
1438 l = qRound(rect.right());
1439 r = qRound(rect.left());
1443 b = qRound(rect.top());
1444 t = qRound(rect.bottom());
1450 for (
int row=b; row<=t; row++) {
1451 for (
int col=l; col<=r; col++) {
1453 T val =
value(col, row);
1466 template <
typename T>
1469 int l = qRound(rect.left());
1470 int t = qRound(rect.top());
1471 int r = qRound(rect.right());
1472 int b = qRound(rect.bottom());
1475 l = qRound(rect.right());
1476 r = qRound(rect.left());
1480 b = qRound(rect.top());
1481 t = qRound(rect.bottom());
1487 for (
int row=b; row<=t; row++) {
1488 for (
int col=l; col<=r; col++) {
1490 T val =
value(col, row);
1496 }
else if (val < min) {
1507 template <
typename T>
1510 int l = qRound(rect.left());
1511 int t = qRound(rect.top());
1512 int r = qRound(rect.right());
1513 int b = qRound(rect.bottom());
1516 l = qRound(rect.right());
1517 r = qRound(rect.left());
1521 b = qRound(rect.top());
1522 t = qRound(rect.bottom());
1528 for (
int row=b; row<=t; row++) {
1529 for (
int col=l; col<=r; col++) {
1531 T val =
value(col, row);
1537 }
else if (val > max) {
1548 template <
typename T>
1551 QPointF c = rect.center();
1552 double a = rect.width()/2;
1553 double b = rect.height()/2;
1555 int bt = qRound(rect.bottom());
1556 int tp = qRound(rect.top());
1561 for (
int row=tp; row<=bt; row++) {
1562 double y=row - c.y();
1563 double xx = a*sqrt(1 - pow(y/b,2));
1564 int x1 = qRound(c.x() - xx);
1565 int x2 = qRound(c.x() + xx);
1567 for (
int col=x1; col<=x2; col++) {
1569 T val =
value(col, row);
1582 template <
typename T>
1585 QPointF c = rect.center();
1586 double a = rect.width()/2;
1587 double b = rect.height()/2;
1589 int bt = qRound(rect.bottom());
1590 int tp = qRound(rect.top());
1595 for (
int row=tp; row<=bt; row++) {
1596 double y=row - c.y();
1597 double xx = a*sqrt(1 - pow(y/b,2));
1598 int x1 = qRound(c.x() - xx);
1599 int x2 = qRound(c.x() + xx);
1601 for (
int col=x1; col<=x2; col++) {
1603 T val =
value(col, row);
1616 template <
typename T>
1619 QPointF c = rect.center();
1620 double a = rect.width()/2;
1621 double b = rect.height()/2;
1623 int bt = qRound(rect.bottom());
1624 int tp = qRound(rect.top());
1629 for (
int row=tp; row<=bt; row++) {
1630 double y=row - c.y();
1631 double xx = a*sqrt(1 - pow(y/b,2));
1632 int x1 = qRound(c.x() - xx);
1633 int x2 = qRound(c.x() + xx);
1635 for (
int col=x1; col<=x2; col++) {
1637 T val =
value(col, row);
1643 }
else if (val < min) {
1654 template <
typename T>
1657 QPointF c = rect.center();
1658 double a = rect.width()/2;
1659 double b = rect.height()/2;
1661 int bt = qRound(rect.bottom());
1662 int tp = qRound(rect.top());
1667 for (
int row=tp; row<=bt; row++) {
1668 double y=row - c.y();
1669 double xx = a*sqrt(1 - pow(y/b,2));
1670 int x1 = qRound(c.x() - xx);
1671 int x2 = qRound(c.x() + xx);
1673 for (
int col=x1; col<=x2; col++) {
1675 T val =
value(col, row);
1681 }
else if (val > max) {
1692 template <
typename T>
1695 QPointF c = rect.center();
1696 double w = rect.width()/2;
1697 double h = rect.height()/2;
1699 int bt = qRound(rect.bottom());
1700 int tp = qRound(rect.top());
1701 int lf = qRound(rect.left());
1702 int rt = qRound(rect.right());
1704 int ptp = qRound(c.y() - h/2);
1705 int pbt = qRound(c.y() + h/2);
1706 int plf = qRound(c.x() - w/2);
1707 int prt = qRound(c.x() + w/2);
1714 for (
int row=tp; row<=bt; row++) {
1715 for (
int col=lf; col<=rt; col++) {
1717 T val =
value(col,row);
1720 if (ptp <= row && row <= pbt && plf <= col && col <= prt) {
1732 if (np > 0 && npk > 0) {
1733 double avbk = sum/np;
1734 double avpk = sumpk/npk;
1736 return (avpk-avbk)*npk;
void saveTextData(QString name, QString sep, bool transp=false)
double correlate(QSharedPointer< QcepImageData< T > > image, int dx, int dy, int mx, int my)
void shiftImage(QSharedPointer< QcepImageData< T > > image, double dx, double dy)
double sumInPeak(QRectF rect)
static void deallocate(int sz, int width, int height)
QcepMaskDataPtr overflow() const
QcepMaskDataPtr m_Overflow
void subtractValue(int x, int y, T val)
QcepSettingsSaverWPtr m_Saver
void setMask(QcepMaskDataPtr mask, QcepMaskDataPtr overflow)
double maxInRectangle(QRectF rect)
void multiplyValue(int x, int y, T val)
static void readSettings(QObject *object, QSettings *settings, QString section)
qint64 qcepDebug(int cond)
void addValue(int x, int y, T val)
double maxInEllipse(QRectF rect)
double minInRectangle(QRectF rect)
static QSharedPointer< QcepImageData< T > > newImage(QcepSettingsSaverWPtr saver, QString name, int width, int height, QcepObject *parent)
QString uniqueFileName(QString name)
void mkPath(QString filePath)
void resize(int width, int height)
QcepImageData(QcepSettingsSaverWPtr saver, int width, int height, T def, QcepObject *parent)
QString fileFormatTransposedCSV()
void copyImage(QSharedPointer< QcepImageData< T2 > > dest)
double findAverage() const
double vValue(int n) const
T value(int x, int y) const
QcepImageDataBase(QcepSettingsSaverWPtr saver, int width, int height, int size, QcepObject *parent)
static void fromScriptValue(const QScriptValue &obj, QSharedPointer< QcepImageData< T > > &data)
void subtractDark(const QSharedPointer< QcepImageData< T2 > > dark)
void copyProperties(QcepImageDataBase *dest)
void copyPropertiesFrom(QSharedPointer< QcepImageDataBase > src)
void divideValue(int x, int y, T val)
double minInEllipse(QRectF rect)
void calculateRangeInCircle()
static QScriptValue toScriptValue(QScriptEngine *engine, const QSharedPointer< QcepImageData< T > > &data)
void accumulateImage(QSharedPointer< QcepImageData< T2 > > image)
double sumInRectangle(QRectF rect)
static void writeSettings(QObject *object, QSettings *settings, QString section)
void setImageData(int x, int y, double v)
virtual double getImageData(int x, int y) const =0
QPointF percentileRange(double lowpct, double highpct)
void add(QSharedPointer< QcepImageData< T2 > > image)
double sumInEllipse(QRectF rect)
bool readImage(QString filename)
void divide(QSharedPointer< QcepImageData< T2 > > image)
QList< double > QcepDoubleList
virtual QString fileFormatFilterString()
double hValue(int n) const
void saveTIFFData(QString name)
QSharedPointer< QcepSettingsSaver > QcepSettingsSaverPtr
void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime()) const
void setValue(int x, int y, T val)
QString get_DataTypeName() const
void multiply(QSharedPointer< QcepImageData< T2 > > image)
QString fileFormatTabDelimited()
void dumpPixels(int x0, int y0, int x1, int y1)
static void allocate(int sz, int width, int height)
QSharedPointer< QcepDataObject > QcepDataObjectPtr
virtual QString description() const
void subtract(QSharedPointer< QcepImageData< T2 > > image)
virtual void saveData(QString &name, QString filter, Overwrite canOverwrite=NoOverwrite)
double getImageData(int x, int y) const
QString fileFormatTransposedTabDelimited()
virtual ~QcepImageDataBase()
void setDefaultValue(T def)
void correctBadBackgroundSubtraction(QcepDoubleImageDataPtr dark, int nImgExposures, int nDarkExposures)
void setDefaultFileName(QString path)
QSharedPointer< QcepMaskData > QcepMaskDataPtr
double averageInRectangle(QRectF rect)
void copyFrom(const QSharedPointer< QcepImageData< T2 > > img)
static double secondsSinceEpoch()
QWeakPointer< QcepSettingsSaver > QcepSettingsSaverWPtr
double averageInEllipse(QRectF rect)
QcepSettingsSaverWPtr saver()
QSharedPointer< QcepDoubleImageData > QcepDoubleImageDataPtr
QcepMaskDataPtr mask() const