本文整理汇总了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><* Identity *>" );
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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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 );
}
}
}
}
示例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 );
}
示例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-- );
}
}
示例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;
}
示例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();
}
示例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;
}
}
示例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);
};
示例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 ) );
}
示例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!" );
}
示例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;
}