Exemple #1
0
const vector<cv::Vec3b>& Labeling::colors() const
{
	if (labelColors.empty())
		buildColors();

	return labelColors;
}
Exemple #2
0
void RMesh::mesh::load(QString filename, RMesh::mesh &m)
{
#ifdef use_boost
//    cube( QString::number(0), m );

    QString off = QString::fromStdString("off");
    QString obj = QString::fromStdString("obj");
    QString ext = filename.right(3);


    if ( ext.toLower().compare( obj ) == 0 )
    {
        cout << "loading obj : " << filename.toStdString() << endl;
        RMesh::Importer::from_obj(m, filename);
    }
    else if ( ext.toLower().compare( off ) == 0 )
    {
        cout << "loading off : " << filename.toStdString() << endl;
        RMesh::Importer::from_off(m, filename);
    }
    else cout << endl << ext.toStdString() << " is not a supported file format";

    buildPCA( m );
    buildColors( m );
    m.bbox.Set( m.vertices );
    m.axes.center = m.bbox.Center();

#endif
}
Exemple #3
0
cv::Mat3b Labeling::bgr() const
{
	if (labelColors.empty())
		buildColors();

	cv::Mat3b ret(labels.rows, labels.cols);
	for (int y = 0; y < labels.rows; ++y) {
		cv::Vec3b *rety = ret[y];
		const short *lbly = labels[y];
		for (int x = 0; x < labels.cols; ++x) {
			rety[x] = labelColors[lbly[x]];
		}
	}
	return ret;
}
Exemple #4
0
Mandelbrot::Mandelbrot(int width, int height)
    :m_width(width), m_height(height)
{
    buildColors();

    double xrange, yrange;
    double xincr, yincr;

    //xmin=-1.26, xmax=-1.24;
    //xmin=-1.24, xmax=-1.26;
    //xmin=0.001585, xmax=0.001612;
    xmin=-1.5, xmax=0.5;

    //ycent=0.822467633298876;
    ycent=0.0;

    double ratio = double(m_height)/double(m_width);

    xrange = xmax - xmin;
    yrange = xrange * ratio;

    xincr = xrange / double(m_width);
    yincr = yrange / double(m_height);

    plane.resize(m_height);

    for(std::vector<std::complex<double>> &i: plane)
    {
        i.resize(m_width);
    }

    double real = xmin, imag = yrange / 2 + ycent;

    for(unsigned int y = 0; y < m_height; ++y)
    {
        real = xmin;
        for(unsigned int x = 0; x < m_width; ++x)
        {
            plane[y][x] = std::complex<double>(real, imag);
            real += xincr;
        }
        imag -= yincr;
    }

    image.resize(m_width, m_height);

    generate();
}
Exemple #5
0
void Labeling::consolidate()
{
	int idx = 1, // consolidation starts at 1
		maxlabel = 0; // if all labels are empty
	std::vector<int> index(labelcount);
	for (int i = 1; i < labelcount; ++i) {
		if (cv::sum(labels == i)[0] == 0) {
			// label is empty
			index[i] = -1;
		} else {
			index[i] = idx++;
			maxlabel = index[i];
		}
	}
	for (int i = 1; i < labelcount; ++i) {
		if (index[i] != -1) {
			labels.setTo(index[i], (labels == i));
		}
	}
	labelcount = maxlabel + 1;
	buildColors();
}
Exemple #6
0
Mandelbrot::Mandelbrot()
    :m_width(2000), m_height(2000)
{
    buildColors();

    double range, xincr, yincr;
    xmin=-1.5;
    xmax=0.5;

    range = xmax - xmin;
    xincr = range / double(m_width);
    yincr = range / double(m_height);

    plane.resize(m_height);

    for(std::vector<std::complex<double>> &i: plane)
    {
        i.resize(m_width);
    }

    double real = xmin, imag = range / 2;

    for(unsigned int y = 0; y < m_height; ++y)
    {
        real = xmin;
        for(unsigned int x = 0; x < m_width; ++x)
        {
            plane[y][x] = std::complex<double>(real, imag);
            real += xincr;
        }
        imag -= yincr;
    }

    image.resize(m_width, m_height);

    generate();
}