当前位置: 首页>>代码示例>>C++>>正文


C++ GenericImage类代码示例

本文整理汇总了C++中GenericImage的典型用法代码示例。如果您正苦于以下问题:C++ GenericImage类的具体用法?C++ GenericImage怎么用?C++ GenericImage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GenericImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Apply

   static void Apply( GenericImage<P>& image, const ColorSaturationInstance& instance, bool useLUT = false )
   {
      if ( instance.Curve().IsIdentity() )
      {
         Console().WriteLn( "<end><cbr>&lt;* Identity *&gt;" );
         return;
      }

      size_type N = image.NumberOfPixels();

      int numberOfThreads = Thread::NumberOfThreads( N, 16 );
      size_type pixelsPerThread = N/numberOfThreads;

      image.Status().Initialize( "Color saturation transformation, HSVL space", N );

      ThreadData data( image, N );
      if ( useLUT )
         data.lut = MakeLUT( instance );

      ReferenceArray<ColorSaturationThread<P> > threads;
      for ( int i = 0, j = 1; i < numberOfThreads; ++i, ++j )
         threads.Add( new ColorSaturationThread<P>( instance, data, image,
                                                    i*pixelsPerThread,
                                                    (j < numberOfThreads) ? j*pixelsPerThread : N ) );
      AbstractImage::RunThreads( threads, data );

      threads.Destroy();

      image.Status() = data.status;
   }
开发者ID:AndresPozo,项目名称:PCL,代码行数:30,代码来源:ColorSaturationInstance.cpp

示例2: SuperPixelThreaded

   static void SuperPixelThreaded( Image& target, const GenericImage<P>& source, const DebayerInstance& instance )
   {
      int target_w = source.Width() >> 1;
      int target_h = source.Height() >> 1;

      target.AllocateData( target_w, target_h, 3, ColorSpace::RGB );

      target.Status().Initialize( "SuperPixel debayering", target_h );

      int numberOfThreads = Thread::NumberOfThreads( target_h, 1 );
      int rowsPerThread = target_h/numberOfThreads;

      AbstractImage::ThreadData data( target, target_h );

      ReferenceArray<SuperPixelThread<P> > threads;
      for ( int i = 0, j = 1; i < numberOfThreads; ++i, ++j )
         threads.Add( new SuperPixelThread<P>( data, target, source, instance,
                                               i*rowsPerThread,
                                               (j < numberOfThreads) ? j*rowsPerThread : target_h ) );

      AbstractImage::RunThreads( threads, data );
      threads.Destroy();

      target.Status() = data.status;
   }
开发者ID:aleixpuig,项目名称:PCL,代码行数:25,代码来源:DebayerInstance.cpp

示例3: VNGThreaded

   static void VNGThreaded( Image& target, const GenericImage<P>& source, const DebayerInstance& instance )
   {
      int target_w = source.Width();
      int target_h = source.Height();

      target.AllocateData( target_w, target_h, 3, ColorSpace::RGB );

      target.Status().Initialize( "VNG debayering", target_h-4 );

      int numberOfThreads = Thread::NumberOfThreads( target_h-4, 1 );
      int rowsPerThread = (target_h - 4)/numberOfThreads;

      AbstractImage::ThreadData data( target, target_h-4 );

      ReferenceArray<VNGThread<P> > threads;
      for ( int i = 0, j = 1; i < numberOfThreads; ++i, ++j )
         threads.Add( new VNGThread<P>( data, target, source, instance,
                                        i*rowsPerThread + 2,
                                        (j < numberOfThreads) ? j*rowsPerThread + 2 : target_h-2 ) );

      AbstractImage::RunThreads( threads, data );
      threads.Destroy();

      // copy top and bottom two rows from the adjecent ones
      for ( int col = 0; col < target_w; col++ )
         for ( int i = 0; i < 3; i++ )
         {
            target.Pixel( col, 0, i ) = target.Pixel( col, 1, i ) = target.Pixel( col, 2, i );
            target.Pixel( col, target_h-1, i ) = target.Pixel( col, target_h-2, i ) = target.Pixel( col, target_h-3, i );
         }

      target.Status() = data.status;
   }
开发者ID:aleixpuig,项目名称:PCL,代码行数:33,代码来源:DebayerInstance.cpp

示例4: gen_normalMap

void GenericImage::gen_normalMap(const char* filename)
{
    GenericImage dst;
    dst.width = width;
    dst.height = height;
    dst.components = 3;
    dst.pixels = (unsigned char*)malloc(width * height * 3);
	
    char* nmap = gen_normal();

    //cast from char to unsigned char to save as an normalmap image
    //and be able to look at the normalmap and make sense

    int index=0;
    unsigned char* p = (unsigned char*)dst.pixels;

    for(int y = 0; y < height; y++)
    {
        for(int x = 0; x < width; x++)
        {
            p[3*index + 0] = (unsigned char)(nmap[3*index + 0] + 127);
            p[3*index + 1] = (unsigned char)(nmap[3*index + 1] + 127);
            p[3*index + 2] = (unsigned char)(nmap[3*index + 2] + 127);
			
            //fprintf(stderr, "normal map[%d](%d, %d, %d)\n", index, nmap[3*index + 0], nmap[3*index + 1], nmap[3*index + 2]);
            index++;
        }
    }

    bool ret = dst.save(filename);
    if(ret) printf("success! normalmap saved to image %s\n", filename);
    else printf("error! normalmap save to image %s failed\n", filename);
}
开发者ID:jinghuage,项目名称:pcaster,代码行数:33,代码来源:imgfile.cpp

示例5: ReadJP2KImage

static void ReadJP2KImage( GenericImage<P>& img, jas_stream_t* jp2Stream, jas_image_t* jp2Image )
{
   int width = jas_image_cmptwidth( jp2Image, 0 );
   int height = jas_image_cmptheight( jp2Image, 0 );
   int numberOfChannels = jas_image_numcmpts( jp2Image );

   jas_matrix_t* pixels = nullptr;

   try
   {
      pixels = jas_matrix_create( 1, width );
      if ( pixels == nullptr )
         throw Error( "Memory allocation error reading JPEG2000 image" );

      // Allocate pixel data
      img.AllocateData( width, height, numberOfChannels,
                        (jas_clrspc_fam( jas_image_clrspc( jp2Image ) ) == JAS_CLRSPC_FAM_GRAY) ?
                              ColorSpace::Gray : ColorSpace::RGB );

      for ( int c = 0; c < numberOfChannels; ++c )
      {
         int n = jas_image_cmptprec( jp2Image, c );
         bool s = jas_image_cmptsgnd( jp2Image, c ) != 0;

         for ( int y = 0; y < height; ++y )
         {
            jas_image_readcmpt( jp2Image, c, 0, y, width, 1, pixels );

            typename P::sample* f = img.ScanLine( y, c );

            if ( n == 8 )
            {
               if ( s )
                  for ( int x = 0; x < width; ++x )
                     *f++ = P::ToSample( int8( jas_matrix_get( pixels, 0, x ) ) );
               else
                  for ( int x = 0; x < width; ++x )
                     *f++ = P::ToSample( uint8( jas_matrix_get( pixels, 0, x ) ) );
            }
            else
            {
               if ( s )
                  for ( int x = 0; x < width; ++x )
                     *f++ = P::ToSample( int16( jas_matrix_get( pixels, 0, x ) ) );
               else
                  for ( int x = 0; x < width; ++x )
                     *f++ = P::ToSample( uint16( jas_matrix_get( pixels, 0, x ) ) );
            }
         }
      }

      jas_matrix_destroy( pixels ), pixels = nullptr;
   }
   catch ( ... )
   {
      if ( pixels != nullptr )
         jas_matrix_destroy( pixels );
      throw;
   }
}
开发者ID:kkretzschmar,项目名称:PCL,代码行数:60,代码来源:JPEG2000Instance.cpp

示例6: CombineChannels

static void CombineChannels( GenericImage<P>& img, int colorSpace, const String& baseId,
                             const Rect& r,
                             const GenericImage<P0>* src0, const GenericImage<P1>* src1, const GenericImage<P2>* src2 )
{
   bool allChannels = src0 != 0 && src1 != 0 && src2 != 0;

   typename P::sample* R = img.PixelData( 0 );
   typename P::sample* G = img.PixelData( 1 );
   typename P::sample* B = img.PixelData( 2 );

   const RGBColorSystem& rgbws = img.RGBWorkingSpace();

   for ( int y = r.y0; y < r.y1; ++y )
   {
      const typename P0::sample* data0 = (src0 != 0) ? src0->PixelAddress( r.x0, y ) : 0;
      const typename P1::sample* data1 = (src1 != 0) ? src1->PixelAddress( r.x0, y ) : 0;
      const typename P2::sample* data2 = (src2 != 0) ? src2->PixelAddress( r.x0, y ) : 0;

      for ( int x = r.x0; x < r.x1; ++x, ++img.Status() )
      {
         if ( colorSpace == ColorSpaceId::RGB )
         {
            if ( data0 != 0 )
               P0::FromSample( *R++, *data0++ );
            if ( data1 != 0 )
               P1::FromSample( *G++, *data1++ );
            if ( data2 != 0 )
               P2::FromSample( *B++, *data2++ );
         }
         else
         {
            RGBColorSystem::sample ch0, ch1, ch2;
            RGBColorSystem::sample r, g, b;

            if ( !allChannels )
            {
               P::FromSample( r, *R );
               P::FromSample( g, *G );
               P::FromSample( b, *B );

               FromRGB( colorSpace, rgbws, ch0, ch1, ch2, r, g, b );
            }

            if ( data0 != 0 )
               P0::FromSample( ch0, *data0++ );
            if ( data1 != 0 )
               P1::FromSample( ch1, *data1++ );
            if ( data2 != 0 )
               P2::FromSample( ch2, *data2++ );

            ToRGB( colorSpace, rgbws, r, g, b, ch0, ch1, ch2 );

            *R++ = P::ToSample( r );
            *G++ = P::ToSample( g );
            *B++ = P::ToSample( b );
         }
      }
   }
}
开发者ID:Astroshed,项目名称:PCL,代码行数:59,代码来源:ChannelCombinationInstance.cpp

示例7: WriteJPEGImage

static void WriteJPEGImage( const GenericImage<P>& image, JPEGWriter* writer )
{
   if ( writer == 0 || !writer->IsOpen() )
      throw Error( "JPEG format: Attempt to write an image before creating a file" );

   StandardStatus status;
   image.SetStatusCallback( &status );
   image.SelectNominalChannels(); // JPEG doesn't support alpha channels
   writer->WriteImage( image );
}
开发者ID:SunGong1993,项目名称:PCL,代码行数:10,代码来源:JPEGInstance.cpp

示例8: Rotate180

   template <class P> static
   void Rotate180( GenericImage<P>& image )
   {
      size_type N = image.NumberOfPixels();
      int n = image.NumberOfChannels();

      if ( image.Status().IsInitializationEnabled() )
         image.Status().Initialize( "Rotate 180 degrees", n*N );

      for ( int c = 0; c < n; ++c, image.Status() += N )
         for ( int y0 = 0, y1 = image.Height()-1; y0 <= y1; ++y0, --y1 )
         {
            typename P::sample* f0 = image.ScanLine( y0, c );
            typename P::sample* f1 = image.ScanLine( y1, c );

            if ( y0 != y1 )
            {
               int x0 = 0, x1 = image.Width()-1;

               while ( x0 < x1 )
               {
                  pcl::Swap( f0[x0], f1[x1] );
                  pcl::Swap( f0[x1], f1[x0] );
                  ++x0;
                  --x1;
               }

               if ( x0 == x1 )
                  pcl::Swap( f0[x0], f1[x0] );
            }
            else
               for ( typename P::sample* f = f0, * g = f0+image.Width()-1; f < g; )
                  pcl::Swap( *f++, *g-- );
         }
   }
开发者ID:morserover,项目名称:PCL,代码行数:35,代码来源:FastRotation.cpp

示例9: to_small_gs

			GenericImage<rgb3> to_small_gs( GenericImage<rgb3> const &input_image ) {
				GenericImage<rgb3> image_output{input_image.width( ),
				                                input_image.height( )};

				std::transform( input_image.cbegin( ), input_image.cend( ),
				                image_output.begin( ), []( rgb3 const &rgb ) {
					                return static_cast<uint8_t>( rgb.too_float_gs( ) );
				                } );

				return image_output;
			}
开发者ID:beached,项目名称:lib_grayscale_filter,代码行数:11,代码来源:filterdawgs.cpp

示例10: ApplyInverseRealFourierTransform_1

static void ApplyInverseRealFourierTransform_1( GenericImage<P>& image, const DComplexImage& dft, bool parallel, int maxProcessors )
{
   DImage tmp;
   tmp.Status() = image.Status();
   image.FreeData();

   ApplyInverseRealFourierTransform_2( tmp, dft, parallel, maxProcessors );

   image.SetStatusCallback( 0 );
   image.Assign( tmp );
   image.Status() = tmp.Status();
}
开发者ID:aleixpuig,项目名称:PCL,代码行数:12,代码来源:FourierTransform.cpp

示例11: ReadJPEGImage

static void ReadJPEGImage( GenericImage<P>& image, JPEGReader* reader, int& readCount )
{
   if ( reader == 0 || !reader->IsOpen() )
      throw Error( "JPEG format: Attempt to read an image before opening a file" );

   try
   {
      /*
       * The readCount thing is a trick to allow reading the same JPEG image
       * multiple times from the same format instance. Ugly but heck, it works.
       */
      if ( readCount )
      {
         String filePath = reader->Path();
         reader = new JPEGReader;
         reader->Open( filePath );
      }

      StandardStatus status;
      image.SetStatusCallback( &status );
      reader->ReadImage( image );

      if ( readCount )
         delete reader;
      ++readCount;
   }
   catch ( ... )
   {
      if ( readCount )
         delete reader;
      throw;
   }
}
开发者ID:SunGong1993,项目名称:PCL,代码行数:33,代码来源:JPEGInstance.cpp

示例12: Apply

 static void Apply( GenericImage<P>& image, const PhotometricSuperflatInstance& instance )
 {
     
     PolynomialSurface* S;
     
     if ( !File::Exists( instance.starDatabasePath ) )
         throw Error( "No such file: " + instance.starDatabasePath );
     S = new PolynomialSurface( instance.starDatabasePath, image.Width(), image.Height() );
     //S->PrintCatalog();
     S->PrintCatalogSummary();
     S->PlotXYKeyedToRelativeFlux(false);
     String eqn = S->ComputeBestFitModel(instance.fitDegree);
     S->PlotXYKeyedToRelativeFlux(true);
     S->ShowBestFitModelImage();
     delete(S);
 };
开发者ID:robertoabraham,项目名称:PhotometricSuperflat,代码行数:16,代码来源:PhotometricSuperflatInstance.cpp

示例13: Apply

 static void Apply( GenericImage<P>& image, const AnnotationInstance& instance )
 {
    int relPosX = 0, relPosY = 0;
    Bitmap annotationBmp = AnnotationRenderer::CreateAnnotationBitmap( instance, relPosX, relPosY, false );
    // blend bitmap to the image
    image.Blend( annotationBmp, Point( instance.annotationPositionX - relPosX,
                                       instance.annotationPositionY - relPosY ) );
 }
开发者ID:AndresPozo,项目名称:PCL,代码行数:8,代码来源:AnnotationInstance.cpp

示例14: ApplyFilter_2

template <class P1, class P2> static
void ApplyFilter_2( GenericImage<P1>& image, const GenericImage<P2>& sharp,
                    float amount, float threshold, float deringing,
                    float rangeLow, float rangeHigh, pcl_bool disableExtension, int c, pcl_bool highPass )
{
   float rangeWidth = 1 + rangeHigh + rangeLow;
   bool isRange = rangeWidth + 1 != 1;

   StandardStatus callback;
   StatusMonitor monitor;
   monitor.SetCallback( &callback );
   monitor.Initialize( "<end><cbr>Larson-Sekanina filter", image.NumberOfPixels() );

   for ( int x = 0; x < image.Width(); ++x )
      for ( int y = 0; y < image.Height(); ++y, ++monitor )
      {
         double f1, f2;
         P1::FromSample( f1, image.Pixel( x, y, c ) );
         P2::FromSample( f2, sharp.Pixel( x, y ) );
         Apply_PixelValues( f1, f2, threshold, deringing, amount, highPass );

         if ( disableExtension )
            image.Pixel( x, y, c ) = P1::ToSample( f1 );
         else
         {
            if ( isRange )
               f1 = (f1 + rangeLow)/rangeWidth;
            image.Pixel( x, y, c ) = P1::ToSample( pcl::Range( f1, 0.0, 1.0 ) );
         }
      }

   if ( disableExtension )
      Console().WarningLn( "<end><cbr>*** Warning: Dynamic range extension has been disabled - check pixel values!" );
}
开发者ID:Astroshed,项目名称:PCL,代码行数:34,代码来源:LarsonSekaninaInstance.cpp

示例15: Apply

   template <class P> static
   void Apply( GenericImage<P>& image, const HistogramTransformation& H )
   {
      if ( image.IsEmptySelection() )
         return;

      image.SetUnique();

      Rect r = image.SelectedRectangle();
      int h = r.Height();

      int numberOfThreads = H.IsParallelProcessingEnabled() ? Min( H.MaxProcessors(), pcl::Thread::NumberOfThreads( h, 1 ) ) : 1;
      int rowsPerThread = h/numberOfThreads;

      H.UpdateFlags();

      size_type N = image.NumberOfSelectedSamples();
      if ( image.Status().IsInitializationEnabled() )
         image.Status().Initialize( "Histogram transformation", N );

      ThreadData<P> data( image, H, N );

      PArray<Thread<P> > threads;
      for ( int i = 0, j = 1; i < numberOfThreads; ++i, ++j )
         threads.Add( new Thread<P>( data, i*rowsPerThread, (j < numberOfThreads) ? j*rowsPerThread : h ) );

      AbstractImage::RunThreads( threads, data );
      threads.Destroy();

      image.Status() = data.status;
   }
开发者ID:morserover,项目名称:PCL,代码行数:31,代码来源:HistogramTransformation.cpp


注:本文中的GenericImage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。