Exemplo n.º 1
0
int main(int argc, char * argv[])
{
	CvCapture *capture = cvCaptureFromCAM(0);
	IplImage  *frame = 0;
    int key = 0;
    
	printf("Enter the range for the hue to be preserved (low, high): ");
	scanf("%d %d",&low, &high);
	while(key != 27) 
	{
		/* get a frame */
        frame = cvQueryFrame( capture );
 
        /* always check */
        if( !frame ) break;
		hsi(frame);
		key = cvWaitKey(10);
       //printf("%d  %c\t",key, key);
    }
	return 0;
}
Exemplo n.º 2
0
rspfRefPtr<rspfImageData> rspfHsiToRgbSource::getTile(
   const rspfIrect& tileRect,
   rspf_uint32 resLevel)
{
   if(!theInputConnection)
   {
      return NULL;  // This filter requires an input.
   }
   
   rspfRefPtr<rspfImageData> inputTile =
      theInputConnection->getTile(tileRect, resLevel);   
   if(!isSourceEnabled())
   {
      return inputTile;
   }
   
   if(!theTile.valid())
   {
      allocate(); // First time through...
   }
   
   if( !inputTile.valid() ||
       inputTile->getDataObjectStatus() == RSPF_NULL ||
       inputTile->getDataObjectStatus() == RSPF_EMPTY )
   {
      theBlankTile->setImageRectangle(tileRect);
      return theBlankTile;
   }

   if((inputTile->getNumberOfBands()==3)&&
      (inputTile->getScalarType()==RSPF_NORMALIZED_FLOAT)&&
      (inputTile->getDataObjectStatus()!=RSPF_NULL))
   {
      // Set the origin, resize if needed of the output tile.
      theTile->setImageRectangle(tileRect);
      
      rspf_uint8* outputBands[3];
      float* inputBands[3];
      outputBands[0] = static_cast<rspf_uint8*>(theTile->getBuf(0));
      outputBands[1] = static_cast<rspf_uint8*>(theTile->getBuf(1));
      outputBands[2] = static_cast<rspf_uint8*>(theTile->getBuf(2));
      inputBands[0] = static_cast<float*>(inputTile->getBuf(0));
      inputBands[1] = static_cast<float*>(inputTile->getBuf(1));
      inputBands[2] = static_cast<float*>(inputTile->getBuf(2));
      
      long height = inputTile->getHeight();
      long width  = inputTile->getWidth();
      long offset = 0;
      for(long row = 0; row < height; ++row)
      {
         for(long col = 0; col < width; ++col)
         {
            rspfHsiVector hsi(inputBands[0][offset],
                               inputBands[1][offset],
                               inputBands[2][offset]);
            
            rspfRgbVector rgb(hsi);
            
            
            outputBands[0][offset] = rgb.getR();
            outputBands[1][offset] = rgb.getG();
            outputBands[2][offset] = rgb.getB();
            
            ++offset;
         }
      }
   }
   else
   {
      return inputTile;
   }

   theTile->validate();

   return theTile;
}