void Na2DViewer::paintCrosshair(QPainter& painter) { float scale = defaultScale * cameraModel.scale(); QBrush brush1(Qt::black); QBrush brush2(QColor(255, 255, 180)); QPen pen1(brush1, 2.0/scale); QPen pen2(brush2, 1.0/scale); // qDebug() << "paint crosshair"; // Q: Why all this complicated math instead of just [width()/2, height()/2]? // A: This helps debug/document placement of image focus qreal w2 = (pixmap.width() - 1.0) / 2.0; // origin at pixel center, not corner qreal h2 = (pixmap.height() - 1.0) / 2.0; // origin at pixel center, not corner qreal cx = w2 + flip_X * (cameraModel.focus().x() - w2) + 0.5; qreal cy = h2 + flip_Y * (cameraModel.focus().y() - h2) + 0.5; QPointF f(cx, cy); QPointF dx1(4.0 / scale, 0); QPointF dy1(0, 4.0 / scale); QPointF dx2(10.0 / scale, 0); // crosshair size is ten pixels QPointF dy2(0, 10.0 / scale); painter.setPen(pen1); painter.drawLine(f + dx1, f + dx2); painter.drawLine(f - dx1, f - dx2); painter.drawLine(f + dy1, f + dy2); painter.drawLine(f - dy1, f - dy2); painter.setPen(pen2); painter.drawLine(f + dx1, f + dx2); painter.drawLine(f - dx1, f - dx2); painter.drawLine(f + dy1, f + dy2); painter.drawLine(f - dy1, f - dy2); }
void InterpolateBicubic::set_table( const std::vector<Value>& ff ){ plumed_assert( getNumberOfSplinePoints()==ff.size() ); plumed_assert( ff[0].getNumberOfDerivatives()==2 ); dcross=0.0; unsigned iplus, iminus; for(unsigned i=1;i<np[0]-1;++i){ iplus=(i+1)*stride[0]; iminus=(i-1)*stride[0]; for(unsigned j=1;j<np[1]-1;++j){ dcross(i,j) = ( ff[iplus+j+1].get() + ff[iminus+j-1].get() - ff[iplus+j-1].get() - ff[iminus+j+1].get() ) / getCrossTermDenominator( i, j ); } } double d1, d2; Matrix<double> tc(4,4); std::vector<double> y(4), dy1(4), dy2(4), d2y12(4); unsigned pij=0; unsigned ipos; for (unsigned i=0;i<np[0]-1;++i){ ipos=i*stride[0]; d1 = getPointSpacing( 0, i ); for (unsigned j=0; j<np[1]-1;++j){ d2 = getPointSpacing( 1, j ); y[0] = ff[ipos+j].get(); y[1] = ff[ipos+stride[0]+j].get(); y[2] = ff[ipos+stride[0]+j+1].get(); y[3] = ff[ipos+j+1].get(); dy1[0] = ff[ipos+j].getDerivative(0); dy1[1] = ff[ipos+stride[0]+j].getDerivative(0); dy1[2] = ff[ipos+stride[0]+j+1].getDerivative(0); dy1[3] = ff[ipos+j+1].getDerivative(0); dy2[0] = ff[ipos+j].getDerivative(1); dy2[1] = ff[ipos+stride[0]+j].getDerivative(1); dy2[2] = ff[ipos+stride[0]+j+1].getDerivative(1); dy2[3] = ff[ipos+j+1].getDerivative(1); d2y12[0] = dcross( i, j ); d2y12[1] = dcross( i+1, j ); d2y12[2] = dcross( i+1, j+1 ); d2y12[3] = dcross( i, j+1 ); IBicCoeff( y, dy1, dy2, d2y12, d1, d2, tc); pij=( ipos+j )*16; for(unsigned k=0; k<4; ++k){ for(unsigned n=0; n<4; ++n){ clist[pij++]=tc(k,n); } } } } }
bool TextureBoostedSaturatedGradientDataTest(bool create, int width, int height, const Func1 & f) { bool result = true; Data data(f.description); TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]."); View src(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dx1(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dy1(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dx2(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dy2(width, height, View::Gray8, NULL, TEST_ALIGN(width)); const int saturation = 16, boost = 4; if(create) { FillRandom(src); TEST_SAVE(src); f.Call(src, saturation, boost, dx1, dy1); TEST_SAVE(dx1); TEST_SAVE(dy1); } else { TEST_LOAD(src); TEST_LOAD(dx1); TEST_LOAD(dy1); f.Call(src, saturation, boost, dx2, dy2); TEST_SAVE(dx2); TEST_SAVE(dy2); result = result && Compare(dx1, dx2, 0, true, 32, 0, "dx"); result = result && Compare(dy1, dy2, 0, true, 32, 0, "dy"); } return result; }
bool TextureBoostedSaturatedGradientAutoTest(int width, int height, int saturation, int boost, const Func1 & f1, const Func1 & f2) { bool result = true; TEST_LOG_SS(Info, "Test " << f1.description << " & " << f2.description << " [" << width << ", " << height << "] <" << saturation << ", " << boost << ">."); View src(width, height, View::Gray8, NULL, TEST_ALIGN(width)); FillRandom(src); View dx1(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dy1(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dx2(width, height, View::Gray8, NULL, TEST_ALIGN(width)); View dy2(width, height, View::Gray8, NULL, TEST_ALIGN(width)); TEST_EXECUTE_AT_LEAST_MIN_TIME(f1.Call(src, saturation, boost, dx1, dy1)); TEST_EXECUTE_AT_LEAST_MIN_TIME(f2.Call(src, saturation, boost, dx2, dy2)); result = result && Compare(dx1, dx2, 0, true, 32, 0, "dx"); result = result && Compare(dy1, dy2, 0, true, 32, 0, "dy"); return result; }