Exemplo n.º 1
0
  static typename std::enable_if<
      std::is_same<Border, ValidConvolution>::value, void>::type
  Convolution(const arma::Mat<eT>& input,
              const arma::Mat<eT>& filter,
              arma::Mat<eT>& output,
              const size_t dW = 1,
              const size_t dH = 1)
  {
    output = arma::zeros<arma::Mat<eT> >((input.n_rows - filter.n_rows + 1) /
        dW, (input.n_cols - filter.n_cols + 1) / dH);

    // It seems to be about 3.5 times faster to use pointers instead of
    // filter(ki, kj) * input(leftInput + ki, topInput + kj) and output(i, j).
    eT* outputPtr = output.memptr();

    for (size_t j = 0; j < output.n_cols; ++j)
    {
      for (size_t i = 0; i < output.n_rows; ++i, outputPtr++)
      {
        const eT* kernelPtr = filter.memptr();
        for (size_t kj = 0; kj < filter.n_cols; ++kj)
        {
          const eT* inputPtr = input.colptr(kj + j * dW) + i * dH;
          for (size_t ki = 0; ki < filter.n_rows; ++ki, ++kernelPtr, ++inputPtr)
            *outputPtr += *kernelPtr * (*inputPtr);
        }
      }
    }
  }
inline Raw_Matrix to_raw(arma::Mat<float> & mat) {
  Raw_Matrix matrix;
  matrix.n_rows = mat.n_rows;
  matrix.n_cols= mat.n_cols;
  matrix.data = mat.memptr();
  return matrix;
}
void Arma_mat_to_cv_mat(const arma::Mat<T>& arma_mat_in, cv::Mat_<T>& cv_mat_out)
{
    cv::transpose(cv::Mat_<T>(static_cast<int>(arma_mat_in.n_cols),
                              static_cast<int>(arma_mat_in.n_rows),
                              const_cast<T*>(arma_mat_in.memptr())),
                  cv_mat_out);
};
Exemplo n.º 4
0
void MainWindow::loadSeries() {
    QString seriesFile = __fileManager.openFile(0, this, "Open Series File...", "*.mat");

    if (seriesFile != "") {
        cout << "Loading start ..." << flush;
        _data.load(seriesFile.toStdString().c_str());
        cout << " done. " << endl;

        _dataT = arma::trans(_data);
        cout << _data.n_cols << "," << _data.n_rows << endl;

        _imageBuffer.set_size(_mapid.n_rows, _mapid.n_cols);
        for (int i = 0; i < _mapid.n_rows; i++) {
            for (int j = 0; j < _mapid.n_cols; j++) {
                if (_mapid(i,j) != _mapid(i,j)) {
                    _imageBuffer(i,j) = NAN;
                } else {
                    _imageBuffer(i,j) = 0;
                }
            }
        }

        ui.slider->setMaximum(_data.n_cols - 1);

        ui.minValue->setValue(_data.min());
        ui.maxValue->setValue(_data.max());

        _mapItem->setImage(_imageBuffer.memptr(), _imageBuffer.n_rows, _imageBuffer.n_cols);
        _mapItem->setRange(ui.minValue->value(), ui.maxValue->value());
        _mapItem->setInteraction(this);

        selectValue(0);
    }
}
Exemplo n.º 5
0
MainWindow::MainWindow(QWidget* parent) {
    ui.setupUi(this);
    ui.graphicsView->setScene(&_scene);

    _mapid.load("./MapID.mat");
    cout << _mapid.n_cols << "," << _mapid.n_rows << endl;


    connect(ui.slider, SIGNAL(valueChanged(int)), SLOT(selectValue(int)));
    connect(ui.clearGraphButton, SIGNAL(pressed()), SLOT(clearGraphs()));
    connect(ui.loadSeries, SIGNAL(pressed()), SLOT(loadSeries()));

    _mapItem = new QFloatImageItem();
    _mapItem->setImage(_imageBuffer.memptr(), _imageBuffer.n_rows, _imageBuffer.n_cols);
    _mapItem->setRange(ui.minValue->value(), ui.maxValue->value());
    _mapItem->setInteraction(this);

    _scene.addItem(_mapItem);
    _traceItem = _scene.addPath(_tracePath);


    _traceItem->setPen(QPen(Qt::black));

    QTransform matrix;
    matrix.scale(5, 5);
    ui.graphicsView->setTransform(matrix);

    ui.customPlot->setInteraction(QCustomPlot::iSelectLegend, true);
    ui.customPlot->setInteraction(QCustomPlot::iSelectPlottables, true);
    connect(ui.customPlot, SIGNAL(selectionChangedByUser()), SLOT(graphSelected()));

    _plotMarker = new QGraphicsEllipseItem(_mapItem);
    _plotMarker->setVisible(false);
}
void
save(OutputArchive& ar, const arma::Mat<T>& mat, const unsigned int version) {
    size_t size = mat.size();

    ar & mat.n_cols;
    ar & mat.n_rows;

    ar & make_array(mat.memptr(), size);
}
Exemplo n.º 7
0
	sha1sum(arma::Mat<T> matrix)
	{
		size_t ptr_lenght=sizeof(T)*matrix.n_cols*matrix.n_rows;
		SHA1((unsigned char*)matrix.memptr(), ptr_lenght, sha1_result);
	}
Exemplo n.º 8
0
cv::Mat
arma2cv(const arma::Mat<T>& from, bool copy = true) {
    cv::Mat mat(from.n_cols, from.n_rows, cv::DataType<T>::type, const_cast<T*>(from.memptr()));
    mat = mat.t();
    return copy ? mat.clone() : mat;
}