本文整理汇总了C++中ossimRefPtr::getNumberOfBands方法的典型用法代码示例。如果您正苦于以下问题:C++ ossimRefPtr::getNumberOfBands方法的具体用法?C++ ossimRefPtr::getNumberOfBands怎么用?C++ ossimRefPtr::getNumberOfBands使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ossimRefPtr
的用法示例。
在下文中一共展示了ossimRefPtr::getNumberOfBands方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void ossimEdgeFilter::runLocalMax8Filter(T /* dummyVariable */,
ossimRefPtr<ossimImageData> inputData)
{
ossim_uint32 bandIdx = 0;
ossim_uint32 numberOfBands = inputData->getNumberOfBands();
ossim_uint32 x = 0;
ossim_uint32 y = 0;
ossim_uint32 width = theTile->getWidth();
ossim_uint32 height = theTile->getHeight();
ossim_int32 rowIncrement = inputData->getWidth();
ossim_int32 rowIncrement2 = 2*inputData->getWidth();
for(bandIdx = 0; bandIdx < numberOfBands; ++bandIdx)
{
//inputBuf has a 1 pixel edge compared to outputBuf
T* inputBuf = static_cast<T*>(inputData->getBuf(bandIdx));
T* outputBuf = static_cast<T*>(theTile->getBuf(bandIdx));
T np = static_cast<T>(inputData->getNullPix(bandIdx)); //changed to input Null
if(inputBuf&&outputBuf)
{
//one pass: maybe faster if changed to two passes
T* outB;
T* inB;
outB = outputBuf;
inB = inputBuf;
for(y = 0; y < height; ++y)
{
for(x = 0; x < width; ++x)
{
if (inB[1+rowIncrement] != np)
{
*outB = max<T>(
max<T>(
max<T>(inB[0],inB[1]),
max<T>(inB[2],inB[rowIncrement])),
max<T>(
max<T>(inB[rowIncrement+2],inB[rowIncrement2]),
max<T>(inB[rowIncrement2+1],inB[rowIncrement2+2])
));
}
else
{
*outB = np;
}
++outB;
++inB;
}
inB+=2; //go to next line, jump due to edge
}
}
}
theTile->validate();
}
示例2: getNumberOfBands
ossim_uint32 ossimMultiResLevelHistogram::getNumberOfBands(ossim_uint32 resLevel) const
{
const ossimRefPtr<ossimMultiBandHistogram> h = getMultiBandHistogram(resLevel);
if (h.valid())
{
return h->getNumberOfBands();
}
return 0;
}
示例3: fillImage
void ossimQtScrollingImageWidget::fillImage(ossimRefPtr<ossimImageData>& data,
QImage* tempImage)
{
if(data.valid() && data->getBuf() && !tempImage->isNull())
{
ossim_uint8* buf[3];
int numberOfBands = data->getNumberOfBands();
int aWidth = tempImage->size().width();
int aHeight = tempImage->size().height();
int maxPixels = aWidth*aHeight;
int offset;
if(numberOfBands >= 3)
{
buf[0] = static_cast<ossim_uint8*>(data->getBuf(0));
buf[1] = static_cast<ossim_uint8*>(data->getBuf(1));
buf[2] = static_cast<ossim_uint8*>(data->getBuf(2));
}
else
{
buf[0] = static_cast<ossim_uint8*>(data->getBuf(0));
buf[1] = static_cast<ossim_uint8*>(data->getBuf(0));
buf[2] = static_cast<ossim_uint8*>(data->getBuf(0));
}
QRgb *bits = (QRgb*)tempImage->bits();
if(tempImage->bits())
{
for(offset = 0; offset < maxPixels;++offset)
{
*bits = qRgb(*buf[0], *buf[1], *buf[2]);
++buf[0];++buf[1];++buf[2];
++bits;
}
}
else
{
tempImage->fill(0);
}
}
else
{
tempImage->fill(0);
}
}
示例4: runFft
void ossimFftFilter::runFft(ossimRefPtr<ossimImageData>& input,
ossimRefPtr<ossimImageData>& output)
{
NEWMAT::Matrix* realIn = new NEWMAT::Matrix(input->getHeight(),
input->getWidth());
NEWMAT::Matrix* imgIn = new NEWMAT::Matrix(input->getHeight(),
input->getWidth());
NEWMAT::Matrix* realOut = new NEWMAT::Matrix(input->getHeight(),
input->getWidth());
NEWMAT::Matrix* imgOut = new NEWMAT::Matrix(input->getHeight(),
input->getWidth());
ossim_uint32 bandIdx = 0;
ossim_uint32 w = input->getWidth();
ossim_uint32 h = input->getHeight();
ossim_uint32 x = 0;
ossim_uint32 y = 0;
if(theDirectionType == FORWARD)
{
ossim_uint32 bands = input->getNumberOfBands();
for(bandIdx = 0; bandIdx < bands; ++bandIdx)
{
ossim_float64* bandReal = 0;
ossim_float64* bandImg = 0;
fillMatrixForward((ossim_float64*)input->getBuf(bandIdx),
(ossim_float64)input->getNullPix(bandIdx),
*realIn,
*imgIn);
NEWMAT::FFT2(*realIn, *imgIn, *realOut, *imgOut);
bandReal = (ossim_float64*)output->getBuf(2*bandIdx);
bandImg = (ossim_float64*)output->getBuf(2*bandIdx + 1);
if(bandReal&&bandImg)
{
for(y = 0; y < h; ++y)
{
for(x = 0; x < w; ++x)
{
*bandReal = (ossim_float64)((*realOut)[y][x]);
*bandImg = (ossim_float64)((*imgOut)[y][x]);
++bandReal;
++bandImg;
}
}
}
}
}
else
{
ossim_float64* bandReal = 0;
ossim_uint32 bands = input->getNumberOfBands();
for(bandIdx = 0; bandIdx < bands; bandIdx+=2)
{
bandReal = (ossim_float64*)output->getBuf(bandIdx/2);
if(input->getBuf(bandIdx)&&
input->getBuf(bandIdx+1))
{
fillMatrixInverse((double*)input->getBuf(bandIdx),
(double*)input->getBuf(bandIdx+1),
*realIn,
*imgIn);
NEWMAT::FFT2I(*realIn, *imgIn, *realOut, *imgOut);
for(y = 0; y < h; ++y)
{
for(x = 0; x < w; ++x)
{
*bandReal = (ossim_float64)((*realOut)[y][x]);
// if(*bandReal > 1.0)
// {
// *bandReal = 1.0;
// }
// if(*bandReal < 0.0)
// {
// *bandReal = 0.0;
// }
++bandReal;
}
}
}
}
}
delete realIn;
delete imgIn;
delete realOut;
delete imgOut;
}
示例5: getHistogram
ossimRefPtr<ossimImageData> ossimHistogramEqualization::runEqualizationAlgorithm(T, ossimRefPtr<ossimImageData> tile)
{
if(!theAccumulationHistogram ||
!getHistogram())
{
return tile;
}
// for now we will always pull from res 0 information
ossimRefPtr<ossimMultiBandHistogram> histo = getHistogram()->getMultiBandHistogram(0);
if(histo.valid())
{
ossim_uint32 maxBands = ( (histo->getNumberOfBands() >
tile->getNumberOfBands())?
tile->getNumberOfBands():
histo->getNumberOfBands());
long offsetUpperBound = tile->getHeight()*tile->getWidth();
for(ossim_uint32 band = 0; band < maxBands; ++band)
{
ossimRefPtr<ossimHistogram> bandHisto = histo->getHistogram(band);
T* buf = static_cast<T*>(tile->getBuf(band));
double *histoLut = band<theForwardLut.size()?theForwardLut[band]:NULL;
ossim_uint32 actualBand = theBandList[band];
if(bandHisto.valid())
{
if(buf&&histoLut&&(actualBand < histo->getNumberOfBands()))
{
if(theInverseFlag)
{
histoLut = theInverseLut[actualBand];
}
if(histoLut)
{
if(tile->getDataObjectStatus() == OSSIM_FULL)
{
T minPix = (T)tile->getMinPix(actualBand);
T maxPix = (T)tile->getMaxPix(actualBand);
for(long offset = 0; offset < offsetUpperBound; ++offset)
{
ossim_int32 idx = bandHisto->GetIndex(buf[offset]);
if(idx>=0)
{
T value = (T)(histoLut[idx]);
//---
// Assign clamping to min max.
//
// ESH 03/2009 -- Clamping to within min-max fixed
//---
buf[offset] = value < minPix ? minPix :
(value > maxPix ? maxPix : value);
}
}
}
else
{
T minPix = (T)tile->getMinPix(actualBand);
T maxPix = (T)tile->getMaxPix(actualBand);
T nullPix = (T)tile->getNullPix(actualBand);
for(long offset = 0; offset < offsetUpperBound; ++offset)
{
ossim_int32 idx = bandHisto->GetIndex(buf[offset]);
if((buf[offset]!=nullPix)&&(idx>=0))
{
T value = (T)(histoLut[idx]);
//---
// Assign clamping to min max.
//
// ESH 03/2009 -- Clamping to within min-max fixed
//---
buf[offset] = value < minPix ? minPix :
(value > maxPix ? maxPix : value);
}
else
{
buf[offset] = nullPix;
}
}
}
}
}
}
}
tile->validate();
}
return tile;
}
示例6: if
template<class T> void ossimCFARFilter::convolveFull(
T,
ossimRefPtr<ossimImageData> inputData,
ossimRefPtr<ossimImageData> outputData)
{
// let's set up some temporary variables so we don't
// have to call the functions in loops. Iknow that compilers
// typically optimize this out but if we are in debug mode
// with no optimization it will still run fast
//
double sum = 0.0,sqrsum = 0.0,variance = 0.0;
ossim_int32 inputW = static_cast<ossim_int32>(inputData->getWidth());
ossim_uint32 outputW = outputData->getWidth();
ossim_uint32 outputH = outputData->getHeight();
ossim_uint32 numberOfBands = inputData->getNumberOfBands();
ossimIpt outputOrigin = outputData->getOrigin();
ossimIpt inputOrigin = inputData->getOrigin();
ossim_int32 startInputOffset = std::abs(outputOrigin.y - inputOrigin.y)*
inputW + std::abs(outputOrigin.x - inputOrigin.x);
ossim_int32 ulKernelStart = -(2*inputW) - 2;
ossim_int32 ul1KernelStart = -inputW - 1;
ossim_int32 leftKernelStart = -2;
ossim_int32 ll1KernelStart = inputW - 1;
ossim_int32 llKernelStart = (2*inputW) - 2;
//populate kernel offset indices
ossim_int32 KernelStart[BOXSIZE];
T* KernelStartBuf[BOXSIZE];
for(ossim_uint16 i=0;i<BOXSIZE;i++)
{
int offset = i-(BOXSIZE/2);
KernelStart[i] = offset*inputW + offset;
KernelStartBuf[i] = NULL;
}
T* ulKernelStartBuf = NULL;
T* ul1KernelStartBuf = NULL;
T* leftKernelStartBuf = NULL;
T* ll1KernelStartBuf = NULL;
T* llKernelStartBuf = NULL;
for(ossim_uint32 band = 0; band < numberOfBands; ++band)
{
T* inputBuf = static_cast<T*>(inputData->getBuf(band))+startInputOffset;
T* outputBuf = static_cast<T*>(outputData->getBuf(band));
T maxPix = static_cast<T>(getMaxPixelValue(band));
T minPix = static_cast<T>(getMinPixelValue(band));
if(inputBuf&&outputBuf)
{
for(ossim_uint32 row = 0; row < outputW; ++row)
{
ossim_int32 rowOffset = inputW*row;
ulKernelStartBuf = inputBuf + (rowOffset + ulKernelStart);
ul1KernelStartBuf = inputBuf + (rowOffset + ul1KernelStart);
leftKernelStartBuf = inputBuf + (rowOffset + leftKernelStart);
ll1KernelStartBuf = inputBuf + (rowOffset + ll1KernelStart);
llKernelStartBuf = inputBuf + (rowOffset + llKernelStart);
for(ossim_uint16 i=0;i<BOXSIZE;i++)
{
KernelStartBuf[i] = inputBuf + (rowOffset + KernelStart[i]);
}
for(ossim_uint32 col = 0; col < outputH; ++col)
{
//calculate mean
sum = 0.0;
sqrsum = 0.0;
for(ossim_uint32 r=0; r<5; ++r)
sum += theKernel[0][r]*(double)ulKernelStartBuf[r];
for(ossim_uint32 r=0; r<5; ++r)
sum += theKernel[1][r]*(double)ul1KernelStartBuf[r];
for(ossim_uint32 r=0; r<5; ++r)
sum += theKernel[2][r]*(double)leftKernelStartBuf[r];
for(ossim_uint32 r=0; r<5; ++r)
sum += theKernel[3][r]*(double)ll1KernelStartBuf[r];
for(ossim_uint32 r=0; r<5; ++r)
sum += theKernel[4][r]*(double)llKernelStartBuf[r];
/*
for(ossim_uint16 i=0;i<BOXSIZE;i++)
{
for(ossim_uint32 r=0; r<5; ++r)
{
sum += theKernel[i][r]*(double)KernelStartBuf[i][r];
sqrsum += theKernel[i][r]*(double)KernelStartBuf[i][r]
*(double)KernelStartBuf[i][r];
}
}
*/
//calculate mean of squares
for(ossim_uint32 r=0; r<5; ++r)
sqrsum += theKernel[0][r]*(double)ulKernelStartBuf[r]
//.........这里部分代码省略.........
示例7: runLaplacianFilter
void ossimEdgeFilter::runLaplacianFilter(T /* dummyVariable */,
ossimRefPtr<ossimImageData> inputData)
{
ossim_uint32 bandIdx = 0;
ossim_uint32 numberOfBands = inputData->getNumberOfBands();
// double horizontalValue = 0.0;
// double verticalValue = 0.0;
double value = 0.0;
// ossim_uint32 valueIdx = 0;
ossim_uint32 x = 0;
ossim_uint32 y = 0;
ossim_uint32 width = theTile->getWidth();
ossim_uint32 height = theTile->getHeight();
ossim_int32 rowIncrement = inputData->getWidth();
ossim_int32 rowIncrement2 = 2*inputData->getWidth();
for(bandIdx = 0; bandIdx < numberOfBands; ++bandIdx)
{
T* inputBuf = static_cast<T*>(inputData->getBuf(bandIdx));
T* outputBuf = static_cast<T*>(theTile->getBuf(bandIdx));
T np = static_cast<T>(theTile->getNullPix(bandIdx));
T minP = static_cast<T>(theTile->getMinPix(bandIdx));
T maxP = static_cast<T>(theTile->getMaxPix(bandIdx));
if(inputBuf&&outputBuf)
{
for(y = 0; y < height; ++y)
{
for(x = 0; x < width; ++x)
{
if( (*(inputBuf + rowIncrement + 1) != np))
{
value = fabs(((double)inputBuf[rowIncrement + 1]*4.0) -
((double)inputBuf[1] + (double)inputBuf[rowIncrement] + (double)inputBuf[rowIncrement + 2] + (double)inputBuf[rowIncrement2+1]));
if((value == np) ||
(value < minP))
{
*outputBuf = (static_cast<T>(minP));
}
else if(value > maxP)
{
*outputBuf = (static_cast<T>(maxP));
}
else
{
*outputBuf = (static_cast<T>(value));
}
}
else
{
*outputBuf = np;
}
++outputBuf;
++inputBuf;
}
inputBuf+=2;
}
}
}
theTile->validate();
}
示例8: runRobertsFilter
void ossimEdgeFilter::runRobertsFilter(T /* dummyVariable */,
ossimRefPtr<ossimImageData> inputData)
{
ossim_uint32 bandIdx = 0;
ossim_uint32 numberOfBands = inputData->getNumberOfBands();
double v1 = 0.0;
double v2 = 0.0;
double value = 0.0;
// ossim_uint32 valueIdx = 0;
ossim_uint32 x = 0;
ossim_uint32 y = 0;
ossim_uint32 width = theTile->getWidth();
ossim_uint32 height = theTile->getHeight();
ossim_int32 rowIncrement = inputData->getWidth();
for(bandIdx = 0; bandIdx < numberOfBands; ++bandIdx)
{
T* inputBuf = static_cast<T*>(inputData->getBuf(bandIdx));
T* outputBuf = static_cast<T*>(theTile->getBuf(bandIdx));
T np = static_cast<T>(theTile->getNullPix(bandIdx));
T minP = static_cast<T>(theTile->getMinPix(bandIdx));
T maxP = static_cast<T>(theTile->getMaxPix(bandIdx));
if(inputBuf&&outputBuf)
{
for(y = 0; y < height; ++y)
{
for(x = 0; x < width; ++x)
{
if( (*inputBuf) != np)
{
v1 = (double)inputBuf[0] - (double)(inputBuf[rowIncrement+1]);
v2 = (double)inputBuf[1] - (double)inputBuf[rowIncrement];
value = sqrt(v1*v1 + v2*v2);
if((value == np) ||
(value < minP))
{
*outputBuf = (static_cast<T>(minP));
}
else if(value > maxP)
{
*outputBuf = (static_cast<T>(maxP));
}
else
{
*outputBuf = (static_cast<T>(value));
}
}
else
{
*outputBuf = np;
}
++outputBuf;
++inputBuf;
}
++inputBuf;
}
}
}
theTile->validate();
}
示例9: encodeJpeg
bool ossimCodecFactory::encodeJpeg( ossim_uint32 quality,
const ossimRefPtr<ossimImageData>& in,
std::vector<ossim_uint8>& out ) const
{
bool result = false;
if ( in.valid() && (in->getDataObjectStatus() != OSSIM_NULL) )
{
if ( in->getScalarType() == OSSIM_UINT8 )
{
// Open a memory stream up to put the jpeg image in memory:
std::stringstream jpegStreamBuf;
//---
// Initialize JPEG compression library:
// NOTE: JDIMENSION is an "unsigned int"
//---
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
cinfo.err = jpeg_std_error( &jerr );
jpeg_create_compress(&cinfo);
// Define a custom stream destination manager for jpeglib to write compressed block:
jpeg_cpp_stream_dest(&cinfo, jpegStreamBuf);
/* Setting the parameters of the output file here */
cinfo.image_width = in->getWidth();
cinfo.image_height = in->getHeight();
// Bands must be one or three for this writer.
const ossim_uint32 INPUT_BANDS = in->getNumberOfBands();
if ( (INPUT_BANDS == 1) || (INPUT_BANDS == 3) )
{
cinfo.input_components = INPUT_BANDS;
}
else
{
if ( INPUT_BANDS < 3 )
{
cinfo.input_components = 1; // Use first band.
}
else
{
cinfo.input_components = 3; // Use the first 3 bands.
}
}
// colorspace of input image
if ( cinfo.input_components == 3)
{
cinfo.in_color_space = JCS_RGB;
}
else
{
cinfo.in_color_space = JCS_GRAYSCALE;
}
// Default compression parameters, we shouldn't be worried about these.
jpeg_set_defaults( &cinfo );
jpeg_set_quality(&cinfo, quality, TRUE); //limit to baseline-JPEG values
// Now do the compression...
jpeg_start_compress( &cinfo, TRUE );
// Line buffer:
ossim_uint32 buf_size = cinfo.input_components*cinfo.image_width;
std::vector<ossim_uint8> buf(buf_size);
// Compress the tile on line at a time:
JSAMPROW row_pointer[1]; // Pointer to a single row.
row_pointer[0] = (JSAMPLE*)&buf.front();
// Get pointers to the input data:
std::vector<const ossim_uint8*> inBuf(cinfo.input_components);
for ( ossim_int32 band = 0; band < cinfo.input_components; ++band )
{
inBuf[band] = in->getUcharBuf(band);
}
ossim_uint32 inIdx = 0;
for (ossim_uint32 line=0; line< cinfo.image_height; ++line)
{
// Convert from band sequential to band interleaved by pixel.
ossim_uint32 outIdx = 0;
for ( ossim_uint32 p = 0; p < cinfo.image_width; ++p )
{
for ( ossim_int32 band = 0; band < cinfo.input_components; ++band )
{
buf[outIdx++] = inBuf[band][inIdx];
}
++inIdx;
}
// Write it...
jpeg_write_scanlines( &cinfo, row_pointer, 1 );
}
// Similar to read file, clean up after we're done compressing.
//.........这里部分代码省略.........
示例10: CopyIplImageToTile
void ossimTileToIplFilter::CopyIplImageToTile(T dummyVariable, ossimRefPtr<ossimImageData> inputTile, IplImage *output)
{
// Determine if tile is full or partially filled
ossimDataObjectStatus status = inputTile->getDataObjectStatus();
uchar *outputData = (uchar *)output->imageData;
int outputStep = output->widthStep/sizeof(uchar);
int pixVal;
long outputOffset = 0;
T maxPix = static_cast<T>(getMaxPixelValue(0));
T minPix = static_cast<T>(getMinPixelValue(0));
T np = static_cast<T>(inputTile->getNullPix(0));
if (status == OSSIM_PARTIAL)
{
for (ossim_uint32 bandIdx = 0; bandIdx < inputTile->getNumberOfBands(); ++bandIdx)
{
T* outBuf = static_cast<T*>(inputTile->getBuf(bandIdx));
if (outBuf)
{
outputOffset = 0;
for (long y = 0; y < output->height; ++y)
{
for (long x = 0; x < output->width; ++x)
{
if (!inputTile->isNull(outputOffset))
{
pixVal = (int)round(outputData[y * outputStep + x]);
if (pixVal > maxPix)
*outBuf = maxPix;
else if (pixVal < 0)
*outBuf = minPix;
else
*outBuf = static_cast<T>(pixVal);
}
else
inputTile->setNull(outputOffset);
++outBuf;
++outputOffset;
}
}
}
}
}
else
{
for (ossim_uint32 bandIdx = 0; bandIdx < inputTile->getNumberOfBands(); ++bandIdx)
{
T* outBuf = (T*)(inputTile->getBuf(bandIdx));
if (outBuf)
{
for (int y = 0; y < output->height; ++y)
{
for (int x = 0; x < output->width; ++x)
{
pixVal = (int)round(outputData[y * outputStep + x]);
if (pixVal > maxPix)
*outBuf = (maxPix);
else if (pixVal < 0)
*outBuf = (minPix);
else
*outBuf = static_cast<T>(pixVal);
// Increment the output buffer to the next pixel value
++outBuf;
}
}
}
else
*outBuf = np;
}
}
}