14 m_RoiType(saver, this,
"roiType", roiType,
"ROI Type"),
16 m_Coords(saver, this,
"coords", QRectF(left, top, right-left, bottom-top),
"ROI Coords"),
17 m_Width2(saver, this,
"width2", 0,
"Width of inner region"),
18 m_Height2(saver, this,
"height2", 0,
"Height of inner region"),
36 return engine->newQObject(coords.data());
41 QObject *qobj = obj.toQObject();
56 }
else if (roiType ==
Ellipse) {
59 return "Rectangle inside Rectangle";
61 return "Ellipse inside Rectangle";
63 return "Rectangle inside Ellipse";
65 return "Ellipse inside Ellipse";
90 return get_Coords().left();
95 return get_Coords().top();
100 return get_Coords().right();
105 return get_Coords().bottom();
110 return get_Coords().width();
115 return get_Coords().height();
120 return get_Coords().center();
125 return get_Coords().size();
135 return get_Height2();
140 return QSizeF(get_Width2(), get_Height2());
165 QRectF c = get_Coords();
176 QRectF c = get_Coords();
187 QRectF c = get_Coords();
198 QRectF c = get_Coords();
209 QRectF crd = get_Coords();
225 QRectF c = get_Coords();
226 QPointF cen = c.center();
243 QRectF c = get_Coords();
244 QPointF cen = c.center();
256 QRectF c = get_Coords();
257 QPointF cen = c.center();
269 QRectF c = get_Coords();
270 QPointF cen = c.center();
282 QRectF c = get_Coords();
283 QPointF cen = c.center();
295 set_Width2(s.width());
296 set_Height2(s.height());
322 QVector<QPointF> res;
323 QRectF c = get_Coords();
325 switch (get_RoiType()) {
329 res.append(c.topLeft());
330 res.append(c.bottomLeft());
331 res.append(c.bottomRight());
332 res.append(c.topRight());
333 res.append(c.topLeft());
339 double a=c.width()/2.0;
340 double b=c.height()/2.0;
341 QPointF cen = c.center();
343 for (
int i=0; i<=16; i++) {
344 double theta = M_PI*i/8.0;
345 double x = cen.x() + a*cos(theta);
346 double y = cen.y() + b*sin(theta);
348 res.append(QPointF(x,y));
356 pkr.setSize(
size2());
357 pkr.moveCenter(c.center());
359 res.append(c.topLeft());
360 res.append(c.bottomLeft());
361 res.append(c.bottomRight());
362 res.append(c.topRight());
363 res.append(c.topLeft());
365 res.append(QPointF(qQNaN(), qQNaN()));
367 res.append(pkr.topLeft());
368 res.append(pkr.bottomLeft());
369 res.append(pkr.bottomRight());
370 res.append(pkr.topRight());
371 res.append(pkr.topLeft());
378 pkr.setSize(
size2());
379 pkr.moveCenter(c.center());
381 double a=c.width()/2.0;
382 double b=c.height()/2.0;
383 QPointF cen = c.center();
385 for (
int i=0; i<=16; i++) {
386 double theta = M_PI*i/8.0;
387 double x = cen.x() + a*cos(theta);
388 double y = cen.y() + b*sin(theta);
390 res.append(QPointF(x,y));
393 res.append(QPointF(qQNaN(), qQNaN()));
395 res.append(pkr.topLeft());
396 res.append(pkr.bottomLeft());
397 res.append(pkr.bottomRight());
398 res.append(pkr.topRight());
399 res.append(pkr.topLeft());
405 res.append(c.topLeft());
406 res.append(c.bottomLeft());
407 res.append(c.bottomRight());
408 res.append(c.topRight());
409 res.append(c.topLeft());
411 res.append(QPointF(qQNaN(), qQNaN()));
417 for (
int i=0; i<=16; i++) {
418 double theta = M_PI*i/8.0;
419 double x = cen.x() + a2*cos(theta);
420 double y = cen.y() + b2*sin(theta);
422 res.append(QPointF(x,y));
429 double a=c.width()/2.0;
430 double b=c.height()/2.0;
431 QPointF cen = c.center();
433 for (
int i=0; i<=16; i++) {
434 double theta = M_PI*i/8.0;
435 double x = cen.x() + a*cos(theta);
436 double y = cen.y() + b*sin(theta);
438 res.append(QPointF(x,y));
441 res.append(QPointF(qQNaN(), qQNaN()));
446 for (
int i=0; i<=16; i++) {
447 double theta = M_PI*i/8.0;
448 double x = cen.x() + a2*cos(theta);
449 double y = cen.y() + b2*sin(theta);
451 res.append(QPointF(x,y));
480 switch (get_RoiType()) {
528 int tp = qRound(
top());
529 int bt = qRound(
bottom());
530 int lf = qRound(
left());
531 int rt = qRound(
right());
533 int tp2 = qRound(
top2());
535 int lf2 = qRound(
left2());
536 int rt2 = qRound(
right2());
540 double a =
width()/2.0;
545 for (
int row=tp; row<=bt; row++) {
546 double dy = row - cy;
549 double xx = a*sqrt(1 - pow(dy/b,2));
550 lf = qRound(cx - xx);
551 rt = qRound(cx + xx);
554 for (
int col=lf; col<=rt; col++) {
555 double dx = col - cx;
558 double xx2 = a2*sqrt(1 - pow(dy/b2,2));
560 lf2 = qRound(cx - xx2);
561 rt2 = qRound(cx + xx2);
573 if (mask == NULL || mask->value(col, row)) {
574 double val = img->getImageData(col, row);
594 }
else if (val > max) {
596 }
else if (val < min) {
605 img->setImageData(col, row, 1000 - val);
628 QMatrix4x4 inv = m.inverted(&invertible);
631 bkgd = inv(0,0)*sumvn + inv(0,1)*sumvx + inv(0,2)*sumvy;
632 gradx = inv(1,0)*sumvn + inv(1,1)*sumvx + inv(1,2)*sumvy;
633 grady = inv(2,0)*sumvn + inv(2,1)*sumvx + inv(2,2)*sumvy;
637 }
else if (sumct > 0) {
647 for (
int row=tp2; row<=bt2; row++) {
648 double dy = row - cy;
651 double xx2 = a2*sqrt(1 - pow(dy/b2,2));
653 lf2 = qRound(cx - xx2);
654 rt2 = qRound(cx + xx2);
661 for (
int col=lf2; col<=rt2; col++) {
662 if (mask == NULL || mask->value(col, row)) {
663 double val = img->getImageData(col, row);
666 double dx = col - cx;
667 double bk = bkgd + dx*gradx + dy*grady;
674 }
else if (v > max) {
676 }
else if (v < min) {
684 img->setImageData(col, row, 1000 - val);
700 set_Average(sum/npx);
705 set_Background(bkgd);
706 set_XGradient(gradx);
707 set_YGradient(grady);
714 res.append(get_Sum());
715 res.append(get_Average());
716 res.append(get_Minimum());
717 res.append(get_Maximum());
718 res.append(get_NPixels());
719 res.append(get_Background());
720 res.append(get_XGradient());
721 res.append(get_YGradient());
static QString outputName(int opt)
QSharedPointer< QxrdROICoordinates > QxrdROICoordinatesPtr
void recalculate(QcepImageDataBasePtr img, QcepMaskDataPtr mask)
QWeakPointer< QxrdExperiment > QxrdExperimentWPtr
void setCenterX(double cx)
void setCenterY(double cy)
void visualizeBackground(QcepImageDataBasePtr img, QcepMaskDataPtr mask)
QVector< QPointF > markerCoords()
virtual ~QxrdROICoordinates()
void setCenter(QPointF c)
void recalculatePrivate(QcepImageDataBasePtr img, QcepMaskDataPtr mask, int vis)
QVector< double > values() const
void visualizePeak(QcepImageDataBasePtr img, QcepMaskDataPtr mask)
static int roiTypeCount()
void selectNamedROIType(QString nm)
QxrdROICoordinates(QcepSettingsSaverWPtr saver, QxrdExperimentWPtr exp, int roiType, double left=0, double top=0, double right=0, double bottom=0)
QSharedPointer< QcepImageDataBase > QcepImageDataBasePtr
QSharedPointer< QcepMaskData > QcepMaskDataPtr
void setHeight2(double h)
static QScriptValue toScriptValue(QScriptEngine *engine, const QxrdROICoordinatesPtr &coords)
QWeakPointer< QcepSettingsSaver > QcepSettingsSaverWPtr
static void fromScriptValue(const QScriptValue &obj, QxrdROICoordinatesPtr &coords)