本文整理汇总了C++中GenericImage::Height方法的典型用法代码示例。如果您正苦于以下问题:C++ GenericImage::Height方法的具体用法?C++ GenericImage::Height怎么用?C++ GenericImage::Height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericImage
的用法示例。
在下文中一共展示了GenericImage::Height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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!" );
}
示例3: while
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-- );
}
}
示例4: 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;
}
示例5: Apply
static void Apply( GenericImage<P>& image, const LocalHistogramEqualizationInstance& instance )
{
if ( image.IsColor() )
{
Image L;
image.GetLightness( L );
L.Status() = image.Status();
Apply( L, instance );
image.Status() = L.Status();
image.SetLightness( L );
return;
}
// create copy of the luminance to evaluate histogram from
GenericImage<P> imageCopy( image );
imageCopy.EnsureUnique(); // really not necessary, but we'll be safer if this is done
size_type N = image.NumberOfPixels();
int numberOfThreads = Thread::NumberOfThreads( image.Height(), 1 );
int rowsPerThread = image.Height()/numberOfThreads;
image.Status().Initialize( "CLAHE", N );
AbstractImage::ThreadData data( image, N );
// create processing threads
ReferenceArray<LocalHistogramEqualizationThread<P> > threads;
for ( int i = 0, j = 1; i < numberOfThreads; ++i, ++j )
threads.Add( new LocalHistogramEqualizationThread<P>( data,
instance,
image,
imageCopy,
i*rowsPerThread,
(j < numberOfThreads) ? j*rowsPerThread : image.Height() ) );
AbstractImage::RunThreads( threads, data );
threads.Destroy();
image.Status() = data.status;
}
示例6: ApplyInPlaceFourierTransform
static void ApplyInPlaceFourierTransform( GenericImage<P>& image, FFTDirection::value_type dir, bool parallel, int maxProcessors )
{
int w = FFTC::OptimizedLength( image.Width() );
int h = FFTC::OptimizedLength( image.Height() );
if ( w != image.Width() || h != image.Height() )
{
StatusCallback* s = image.GetStatusCallback(); // don't update status here
image.SetStatusCallback( 0 );
image.ShiftToCenter( w, h );
image.SetStatusCallback( s );
}
bool statusInitialized = false;
if ( image.Status().IsInitializationEnabled() )
{
image.Status().Initialize( (dir == FFTDirection::Backward) ? "Inverse FFT" : "FFT",
image.NumberOfSelectedChannels()*size_type( w + h ) );
image.Status().DisableInitialization();
statusInitialized = true;
}
try
{
FFTC F( h, w, image.Status() );
F.EnableParallelProcessing( parallel, maxProcessors );
for ( int c = image.FirstSelectedChannel(); c <= image.LastSelectedChannel(); ++c )
F( image[c], image[c], (dir == FFTDirection::Backward) ? PCL_FFT_BACKWARD : PCL_FFT_FORWARD );
if ( statusInitialized )
image.Status().EnableInitialization();
}
catch ( ... )
{
if ( statusInitialized )
image.Status().EnableInitialization();
throw;
}
}
示例7: tmp
template <class P> static
void Rotate90CW( GenericImage<P>& image )
{
image.SetUnique();
int w = image.Width();
int h = image.Height();
int h1 = h - 1;
int n = image.NumberOfChannels();
size_type N = image.NumberOfPixels();
typename GenericImage<P>::color_space cs0 = image.ColorSpace();
StatusMonitor status = image.Status();
typename P::sample** f0 = 0;
try
{
if ( image.Status().IsInitializationEnabled() )
status.Initialize( "Rotate 90 degrees, clockwise", n*N );
f0 = image.ReleaseData();
typename GenericImage<P>::sample_array tmp( N );
for ( int c = 0; c < n; ++c, status += N )
{
typename P::sample* f = f0[c];
typename P::sample* t = tmp.Begin();
::memcpy( t, f, N*P::BytesPerSample() );
for ( int y = 0; y < h; ++y )
for ( int x = 0, h1y = h1-y; x < w; ++x, ++t )
f[x*h + h1y] = *t;
}
image.ImportData( f0, h, w, n, cs0 ).Status() = status;
}
catch ( ... )
{
if ( f0 != 0 )
{
for ( int c = 0; c < n; ++c )
if ( f0[c] != 0 )
image.Allocator().Deallocate( f0[c] );
image.Allocator().Deallocate( f0 );
image.FreeData();
}
throw;
}
}
示例8: 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);
};
示例9: HorizontalMirror
template <class P> static
void HorizontalMirror( GenericImage<P>& image )
{
size_type N = image.NumberOfPixels();
int n = image.NumberOfChannels();
if ( image.Status().IsInitializationEnabled() )
image.Status().Initialize( "Horizontal mirror", n*N );
for ( int c = 0; c < n; ++c, image.Status() += N )
for ( int y = 0; y < image.Height(); ++y )
for ( typename P::sample* f = image.ScanLine( y, c ),
* g = f + image.Width()-1; f < g; )
{
pcl::Swap( *f++, *g-- );
}
}
示例10: VerticalMirror
template <class P> static
void VerticalMirror( GenericImage<P>& image )
{
size_type N = image.NumberOfPixels();
int n = image.NumberOfChannels();
if ( image.Status().IsInitializationEnabled() )
image.Status().Initialize( "Vertical mirror", n*N );
for ( int c = 0; c < n; ++c, image.Status() += N )
for ( int y0 = 0, y1 = image.Height()-1; y0 < y1; ++y0, --y1 )
for ( typename P::sample* f0 = image.ScanLine( y0, c ),
* f1 = image.ScanLine( y1, c ),
* fw = f0 + image.Width();
f0 < fw; )
{
pcl::Swap( *f0++, *f1++ );
}
}
示例11: F
static void ApplyInverseRealFourierTransform_2( GenericImage<P>& image, const GenericImage<P1>& dft, bool parallel, int maxProcessors )
{
if ( dft.IsEmpty() )
{
image.FreeData();
return;
}
int w = dft.Width();
int h = dft.Height();
image.AllocateData( 2*(w - 1), h, dft.NumberOfChannels(), dft.ColorSpace() );
bool statusInitialized = false;
if ( image.Status().IsInitializationEnabled() )
{
image.Status().Initialize( "Inverse FFT", image.NumberOfChannels()*size_type( w + h ) );
image.Status().DisableInitialization();
statusInitialized = true;
}
try
{
FFTR F( h, w, image.Status() );
F.EnableParallelProcessing( parallel, maxProcessors );
for ( int c = 0; c < image.NumberOfChannels(); ++c )
F( image[c], dft[c] );
if ( statusInitialized )
image.Status().EnableInitialization();
}
catch ( ... )
{
if ( statusInitialized )
image.Status().EnableInitialization();
throw;
}
}
示例12: Apply
template <class P> static
void Apply( GenericImage<P>& image, const MorphologicalTransformation& transformation )
{
if ( image.IsEmptySelection() )
return;
image.EnsureUnique();
int n = transformation.OverlappingDistance();
if ( n > image.Height() || n > image.Width() )
{
image.Zero();
return;
}
/*
* Dilation requires a reflected structure. We'll unreflect it once the
* transformation has finished.
*/
bool didReflect = false;
if ( transformation.Operator().IsDilation() != transformation.Structure().IsReflected() )
{
const_cast<StructuringElement&>( transformation.Structure() ).Reflect();
didReflect = true;
}
int numberOfRows = image.SelectedRectangle().Height();
int numberOfThreads = transformation.IsParallelProcessingEnabled() ?
Min( transformation.MaxProcessors(), pcl::Thread::NumberOfThreads( numberOfRows, n ) ) : 1;
int rowsPerThread = numberOfRows/numberOfThreads;
size_type N = image.NumberOfSelectedSamples();
if ( image.Status().IsInitializationEnabled() )
image.Status().Initialize( "Morphological transformation, " + transformation.Operator().Description(), N );
ThreadData<P> data( image, transformation, N );
ReferenceArray<Thread<P> > threads;
for ( int i = 0, j = 1, y0 = image.SelectedRectangle().y0; i < numberOfThreads; ++i, ++j )
threads.Add( new Thread<P>( data,
y0 + i*rowsPerThread,
y0 + ((j < numberOfThreads) ? j*rowsPerThread : numberOfRows),
i > 0,
j < numberOfThreads ) );
try
{
AbstractImage::RunThreads( threads, data );
if ( didReflect )
const_cast<StructuringElement&>( transformation.Structure() ).Reflect();
}
catch ( ... )
{
if ( didReflect )
const_cast<StructuringElement&>( transformation.Structure() ).Reflect();
throw;
}
image.SetStatusCallback( nullptr );
int c0 = image.SelectedChannel();
Point p0 = image.SelectedRectangle().LeftTop();
for ( int i = 0, j = 1; i < numberOfThreads; ++i, ++j )
{
if ( i > 0 )
image.Mov( threads[i].UpperOverlappingRegion(),
Point( p0.x, p0.y + i*rowsPerThread ), c0 );
if ( j < numberOfThreads )
image.Mov( threads[i].LowerOverlappingRegion(),
Point( p0.x, p0.y + j*rowsPerThread - threads[i].LowerOverlappingRegion().Height() ), c0 );
}
image.Status() = data.status;
threads.Destroy();
}
示例13: Error
static void WriteJP2KImage( const GenericImage<P>& img,
const ImageInfo& info, const ImageOptions& options,
jas_stream_t* jp2Stream, jas_image_t* jp2Image, int jp2Format,
const JPEG2000ImageOptions& jp2Options )
{
jas_matrix_t* pixels = nullptr;
try
{
pixels = jas_matrix_create( 1, img.Width() );
if ( pixels == nullptr )
throw Error( "Memory allocation error writing JPEG2000 image." );
for ( int c = 0; c < img.NumberOfChannels(); ++c )
{
for ( int y = 0; y < img.Height(); ++y )
{
const typename P::sample* f = img.ScanLine( y, c );
if ( options.bitsPerSample == 8 )
{
if ( jp2Options.signedSample )
{
int8 v;
for ( int x = 0; x < img.Width(); ++x )
{
P::FromSample( v, *f++ );
jas_matrix_set( pixels, 0, x, v );
}
}
else
{
uint8 v;
for ( int x = 0; x < img.Width(); ++x )
{
P::FromSample( v, *f++ );
jas_matrix_set( pixels, 0, x, v );
}
}
}
else
{
if ( jp2Options.signedSample )
{
int16 v;
for ( int x = 0; x < img.Width(); ++x )
{
P::FromSample( v, *f++ );
jas_matrix_set( pixels, 0, x, v );
}
}
else
{
uint16 v;
for ( int x = 0; x < img.Width(); ++x )
{
P::FromSample( v, *f++ );
jas_matrix_set( pixels, 0, x, v );
}
}
}
jas_image_writecmpt( jp2Image, c, 0, y, img.Width(), 1, pixels );
}
}
IsoString jp2OptionsStr;
jp2OptionsStr.AppendFormat( "mode=%s", jp2Options.lossyCompression ? "real" : "int" );
if ( jp2Options.lossyCompression )
jp2OptionsStr.AppendFormat( " rate=%g", jp2Options.compressionRate );
if ( jp2Options.tiledImage )
{
jp2OptionsStr.AppendFormat( " tilewidth=%d", Range( jp2Options.tileWidth, 8, img.Width() ) );
jp2OptionsStr.AppendFormat( " tileheight=%d", Range( jp2Options.tileHeight, 8, img.Height() ) );
}
if ( jp2Options.numberOfLayers > 1 )
{
jp2OptionsStr.Append( " ilyrrates=" );
float dr = (jp2Options.lossyCompression ? jp2Options.compressionRate : 1.0F)/jp2Options.numberOfLayers;
for ( int l = 1; ; )
{
jp2OptionsStr.AppendFormat( "%g", l*dr );
if ( ++l == jp2Options.numberOfLayers )
break;
jp2OptionsStr.Append( ',' );
}
jp2OptionsStr.Append( " prg=" );
switch ( jp2Options.progressionOrder )
{
default:
//.........这里部分代码省略.........
示例14: Apply
template <class P> static
void Apply( GenericImage<P>& image, const Translation& translation )
{
if ( translation.Delta() == 0.0 )
return;
int width = image.Width();
int height = image.Height();
if ( width == 0 || height == 0 )
return;
image.EnsureUnique();
typename P::sample* f = nullptr;
typename P::sample** f0 = nullptr;
int n = image.NumberOfChannels();
typename GenericImage<P>::color_space cs0 = image.ColorSpace();
StatusMonitor status = image.Status();
int numberOfThreads = translation.IsParallelProcessingEnabled() ?
Min( translation.MaxProcessors(), pcl::Thread::NumberOfThreads( height, 1 ) ) : 1;
int rowsPerThread = height/numberOfThreads;
try
{
size_type N = size_type( width )*size_type( height );
if ( status.IsInitializationEnabled() )
status.Initialize( String().Format( "Translate dx=%.3lf, dy=%.3lf, ",
translation.Delta().x, translation.Delta().y ) + translation.Interpolation().Description(),
size_type( n )*N );
f0 = image.ReleaseData();
for ( int c = 0; c < n; ++c )
{
ThreadData<P> data( translation.Delta(), width, height, status, N );
data.f = f = image.Allocator().AllocatePixels( size_type( width )*size_type( height ) );
data.fillValue = (c < translation.FillValues().Length()) ? P::ToSample( translation.FillValues()[c] ) : P::MinSampleValue();
ReferenceArray<Thread<P> > threads;
for ( int i = 0, j = 1; i < numberOfThreads; ++i, ++j )
threads.Add( new Thread<P>( data,
translation.Interpolation().NewInterpolator<P>( f0[c], width, height ),
i*rowsPerThread,
(j < numberOfThreads) ? j*rowsPerThread : height ) );
AbstractImage::RunThreads( threads, data );
threads.Destroy();
image.Allocator().Deallocate( f0[c] );
f0[c] = f;
f = nullptr;
status = data.status;
}
image.ImportData( f0, width, height, n, cs0 ).Status() = status;
}
catch ( ... )
{
if ( f != nullptr )
image.Allocator().Deallocate( f );
if ( f0 != nullptr )
{
for ( int c = 0; c < n; ++c )
if ( f0[c] != nullptr )
image.Allocator().Deallocate( f0[c] );
image.Allocator().Deallocate( f0 );
}
image.FreeData();
throw;
}
}
示例15: Convolve_2
template <class P1, class P2> static
void Convolve_2( const GenericImage<P1>& image, GenericImage<P2>& sharp,
pcl_enum interpolation, float dR, float angleD, DPoint center, int c )
{
PixelInterpolation* P = 0;
PixelInterpolation::Interpolator<P1>* interpolator = 0;
try
{
switch ( interpolation )
{
case LSInterpolation::Bilinear:
P = new BilinearPixelInterpolation();
break;
default:
case LSInterpolation::Bicubic:
P = new BicubicPixelInterpolation();
break;
case LSInterpolation::BicubicSpline:
P = new BicubicSplinePixelInterpolation();
break;
case LSInterpolation::BicubicBSpline:
P = new BicubicBSplinePixelInterpolation();
break;
}
interpolator = P->NewInterpolator<P1>( image[c], image.Width(), image.Height() );
int w = image.Width() - 1;
int h = image.Height() - 1;
double fimg, fsharp;
StatusMonitor monitor;
monitor.Initialize( "<end><cbr>High-pass Larson-Sekanina filter", image.NumberOfPixels() );
sharp.Zero();
float dAlpha = Rad( angleD );
for ( int x = 0; x < image.Width(); ++x )
for ( int y = 0; y < image.Height(); ++y, ++monitor )
{
// Get the central value
P1::FromSample( fimg, image.Pixel( x, y, c ) );
fsharp = fimg+fimg;
double r, theta;
ToPolar( x, y, center, r, theta);
DPoint delta;
// Positive differential
ToCartesian( r-dR, theta+dAlpha, center, delta );
if ( delta.x < 0 )
delta.x = Abs( delta.x );
else if ( delta.x > w )
delta.x = 2*w - delta.x;
if ( delta.y < 0 )
delta.y = Abs( delta.y );
else if ( delta.y > h )
delta.y = 2*h - delta.y;
P1::FromSample( fimg, (*interpolator)( delta ) );
fsharp -= fimg;
//Negative differential
ToCartesian( r-dR, theta-dAlpha, center, delta );
if ( delta.x < 0 )
delta.x = Abs( delta.x );
else if ( delta.x > w )
delta.x = 2*w - delta.x;
if ( delta.y < 0 )
delta.y = Abs( delta.y );
else if ( delta.y > h )
delta.y = 2*h - delta.y;
P1::FromSample( fimg, (*interpolator)( delta ) );
fsharp -= fimg;
sharp.Pixel( x, y ) = P2::ToSample( fsharp );
}
delete interpolator;
delete P;
}
catch ( ... )
{
if ( interpolator != 0 )
delete interpolator;
if ( P != 0 )
delete P;
throw;
}
}