Ejemplo n.º 1
0
ColorRGB *ProceduralTexture::cobblestone(int stoneSize,
										 int stoneNoise,
										 ColorHSV color,
										 int colorRange,
										 float edgeIntensity,
										 int edgeSize,
										 float edgeOpacity,
										 float edgeSmooth,
										 int stoneLayers,
										 float smoothness,
										 float stoneBrightness,
										 bool createNormalMap){
	unsigned char *ct = generateCelluarTexture(stoneSize);
	gaussianBlur(ct, edgeSmooth);
	brightnessContrast(ct, 0, edgeIntensity);
	unsigned char *pn = generatePerlinNoise(stoneNoise);
	postEffect(pn, stoneLayers, smoothness);
	brightnessContrast(pn, stoneBrightness, 1);
	mix(pn, ct, edgeSize, edgeOpacity);
	delete[] ct;
	if (createNormalMap)
		generateNormalMap(pn);
	ColorRGB *cct = generateCelluarTexture(stoneSize, color, colorRange);
	mix(cct, pn);
	delete[] pn;

	return cct;
}
Ejemplo n.º 2
0
void Analysis::filterData(PivData *pivData, FilterOptions filterOptions)
{
    // Checking each filtering option and calling external filter functions (included from filters.h)
    if (filterOptions.snr()) snr(pivData,filterOptions);
    if (filterOptions.imageIntensity()) imageIntensity(pivData,filterOptions);
    if (filterOptions.globalRange()) globalRange(pivData,filterOptions);
    if (filterOptions.globalStd()) globalStd(pivData,filterOptions);
    if (filterOptions.local()) localDetect(pivData,filterOptions);
    if (filterOptions.interpolate()) meanInterpolate(pivData, filterOptions);
    if (filterOptions.smoothing()) gaussianBlur(pivData, filterOptions);
}
Ejemplo n.º 3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()));
    connect(ui->actionReset, SIGNAL(triggered()), this, SLOT(reset()));
    connect(ui->btn_Left, SIGNAL(clicked()), this, SLOT(turnLeft()));
    connect(ui->btn_Right, SIGNAL(clicked()), this, SLOT(turnRight()));
    connect(ui->actionRgb2gray, SIGNAL(triggered()), this, SLOT(rgb2gray()));
    connect(ui->actionRgb2bw, SIGNAL(triggered()), this, SLOT(rgb2bw()));
    connect(ui->actionNegative, SIGNAL(triggered()), this, SLOT(negative()));
    connect(ui->actionStretch, SIGNAL(triggered()), this, SLOT(stretch()));
    connect(ui->actionLog, SIGNAL(triggered()), this, SLOT(log()));
    connect(ui->actionHistogramEqualize, SIGNAL(triggered()), this, SLOT(histogramEqualize()));
    connect(ui->actionHistogramExactSpecifiedEqualize, SIGNAL(triggered()), this, SLOT(histogramExactSpecifiedEqualize()));
    connect(ui->actionSpatialFilter, SIGNAL(triggered()), this, SLOT(spatialFilter()));
    connect(ui->actionMedianFilter, SIGNAL(triggered()), this, SLOT(medianFilter()));
    connect(ui->actionFFT, SIGNAL(triggered()), this, SLOT(makeFFT()));
    connect(ui->actionOilPaint, SIGNAL(triggered()), this, SLOT(oilPaint()));
    connect(ui->actionRelief, SIGNAL(triggered()), this, SLOT(relief()));
    connect(ui->actionEdgeExtraction, SIGNAL(triggered()), this, SLOT(edgeExtraction()));
    connect(ui->actionGaussianBlur, SIGNAL(triggered()), this, SLOT(gaussianBlur()));
    connect(ui->actionOpenOperate, SIGNAL(triggered()), this, SLOT(openOp()));
    connect(ui->actionCloseOperate, SIGNAL(triggered()), this, SLOT(closeOp()));
    connect(ui->actionExpansion, SIGNAL(triggered()), this, SLOT(expansionOp()));
    connect(ui->actionCorrosion, SIGNAL(triggered()), this, SLOT(corrosionOp()));
    connect(ui->checkBox, SIGNAL(toggled(bool)), this, SLOT(saveCheck(bool)));
    connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save()));
    this->ui->graphicsView->setScene(Q_NULLPTR);
    this->pixmapItem = Q_NULLPTR;
    this->directory = new QDir();
    this->imageProcessor = Q_NULLPTR;
    this->ui->actionReset->setEnabled(false);
    this->ui->btn_Left->setEnabled(false);
    this->ui->btn_Right->setEnabled(false);
    this->ui->actionRgb2gray->setEnabled(false);
    this->ui->actionRgb2bw->setEnabled(false);
    this->ui->actionNegative->setEnabled(false);
    this->ui->actionStretch->setEnabled(false);
    this->ui->actionLog->setEnabled(false);
    this->ui->actionHistogramEqualize->setEnabled(false);
    this->ui->actionHistogramExactSpecifiedEqualize->setEnabled(false);
    this->ui->actionSpatialFilter->setEnabled(false);
    this->ui->actionMedianFilter->setEnabled(false);
    this->ui->actionFFT->setEnabled(false);
    this->ui->actionOilPaint->setEnabled(false);
    this->ui->actionRelief->setEnabled(false);
    this->ui->actionEdgeExtraction->setEnabled(false);
    this->ui->actionGaussianBlur->setEnabled(false);
    this->ui->actionSave->setEnabled(false);
}
Ejemplo n.º 4
0
void toweringinferno::heatvision::HeatvisionSystem::update(
    const toweringinferno::World& world
)
{
    for(auto civilianIt = m_civilians.begin(); civilianIt != m_civilians.end(); ++civilianIt)
    {
        assert(civilianIt->isAlive());

        const Cell& cell = world.getCell(civilianIt->pos);
        const float hpDelta
            = cell.fire > 0.0f ? utils::mapValue(cell.fire, 0.0f, 0.5f, 0.0f, -0.4f)
              : cell.water > 0.0f ? utils::mapValue(cell.water, 0.85f, 1.5f, 0.0f, -0.4f)
              : 0.0f;

        civilianIt->hp = utils::max(0.0f, civilianIt->hp + hpDelta);

        TileHeat heat[eTile_Count];

        const Point& origin = civilianIt->pos;

        for(int tileIndex = 0; tileIndex < eTile_Count; ++tileIndex)
        {
            const Tile currentTile = static_cast<Tile>(tileIndex);
            const Point tilePos = calculatePosition(origin, currentTile);

            const float danger = calculateBleedableDanger(tilePos, world);
            const float desire = calculateDesire(tilePos, origin);

            heat[tileIndex] = TileHeat(tilePos, danger, desire);
        }

        gaussianBlur(heat, 0.2f, civilianIt->heatMap);

        for(int tileIndex = 0; tileIndex < eTile_Count; ++tileIndex)
        {
            const Tile currentTile = static_cast<Tile>(tileIndex);
            const Point tilePos = calculatePosition(origin, currentTile);

            const float danger = calculateNonBleedableDanger(tilePos, currentTile, world, m_civilians.begin(), m_civilians.end());

            civilianIt->heatMap[tileIndex].danger = utils::max(danger, civilianIt->heatMap[tileIndex].danger);
        }

        std::sort(civilianIt->heatMap, civilianIt->heatMap + eTile_Count);

        civilianIt->nextPos = civilianIt->heatMap[0].pos;
    }
}
Ejemplo n.º 5
0
void wxSVGCanvasCairo::DrawCanvasPath(wxSVGCanvasPathCairo& canvasPath, wxSVGMatrix& matrix,
		const wxCSSStyleDeclaration& style, wxSVGSVGElement& svgElem) {
	// check Filter
	if (style.GetFilter().GetCSSPrimitiveType() == wxCSS_URI && style.GetFilter().GetStringValue().length() > 1) {
		wxString filterId = style.GetFilter().GetStringValue().substr(1);
		wxSVGElement* filterElem = (wxSVGElement*) svgElem.GetElementById(filterId);
		// feGaussianBlur
		if (filterElem && filterElem->GetDtd() == wxSVG_FILTER_ELEMENT && filterElem->GetFirstChild() != NULL
				&& ((wxSVGSVGElement*) filterElem->GetFirstChild())->GetDtd() == wxSVG_FEGAUSSIANBLUR_ELEMENT) {
			float stdX = ((wxSVGFEGaussianBlurElement*) filterElem->GetFirstChild())->GetStdDeviationX().GetAnimVal();
			float stdY = ((wxSVGFEGaussianBlurElement*) filterElem->GetFirstChild())->GetStdDeviationY().GetAnimVal();
			if (stdX <= 0 || stdY <= 0)
				return;
			int dx = int(floor(stdX * 3 * sqrt(2 * M_PI) / 4 + 0.5));
			int dy = int(floor(stdY * 3 * sqrt(2 * M_PI) / 4 + 0.5));
			
			wxSVGRect rect = canvasPath.GetResultBBox(style, matrix.Inverse());
			rect.SetX(rect.GetX() - 2*dx);
			rect.SetY(rect.GetY() - 2*dy);
			rect.SetWidth(rect.GetWidth() + 4*dx);
			rect.SetHeight(rect.GetHeight() + 4*dy);
			
			int width = (int) rect.GetWidth();
			int height = (int) rect.GetHeight();
			cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
			cairo_t* cr = cairo_create(surface);
			wxSVGMatrix matrix2 = wxSVGMatrix(1, 0, 0, 1, - rect.GetX(), - rect.GetY()).Multiply(matrix);
			DrawPath(cr, canvasPath, matrix2, style, svgElem);
			gaussianBlur(surface, dx, dy);
			
			// draw surface
			cairo_save(m_cr);
			SetMatrix(m_cr, wxSVGMatrix(1, 0, 0, 1, rect.GetX(), rect.GetY()));
			cairo_set_source_surface(m_cr, surface, 0, 0);
			cairo_rectangle(m_cr, 0, 0, width, height);
			cairo_paint(m_cr); // fill the rectangle using the pattern
			cairo_new_path(m_cr);
			cairo_restore(m_cr);
			
			cairo_destroy(cr);
			cairo_surface_destroy(surface);
			return;
		}
	}
	DrawPath(m_cr, canvasPath, matrix, style, svgElem);
}
Ejemplo n.º 6
0
void HessianDetector::detectOctaveKeypoints(const cv::Mat &firstLevel, float pixelDistance, cv::Mat &nextOctaveFirstLevel)
{
   octaveMap = cv::Mat::zeros(firstLevel.rows, firstLevel.cols, CV_8UC1);
   float sigmaStep = pow(2.0f, 1.0f / (float) par.numberOfScales);
   float curSigma = par.initialSigma;
   blur = firstLevel;   
   cur = hessianResponse(blur, curSigma*curSigma);
   int numLevels = 1;
   
   for (int i = 1; i < par.numberOfScales+2; i++)
   {
      // compute the increase necessary for the next level and compute the next level
      float sigma = curSigma * sqrt(sigmaStep * sigmaStep - 1.0f);
      // do the blurring
      cv::Mat nextBlur = gaussianBlur(blur, sigma);
      // the next level sigma
      sigma = curSigma*sigmaStep;
      // compute response for current level
      high = hessianResponse(nextBlur, sigma*sigma);
      numLevels ++;
      // if we have three consecutive responses
      if (numLevels == 3)
      {
         // find keypoints in this part of octave for curLevel
         findLevelKeypoints(curSigma, pixelDistance);
         numLevels--;
      }      
      if (i == par.numberOfScales)
         // downsample the right level for the next octave
         nextOctaveFirstLevel = halfImage(nextBlur);
      prevBlur = blur; blur = nextBlur;
      // shift to the next response 
      low = cur; cur = high;
      curSigma *= sigmaStep;
   }
}
Ejemplo n.º 7
0
SDL_Surface *textureSynthesis(SDL_Surface *inputTexture, int w, int h)
{
	debug("Making output texture\n");						//I_s
	SDL_Surface *outputTexture = createSurface(w, h);

	debug("Generating noise on output texture\n");
	noisify(outputTexture);

	debug("Making output texture Gaussian Pyramid\n");				//G_s
	gauss_pyramid *outPyramid = new gauss_pyramid(outputTexture, -1, false);

	debug("Making input texture Gaussian Pyramid\n");				//G_a
	gauss_pyramid *inPyramid = new gauss_pyramid(inputTexture, outPyramid->getLevels());
	hood_pyramid *inHoodPyramid = new hood_pyramid(inPyramid);

	debug("Beginning texture synthesis...\n");
	int l = 0;
	double totTime = 0;
#ifdef TEX_SYN_USE_MULTIRESOLUTION
	for(l = outPyramid->getLevels() - 1; l >= 0; l--)
	{
#endif
		SDL_Surface *curLevel = outPyramid->getLevel(l);
		int lvlW = curLevel->w, lvlH = curLevel->h;
		debug("\tBeginning work on %d x %d level %d of the output pyramid..\n", lvlW, lvlH, l);

		//do this in scanline order
		for(int y = 0; y < lvlH; y++)
		{
            //for timing the operation
            clock_t start = clock();
			for(int x = 0; x < lvlW; x++)
			{
				verboseDebug("\t\tCalculating color for level %d at (%d, %d)\n", l, x, y);

				//update the display
				dispSurface(curLevel);

				//calculate the color to put here
				Uint32 color = findBestMatch(inHoodPyramid, inPyramid, outPyramid, l, x, y);

				//put that color on the pyramid level
				putPixel(curLevel, x, y, color);
			}
			totTime += ((double)clock() - start) / CLOCKS_PER_SEC;
			if(y % 20 == 0)
            	debug("\t\tTwenty rows done. Average time per row: %f s*\n", totTime / (y + 1));
            	//about the seconds* there, that value is not quite seconds, but it should be close and
            	//consistant in time.
		}

#ifdef TEX_SYN_USE_MULTIRESOLUTION
		//reset the timer every level
		totTime = 0.0;

		//blur the curent level (if it isn't the last)
		if(l > 0)
			gaussianBlur(curLevel);
	}
#endif

	//reconstruct the pyramid
	SDL_Surface *toReturn = outPyramid->reconstructPyramid();

	//free output bitmap
	debug("Cleaning up\n");
	delete outPyramid;
	delete inHoodPyramid;
	delete inPyramid;

	//return it up.
	return toReturn;
}