image::Image* NonLocalMeansFilter::Run( image::Image* pImageIn )
{
   int borderSize = (int)(1.5 * (double)(mSearchWindowSize));
   mSourceWidth = pImageIn->GetWidth();
   mSourceHeight = pImageIn->GetHeight();
   Image* pImageInExtended = ImageTools::MirrorBorder( pImageIn, borderSize, borderSize );
   Image* pImageTmpExtended = pImageInExtended->Clone();
   Image* pImageOutExtended = pImageInExtended->Clone();

   mExtendedWidth = pImageInExtended->GetWidth();
   mExtendedHeight = pImageInExtended->GetHeight();
   mNrBands = pImageInExtended->GetNumberOfBands();

   for (int iter = 0; iter < mNrIterations; iter++)
   {
      for (int i = 0; i < mNrBands; i++)
      {
         mpGridIn  = pImageTmpExtended->GetBands()[ i ];
         mpGridOut = pImageOutExtended->GetBands()[ i ];

         LoopOverImage( );
      }
      pImageTmpExtended->CopyImageValues( pImageOutExtended );
   }
   Image* pImageOut = ImageTools::CropBorder( pImageOutExtended, borderSize, borderSize );
   delete pImageInExtended;
   delete pImageOutExtended;
   delete pImageTmpExtended;
   std::string outName = pImageIn->GetImageName() + std::string("-NonLocalMeans");
   pImageOut->SetImageName(outName);
   return pImageOut;
}
Example #2
0
		bool Replication(Image& image, float scaleX, float scaleY)
		{
			
			int sWidth = image.width * scaleX;
			int sHeight = image.height * scaleY;
			Image& scaled = Image::Create(sWidth, sHeight, image.type);

			//iterate over empty scaled image and fill with coresponding pixel from original
			for (int x = 0; x < sWidth; x++) {
			for (int y = 0; y < sHeight; y++) {
				//find pixel original

				int xOrig = std::floor(x / scaleX);
				int yOrig = std::floor(y / scaleY);
				uchar* pxOrig = image.pixelPtr(xOrig, yOrig);
				//copy pixel components
				uchar* pxScaled = scaled.pixelPtr(x, y);
				for (int i = 0; i < image.type; i++) {
					*(pxScaled + i) = *(pxOrig + i);
				}
			}
			}
			image.Clone(scaled);
			delete &scaled;

			return false;
		}
Example #3
0
DamageIcon::DamageIcon()
{
    mType = ENTITY_DAMAGEICON;
    //mId = its(amount);

    Image* img = resman->LoadImg("assets/dmg_font.png");
    mFontImage = img->Clone(true);
    resman->Unload(img); //dereference it, since we no longer touch the original

    // Background image will be a random one from the pool
    LoadImage("assets/dmg_bg" + its(rnd(0, 4)) + ".png");

    // Determine letter sizes based on pink pixels found.
    // Create an array to store this info for quicker access later
    color c;
    for (int x = 0; x < mFontImage->Width(); ++x)
    {
        c = mFontImage->GetPixel(x, 0);
        if (c.r == 255 && c.g == 0 && c.b == 255) //pink!
            mBorders.push_back(x);
    }

    // Colorize our version to suit our needs
    //mFontImage->ColorizeGreyscale(fontRgb);
    //mImage->ColorizeGreyscale(bgRgb);

    // Add timer to destroy this entity after some constant time
    timers->Add("", DAMAGE_ICON_TTL, false,
                timer_DeleteDamageIcon, NULL, this);
    timers->Add("", DAMAGE_ICON_THINK, false,
                timer_DamageIconThink, NULL, this);

    mOrigin.y = mImage->Height();
    mOrigin.x = mImage->Width()/2;
}
boost::shared_ptr< Image > Undistortion::undistort( const Image& image )
{
	// shortcut if no distortion
	if ( !hasDistortion() )
		return image.Clone();
		
	// initialize the distortion map
	initMap( image.width, image.height, image.origin );
	
	// undistort
	boost::shared_ptr< Image > pUndistorted( new Image( image.width, image.height, image.nChannels, image.depth ) );
	pUndistorted->origin = image.origin;
	memcpy( pUndistorted->colorModel,  image.colorModel, 4 );
	memcpy( pUndistorted->channelSeq,  image.channelSeq, 4 );

	cvRemap( image, *pUndistorted, *m_pMapX, *m_pMapY );
	
	// send result
	return pUndistorted;
}