Ejemplo n.º 1
0
void findCoords(vector<BitObj*> &extents, ofstream &coords) {
    int num_rows = 0;
    vector<vector<int> > weighted(extents.back()->weight + 1);
    for (int i = 0; i < extents.size(); ++i) {
        weighted[extents[i]->weight].push_back(i);
    }
    for (auto row : weighted) {
        if (row.size())
            ++num_rows;
    }
    int row_w = (int)extents.size() * SPACE;
    CoordXY xy_set(row_w, row_w / num_rows);
    int y_idx = 0;
    for (int i = 0; i < weighted.size(); ++i) {
        int num_conc = (int)weighted[i].size();
        for (int j = 0; j < num_conc; ++j) {
            extents[weighted[i][j]]->coord = xy_set(num_conc, y_idx, j);
        }
        if (num_conc)
            ++y_idx;
    }
    cout << "Writing coords to coords.txt...\n";
    coords << extents.size() << '\n';
    for (auto e : extents) {
        coords << e->coord.first << ' ' << e->coord.second << '\n';
    }
}
Ejemplo n.º 2
0
    double squared(const eastl::vector<int>& observated,
                   const eastl::vector<int>& simulated) noexcept
    {
        pre(observated, simulated);

        for (int i = 0; i != NC; ++i)
            for (int j = 0; j != NC; ++j)
                weighted(i, j) = std::abs(i - j) * std::abs(i - j);

        return post();
    }
Ejemplo n.º 3
0
void Main::onStatsLevelOutput(qreal _level)
{
	int level = (int) (weighted(_level) * 100);
	static int lastLevel = 0;
	if (AudioInfo::DO_DEBUG)
		log.debug("level (out): %1", level);
	level = level >= lastLevel ? level : (lastLevel + level) / 2;
	if (level != lastLevel) {
		ui->statsLevelOutput->setValue(level);
		lastLevel = level;
	}
}
Ejemplo n.º 4
0
double Bar::operator[](BarData data) const
{
    switch (data) {
    case Close:
        return d->m_close;
    case Open:
        return d->m_open;
    case High:
        return d->m_high;
    case Low:
        return d->m_low;
    case Median:
        return median();
    case Typical:
        return typical();
    case Weighted:
        return weighted();
    case Volume:
        return d->m_volume;
    case OpenInt:
        return d->m_openInt;
    }
}
Ejemplo n.º 5
0
void Rgb2Graphen::execute()
{
    const cv::Mat input = mIn;
    GrayImage dest(input.rows, input.cols);
    int mode = mMode;
    int target = mTarget;

    // load configuration if needed
    if (mSingleRGBString.hasChanged() || mSingleVarianceString.hasChanged() ||
            mDoubleRGBString.hasChanged() || mDoubleVarianceString.hasChanged())
    {
        loadRGBConfig();
    }

    // spliting input image into seperate channel specific matrixes
    std::vector<cv::Mat> channels(3);
    cv::split(input,channels);

    if(mode == BlueSubstractDefault)
    {
        cv::Mat diff;
        cv::absdiff(channels[1], channels[2], diff);
        // diff *= 0.5;
        channels[1]/=2;
        channels[2]/=2;
        cv::subtract(channels[0], channels[1], dest);
        cv::subtract(dest, channels[2], dest);
        cv::subtract(dest, diff, dest);
    }
    else if(mode == WeightedSummPaper)
    {
        cv::addWeighted(channels[2], 0.3, channels[1], 0.59, 0, dest);
        cv::addWeighted(dest, 1, channels[0], 0.11, 0, dest);
    }
    else if(mode == BlueSubstractTweeked) {
        //b-r+b-g
        cv::absdiff(channels[0],channels[2], dest);

        cv::Mat diff;
        cv::absdiff(channels[0],channels[1], diff);

        cv::add(diff, dest, dest);

        //dest.convertTo(dest, CV_64F);

        dest /= 4;

        channels[0] /= 2;
        cv::add(dest, channels[0], dest);
    }
    else if(mode == GaussSingle)
    {
        // factor to make differences visible
        const int factor = 128;
        const double v = mVariance.getValue();

        std::vector<cv::Mat> weighted(3);
        // use RGB values depending of set target
        switch(target)
        {
        case SingleLayerGraphen:
            weighted[0] = gauss(channels[2], mSingleVarianceVector.at(0)*v, mSingleRGBVector.at(0));
            weighted[1] = gauss(channels[1], mSingleVarianceVector.at(1)*v, mSingleRGBVector.at(1));
            weighted[2] = gauss(channels[0], mSingleVarianceVector.at(2)*v, mSingleRGBVector.at(2));
            break;
        case DoubleLayerGraphen:
            weighted[0] = gauss(channels[2], mDoubleVarianceVector.at(0)*v, mDoubleRGBVector.at(0));
            weighted[1] = gauss(channels[1], mDoubleVarianceVector.at(1)*v, mDoubleRGBVector.at(1));
            weighted[2] = gauss(channels[0], mDoubleVarianceVector.at(2)*v, mDoubleRGBVector.at(2));
            break;
        default:
            break;
        }

        // multiply the weight of every RGB-channel
        cv::Mat mul;
        cv::multiply(weighted[0], weighted[1], mul);
        cv::multiply(mul, weighted[2], mul);

        dest = mul * factor;
    }
    else if (mode == GaussCombined)
    {
        // factor to make differences visible
        const int singleFactor = 64;
        const int doubleFactor = 128;
        const double v = mVariance.getValue();

        std::vector<cv::Mat> singleWeighted(3);
        std::vector<cv::Mat> doubleWeighted(3);
        // use RGB values depending of set target
        singleWeighted[0] = gauss(channels[2], mSingleVarianceVector.at(0)*v, mSingleRGBVector.at(0));
        singleWeighted[1] = gauss(channels[1], mSingleVarianceVector.at(1)*v, mSingleRGBVector.at(1));
        singleWeighted[2] = gauss(channels[0], mSingleVarianceVector.at(2)*v, mSingleRGBVector.at(2));

        doubleWeighted[0] = gauss(channels[2], mDoubleVarianceVector.at(0)*v, mDoubleRGBVector.at(0));
        doubleWeighted[1] = gauss(channels[1], mDoubleVarianceVector.at(1)*v, mDoubleRGBVector.at(1));
        doubleWeighted[2] = gauss(channels[0], mDoubleVarianceVector.at(2)*v, mDoubleRGBVector.at(2));

        // multiply the weight of every RGB-channel
        // single layer component
        cv::Mat mul;
        cv::multiply(singleWeighted[0], singleWeighted[1], mul);
        cv::multiply(mul, singleWeighted[2], mul);

        dest = mul * singleFactor;

        // double layer component
        cv::multiply(doubleWeighted[0], doubleWeighted[1], mul);
        cv::multiply(mul, doubleWeighted[2], mul);

        mul *= doubleFactor;

        // add components
        cv::add(dest, mul, dest);
    }
    mOut.send(dest);
}