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


C++ DataAccessor类代码示例

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


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

示例1: getCurrentFrameAccessor

bool BackgroundSuppressionShell::preprocess()
{
   if(mpRaster == NULL)
   {
      return false;
   }
   RasterDataDescriptor *pDesc = static_cast<RasterDataDescriptor*>(mpRaster->getDataDescriptor());
   if(mpTemporaryBuffer.get() == NULL)
   {
      mpTemporaryBuffer.reset(new char[pDesc->getRowCount() * pDesc->getColumnCount() * pDesc->getBytesPerElement()]);
      if(mpTemporaryBuffer.get() == NULL)
      {
         return false;
      }
   }
   DataAccessor frameAccessor = getCurrentFrameAccessor();
   size_t rowSize = pDesc->getColumnCount() * pDesc->getBytesPerElement();
   for(unsigned int row = 0; row < pDesc->getRowCount(); row++)
   {
      if(!frameAccessor.isValid())
      {
         return false;
      }
      memcpy(mpTemporaryBuffer.get() + row * rowSize, frameAccessor->getRow(), rowSize);
      frameAccessor->nextColumn();
   }
   return true;
}
开发者ID:Siddharthk,项目名称:coan,代码行数:28,代码来源:BackgroundSuppressionShell.cpp

示例2: VERIFY

bool bilinear_bayer::copyImage(RasterElement * pRaster,
							   RasterElement * dRaster, int i,
							   Progress * pProgress)
{
	VERIFY(pRaster != NULL);
	RasterDataDescriptor *pDesc =
		dynamic_cast < RasterDataDescriptor * >(pRaster->getDataDescriptor());
	VERIFY(dRaster != NULL);
	RasterDataDescriptor *rDesc =
		dynamic_cast < RasterDataDescriptor * >(dRaster->getDataDescriptor());



	DimensionDescriptor thirdBand = pDesc->getActiveBand(i);	// get active
																// band

	// source
	FactoryResource < DataRequest > pRequest;
	pRequest->setInterleaveFormat(BSQ);
	pRequest->setBands(thirdBand, thirdBand);
	DataAccessor thirdBandDa = pRaster->getDataAccessor(pRequest.release());
	thirdBand = rDesc->getActiveBand(i);

	// destination
	FactoryResource < DataRequest > pResultRequest;
	pResultRequest->setWritable(true);
	pRequest->setInterleaveFormat(BSQ);
	pResultRequest->setBands(thirdBand, thirdBand);
	DataAccessor pDestAcc = dRaster->getDataAccessor(pResultRequest.release());






	VERIFY(thirdBandDa.isValid());
	VERIFY(pDestAcc.isValid());


	for (unsigned int curRow = 0; curRow < pDesc->getRowCount(); ++curRow)

	{
		for (unsigned int curCol = 0; curCol < pDesc->getColumnCount();
			 ++curCol)
		{

			switchOnEncoding(pDesc->getDataType(), bilinear,
							 pDestAcc->getColumn(), thirdBandDa, curRow,
							 curCol, pDesc->getRowCount(),
							 pDesc->getColumnCount(), i, pRaster);
			pDestAcc->nextColumn();
		}

		pDestAcc->nextRow();

	}

	return true;
}
开发者ID:vijeshm,项目名称:Opticks-Photography-Addons,代码行数:59,代码来源:bilinear_bayer.cpp

示例3: getResampledLibraryData

bool SpectralLibraryManager::getResampledSignatureValues(const RasterElement* pRaster, const Signature* pSignature,
        std::vector<double>& values)
{
    values.clear();
    if (pRaster == NULL || pSignature == NULL)
    {
        return false;
    }

    const RasterElement* pLibData = getResampledLibraryData(pRaster);
    if (pLibData == NULL)
    {
        return false;
    }

    int index = getSignatureIndex(pSignature);
    if (index < 0)
    {
        return false;
    }
    const RasterDataDescriptor* pLibDesc = dynamic_cast<const RasterDataDescriptor*>(pLibData->getDataDescriptor());
    VERIFY(pLibDesc != NULL);
    unsigned int numBands = pLibDesc->getBandCount();
    values.reserve(numBands);
    FactoryResource<DataRequest> pRqt;
    unsigned int row = static_cast<unsigned int>(index);
    pRqt->setInterleaveFormat(BIP);
    pRqt->setRows(pLibDesc->getActiveRow(row), pLibDesc->getActiveRow(row), 1);
    DataAccessor acc = pLibData->getDataAccessor(pRqt.release());
    VERIFY(acc.isValid());
    double* pDbl = reinterpret_cast<double*>(acc->getColumn());
    for (unsigned int band = 0; band < numBands; ++band)
    {
        values.push_back(*pDbl);
        ++pDbl;
    }

    return true;
}
开发者ID:tclarke,项目名称:opticks-extras-Spectral,代码行数:39,代码来源:SpectralLibraryManager.cpp

示例4: pStep

bool Orthorectification::process(int type, RasterElement *pDSM, GRID DSMGrid, double Geoid_Offset, int DSM_resampling)
{
	StepResource pStep("Orthorectification Process", "app", "B4D426EC-E06D-11E1-83C8-42E56088709B");
	pStep->addStep("Start","app", "B4D426EC-E06D-11E1-83C8-42E56088709B");
	boxsize=0;

	res_type = type;

	if (res_type == 0) 
	{
		boxsize=0;	
	}
	else if (res_type == 1)
	{
		boxsize=1;		
	}
	else if (res_type == 2)
	{
		boxsize=2;		
	}
	else if (res_type == 3)
	{
		boxsize=3;	
	}

    ProgressResource pResource("ProgressBar");

	Progress *pProgress=pResource.get(); 

	pProgress->setSettingAutoClose(false);

	RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(Image->getDataDescriptor());
    
    FactoryResource<DataRequest> pRequest;
    DataAccessor pSrcAcc = Image->getDataAccessor(pRequest.release());

    RasterDataDescriptor* pDescDSM = static_cast<RasterDataDescriptor*>(pDSM->getDataDescriptor());

	FactoryResource<DataRequest> pRequestDSM;
    DataAccessor pDSMAcc = pDSM->getDataAccessor(pRequestDSM.release());

 
	unsigned int N_Row = int(OrthoGrid.Y_Dim)+1;
	unsigned int N_Col = int(OrthoGrid.X_Dim)+1;

	// Check name of raster element //
	Service<ModelServices> pModel;
    vector<string> mCubeNames = pModel->getElementNames("RasterElement");

	int NameIndex = 0, control=0;
	stringstream out;
	string OutputName=Image->getName();
	string OutputName1 = OutputName.substr(0,OutputName.find_last_of("."));

	while (control == 0)
	{
		control = 1;
		OutputName = OutputName1+"_ortho_";

		out << NameIndex;
		OutputName.append(out.str()+".tiff");		
		
		for (unsigned int k=0; k<mCubeNames.size(); k++)
		{
		if (OutputName.compare(mCubeNames[k]) == 0) control = 0;
		}

		NameIndex++;
		out.str("");
		out.clear();

	}

	// Create output raster element and assoiciated descriptor and accessor //
	
	ModelResource<RasterElement> pResultCube(RasterUtilities::createRasterElement(OutputName,N_Row ,N_Col, FLT4BYTES));

	RasterDataDescriptor* pResultDesc = static_cast<RasterDataDescriptor*> (pResultCube->getDataDescriptor());

    FactoryResource<DataRequest> pResultRequest;
    pResultRequest->setWritable(true);
    DataAccessor pDestAcc = pResultCube->getDataAccessor(pResultRequest.release());

    double NodeLat, NodeLon, H_IJ=0;
	//int DSM_I, DSM_J;

    for (unsigned int row = 0; row < N_Row; ++row)
    {
	  if (pProgress != NULL)
	  {
      pProgress->updateProgress("Calculating result", row * 100 / N_Row, NORMAL);
	  }

      if (!pDestAcc.isValid())
      {
         std::string msg = "Unable to access the cube data.";
         pProgress->updateProgress(msg, 0, ERRORS);
		 pStep->finalize(Message::Failure, msg);
         return false;
      }
//.........这里部分代码省略.........
开发者ID:GSoC-2012-Nascetti,项目名称:SAR_PlugIn,代码行数:101,代码来源:Orthorectification.cpp

示例5: progress

bool SamAlgorithm::processAll()
{
   auto_ptr<Wavelengths> pWavelengths;

   ProgressTracker progress(getProgress(), "Starting SAM", "spectral", "C4320027-6359-4F5B-8820-8BC72BF1B8F0");
   progress.getCurrentStep()->addProperty("Interactive", isInteractive());

   RasterElement* pElement = getRasterElement();
   if (pElement == NULL)
   {
      progress.report(SAMERR012, 0, ERRORS, true);
      return false;
   }
   progress.getCurrentStep()->addProperty("Cube", pElement->getName());
   const RasterDataDescriptor* pDescriptor = static_cast<RasterDataDescriptor*>(pElement->getDataDescriptor());
   VERIFY(pDescriptor != NULL);

   BitMaskIterator iter(getPixelsToProcess(), pElement);
   unsigned int numRows = iter.getNumSelectedRows();
   unsigned int numColumns = iter.getNumSelectedColumns();
   unsigned int numBands = pDescriptor->getBandCount();
   Opticks::PixelOffset layerOffset(iter.getColumnOffset(), iter.getRowOffset());

   // get cube wavelengths
   DynamicObject* pMetadata = pElement->getMetadata();
   if (pMetadata != NULL)
   {
      pWavelengths.reset(new Wavelengths(pMetadata));
      if (!pWavelengths->isEmpty() && (!pWavelengths->hasEndValues() || !pWavelengths->hasStartValues()))
      {
         pWavelengths->calculateFwhm();
      }
   }
   VERIFY(pWavelengths.get() != NULL);

   int sig_index = 0;
   bool bSuccess = true;

   if (mInputs.mSignatures.empty())
   {
      progress.report(SAMERR005, 0, ERRORS, true);
      return false;
   }
   int iSignatureCount = mInputs.mSignatures.size();

   // Get colors for all the signatures
   vector<ColorType> layerColors, excludeColors;
   excludeColors.push_back(ColorType(0, 0, 0));
   excludeColors.push_back(ColorType(255, 255, 255));
   ColorType::getUniqueColors(iSignatureCount, layerColors, excludeColors);

   // Create a vector for the signature names
   vector<string> sigNames;

   // Create a pseudocolor results matrix if necessary
   RasterElement* pPseudocolorMatrix = NULL;
   RasterElement* pLowestSAMValueMatrix = NULL;
   // Check for multiple Signatures and if the user has selected
   // to combined multiple results in one pseudocolor output layer
   if (iSignatureCount > 1 && mInputs.mbCreatePseudocolor)
   {
      pPseudocolorMatrix = createResults(numRows, numColumns, mInputs.mResultsName);
      pLowestSAMValueMatrix = createResults(numRows, numColumns, "LowestSAMValue");

      if (pPseudocolorMatrix == NULL || pLowestSAMValueMatrix == NULL )
      {
         progress.report(SAMERR007, 0, ERRORS, true);
         return false;
      }

      FactoryResource<DataRequest> pseudoRequest;
      pseudoRequest->setWritable(true);
      string failedDataRequestErrorMessage =
         SpectralUtilities::getFailedDataRequestErrorMessage(pseudoRequest.get(), pPseudocolorMatrix);
      DataAccessor pseudoAccessor = pPseudocolorMatrix->getDataAccessor(pseudoRequest.release());
      if (!pseudoAccessor.isValid())
      {
         string msg = "Unable to access results.";
         if (!failedDataRequestErrorMessage.empty())
         {
            msg += "\n" + failedDataRequestErrorMessage;
         }

         progress.report(msg, 0, ERRORS, true);
         return false;
      }

      FactoryResource<DataRequest> lsvRequest;
      lsvRequest->setWritable(true);
      failedDataRequestErrorMessage =
         SpectralUtilities::getFailedDataRequestErrorMessage(lsvRequest.get(), pLowestSAMValueMatrix);
      DataAccessor lowestSamValueAccessor = pLowestSAMValueMatrix->getDataAccessor(lsvRequest.release());
      if (!lowestSamValueAccessor.isValid())
      {
         string msg = "Unable to access results.";
         if (!failedDataRequestErrorMessage.empty())
         {
            msg += "\n" + failedDataRequestErrorMessage;
         }

//.........这里部分代码省略.........
开发者ID:yuguess,项目名称:GSoC,代码行数:101,代码来源:Sam.cpp

示例6: getReporter

void ConvolutionFilterShell::ConvolutionFilterThread::convolve(const T*)
{
   int numResultsCols = mInput.mpIterCheck->getNumSelectedColumns();
   if (mInput.mpResult == NULL)
   {
      return;
   }

   const RasterDataDescriptor* pResultDescriptor = static_cast<const RasterDataDescriptor*>(
      mInput.mpResult->getDataDescriptor());

   // account for AOIs which extend outside the dataset
   int maxRowNum = static_cast<int>(mInput.mpDescriptor->getRowCount()) - 1;
   mRowRange.mFirst = std::max(0, mRowRange.mFirst);
   mRowRange.mLast = std::min(mRowRange.mLast, maxRowNum);

   unsigned int bandCount = mInput.mBands.size();
   for (unsigned int bandNum = 0; bandNum < bandCount; ++bandNum)
   {
      FactoryResource<DataRequest> pResultRequest;
      pResultRequest->setRows(pResultDescriptor->getActiveRow(mRowRange.mFirst),
         pResultDescriptor->getActiveRow(mRowRange.mLast));
      pResultRequest->setColumns(pResultDescriptor->getActiveColumn(0),
         pResultDescriptor->getActiveColumn(numResultsCols - 1));
      pResultRequest->setBands(pResultDescriptor->getActiveBand(bandNum),
         pResultDescriptor->getActiveBand(bandNum));
      pResultRequest->setWritable(true);
      DataAccessor resultAccessor = mInput.mpResult->getDataAccessor(pResultRequest.release());
      if (!resultAccessor.isValid())
      {
         return;
      }

      int oldPercentDone = -1;
      int rowOffset = static_cast<int>(mInput.mpIterCheck->getOffset().mY);
      int startRow = mRowRange.mFirst + rowOffset;
      int stopRow = mRowRange.mLast + rowOffset;

      int columnOffset = static_cast<int>(mInput.mpIterCheck->getOffset().mX);
      int startColumn = columnOffset;
      int stopColumn = numResultsCols + columnOffset - 1;

      int yshift = (mInput.mKernel.Nrows() - 1) / 2;
      int xshift = (mInput.mKernel.Ncols() - 1) / 2;

      FactoryResource<DataRequest> pRequest;
      pRequest->setRows(mInput.mpDescriptor->getActiveRow(std::max(0, startRow - yshift)),
         mInput.mpDescriptor->getActiveRow(std::min(maxRowNum, stopRow + mInput.mKernel.Nrows() - yshift)));
      pRequest->setColumns(mInput.mpDescriptor->getActiveColumn(startColumn),
         mInput.mpDescriptor->getActiveColumn(stopColumn));
      pRequest->setBands(mInput.mpDescriptor->getActiveBand(mInput.mBands[bandNum]),
         mInput.mpDescriptor->getActiveBand(mInput.mBands[bandNum]));
      DataAccessor accessor = mInput.mpRaster->getDataAccessor(pRequest.release());
      if (!accessor.isValid())
      {
         return;
      }

      Service<ModelServices> model;
      ModelServices* pModel = model.get();
      int numRows = stopRow - startRow + 1;
      for (int row_index = startRow; row_index <= stopRow; ++row_index)
      {
         int percentDone = 100 * ((bandNum * numRows) + (row_index - startRow)) / (numRows * bandCount); 
         if (percentDone > oldPercentDone)
         {
            oldPercentDone = percentDone;
            getReporter().reportProgress(getThreadIndex(), percentDone);
         }
         if (mInput.mpAbortFlag != NULL && *mInput.mpAbortFlag)
         {
            break;
         }

         for (int col_index = startColumn; col_index <= stopColumn; ++col_index)
         {
            double accum = 0.0;
            if (mInput.mpIterCheck->getPixel(col_index, row_index))
            {
               for (int kernelrow = 0; kernelrow < mInput.mKernel.Nrows(); kernelrow++)
               {
                  int neighbor_row = row_index - yshift + kernelrow;
                  int real_row = std::min(std::max(0, neighbor_row),
                     static_cast<int>(mInput.mpDescriptor->getRowCount()) - 1);
                  for (int kernelcol = 0; kernelcol < mInput.mKernel.Ncols(); kernelcol++)
                  {
                     int neighbor_col = col_index - xshift + kernelcol;
                     int real_col = std::min(std::max(0, neighbor_col),
                        static_cast<int>(mInput.mpDescriptor->getColumnCount()) - 1);
                     accessor->toPixel(real_row, real_col);
                     if (accessor.isValid() == false)
                     {
                        return;
                     }

                     double val = 0.0;
                     pModel->getDataValue<T>(reinterpret_cast<T*>(accessor->getColumn()), COMPLEX_MAGNITUDE, 0, val);
                     accum += mInput.mKernel(kernelrow+1, kernelcol+1) * val / mInput.mKernel.Storage();
                  }
               }
//.........这里部分代码省略.........
开发者ID:Tom-VdE,项目名称:opticks,代码行数:101,代码来源:ConvolutionFilterShell.cpp

示例7: edgeDetection7

   double edgeDetection7(DataAccessor pSrcAcc, int row, int col, int rowSize, int colSize)
   {
      int prevCol = std::max(col - 1, 0);
      int prevRow = std::max(row - 1, 0);
      int nextCol = std::min(col + 1, colSize - 1);
      int nextRow = std::min(row + 1, rowSize - 1);

	  int prevCol1 = std::max(col-2,0);
	  int prevRow1= std::max(row-2,0);
	  int nextCol1= std::min(col+2,colSize-1);
	  int nextRow1= std::min(row+2,rowSize-1);

	  pSrcAcc->toPixel(prevRow1, prevCol1);
      int row1col1 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(prevRow1, prevCol);
      int row1col2 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(prevRow1, col);
      int row1col3 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(prevRow1, nextCol);
      int row1col4 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(prevRow1, nextCol1);
      int row1col5 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(prevRow, prevCol1);
      int row2col1 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(prevRow, prevCol);
      int row2col2 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(prevRow, col);
      int row2col3 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(prevRow, nextCol);
      int row2col4 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(prevRow, nextCol1);
      int row2col5 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(row, prevCol1);
      int row3col1 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(row, prevCol);
      int row3col2 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(row, col);
      int row3col3 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(row, nextCol);
      int row3col4 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(row, nextCol1);
      int row3col5 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(nextRow, prevCol1);
      int row4col1 = pSrcAcc->getColumnAsInteger();

	  pSrcAcc->toPixel(nextRow, prevCol);
      int row4col2 = pSrcAcc->getColumnAsInteger();

      pSrcAcc->toPixel(nextRow, col);
      int row4col3 = pSrcAcc->getColumnAsInteger();

      pSrcAcc->toPixel(nextRow, nextCol);
      int row4col4 = pSrcAcc->getColumnAsInteger();

      pSrcAcc->toPixel(nextRow, nextCol1);
      int row4col5 = pSrcAcc->getColumnAsInteger();

      pSrcAcc->toPixel(nextRow1, prevCol1);
      int row5col1 = pSrcAcc->getColumnAsInteger();

      pSrcAcc->toPixel(nextRow1, prevCol);
      int row5col2 = pSrcAcc->getColumnAsInteger();

      pSrcAcc->toPixel(nextRow1, col);
      int row5col3 = pSrcAcc->getColumnAsInteger();

      pSrcAcc->toPixel(nextRow1, nextCol);
      int row5col4 = pSrcAcc->getColumnAsInteger();

      pSrcAcc->toPixel(nextRow1, nextCol1);
      int row5col5 = pSrcAcc->getColumnAsInteger();

	   int g = row1col1 + row1col2 + row1col3 + row1col4 + row1col5 + row2col1 + row2col2 + row2col3 + row2col4
		         + row2col5 + row3col1 + row3col2 + 24*row3col3 + row3col4 + row3col5 + row4col1 + row4col2 + row4col3
				 + row4col4 + row4col5 + row5col1 + row5col2 + row5col3 + row5col4 + row5col5;


	    double value = g/159.0;

		return value;

      
   };
开发者ID:pMav5,项目名称:Ship-Detection-Applet-for-Opticks,代码行数:98,代码来源:highpass.cpp

示例8: pStep

bool WaveletKSigmaFilter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   StepResource pStep("Wavelet K-Sigma Filter", "app", "1A4BDC34-5A95-419B-8E53-C92333AFFC3E");
   if (pInArgList == NULL || pOutArgList == NULL)
   {
      return false;
   }
   Progress* pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg());
   RasterElement* pCube = pInArgList->getPlugInArgValue<RasterElement>(Executable::DataElementArg());
   if (pCube == NULL)
   {
      std::string msg = "A raster cube must be specified.";
      pStep->finalize(Message::Failure, msg);
      if (pProgress != NULL) 
      {
         pProgress->updateProgress(msg, 0, ERRORS);
      }
      return false;
   }
   RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(pCube->getDataDescriptor());
   VERIFY(pDesc != NULL);
   EncodingType ResultType = pDesc->getDataType();
   if (pDesc->getDataType() == INT4SCOMPLEX)
   {
      ResultType = INT4SBYTES;
   }
   else if (pDesc->getDataType() == FLT8COMPLEX)
   {
      ResultType = FLT8BYTES;
   }

   FactoryResource<DataRequest> pRequest;
   pRequest->setInterleaveFormat(BSQ);
   DataAccessor pSrcAcc = pCube->getDataAccessor(pRequest.release());

   ModelResource<RasterElement> pResultCube(RasterUtilities::createRasterElement(pCube->getName() +
      "_Noise_Removal_Result", pDesc->getRowCount(), pDesc->getColumnCount(), ResultType));
   if (pResultCube.get() == NULL)
   {
      std::string msg = "A raster cube could not be created.";
      pStep->finalize(Message::Failure, msg);
      if (pProgress != NULL) 
      {
         pProgress->updateProgress(msg, 0, ERRORS);
      }
      return false;
   }
   FactoryResource<DataRequest> pResultRequest;
   pResultRequest->setWritable(true);
   DataAccessor pDestAcc = pResultCube->getDataAccessor(pResultRequest.release());

   Service<DesktopServices> pDesktop;
   WaveletKSigmaDlg dlg(pDesktop->getMainWidget());
   int stat = dlg.exec();
   if (stat != QDialog::Accepted)
   {
	  // pProgress->updateProgress("Level 4 " + StringUtilities::toDisplayString(dlg.getLevelThreshold(3))
       //  + " Level5 " + StringUtilities::toDisplayString(dlg.getLevelThreshold(4)), dlg.getLevelThreshold(0), NORMAL);

	   return true;
   }

   unsigned int rowLoops;
   unsigned int colLoops;
   unsigned int rowIndex = 0;
   unsigned int colIndex = 0;
   double ScaleKValue[MAX_WAVELET_LEVELS] = {0.0};
   for (int k=0; k<MAX_WAVELET_LEVELS;k++)
   {
	   ScaleKValue[k] = dlg.getLevelThreshold(k);
   }
   
   if (0 == pDesc->getRowCount()%rowBlocks)
   {
	   rowLoops = pDesc->getRowCount()/rowBlocks;
   }
   else
   {
	   rowLoops = pDesc->getRowCount()/rowBlocks + 1;
   }

   if (0 == pDesc->getColumnCount()%colBlocks)
   {
	   colLoops = pDesc->getColumnCount()/colBlocks;
   }
   else
   {
	   colLoops = pDesc->getColumnCount()/colBlocks + 1;
   }

   for (unsigned int i = 0; i < rowLoops; i++)
   {
	   if ( rowIndex + rowBlocks > pDesc->getRowCount())
	   {
		   rowIndex = pDesc->getRowCount() - rowBlocks;
	   }

	   colIndex = 0;

	   for (unsigned int j = 0; j < colLoops; j++)
//.........这里部分代码省略.........
开发者ID:felipebetancur,项目名称:Astronomy-Image-Processing,代码行数:101,代码来源:WaveletKSigmaFilter.cpp

示例9: VERIFY

bool adaptive_median::copyImage4(RasterElement * pRaster,
								 RasterElement * dRaster, int i,
								 Progress * pProgress)
{
	int flag = 0;
	int size = 3;
	int sizeMax = MAX_SIZE;
	VERIFY(pRaster != NULL);
	RasterDataDescriptor *pDesc =
		dynamic_cast < RasterDataDescriptor * >(pRaster->getDataDescriptor());
	VERIFY(dRaster != NULL);
	RasterDataDescriptor *rDesc =
		dynamic_cast < RasterDataDescriptor * >(dRaster->getDataDescriptor());

	DimensionDescriptor thirdBand = pDesc->getActiveBand(i);	// get active
																// band

	// source
	FactoryResource < DataRequest > pRequest;
	pRequest->setInterleaveFormat(BSQ);
	pRequest->setBands(thirdBand, thirdBand);
	DataAccessor thirdBandDa = pRaster->getDataAccessor(pRequest.release());
	thirdBand = rDesc->getActiveBand(i);

	// destination
	FactoryResource < DataRequest > pResultRequest;
	pResultRequest->setWritable(true);
	pRequest->setInterleaveFormat(BSQ);
	pResultRequest->setBands(thirdBand, thirdBand);
	DataAccessor pDestAcc = dRaster->getDataAccessor(pResultRequest.release());
	VERIFY(thirdBandDa.isValid());
	VERIFY(pDestAcc.isValid());

	for (unsigned int curRow = 0; curRow < pDesc->getRowCount(); ++curRow)
	{
		for (unsigned int curCol = 0; curCol < pDesc->getColumnCount();
			 ++curCol)
		{
			VERIFY(pDestAcc.isValid());
			switchOnEncoding(pDesc->getDataType(), adaptivemedian,
							 pDestAcc->getColumn(), thirdBandDa, curRow,
							 curCol, pDesc->getRowCount(),
							 pDesc->getColumnCount(), size, sizeMax, pProgress,
							 &flag);
			if (flag == 1 && size <= sizeMax)
			{
				// increase window size
				size = size + 2;
				curCol--;
			}
			else
			{
				pDestAcc->nextColumn();
				size = 3;
				flag = 0;
			}
		}
		pDestAcc->nextRow();
	}

	return true;
}
开发者ID:vijeshm,项目名称:Opticks-Photography-Addons,代码行数:62,代码来源:adaptive_meadian.cpp

示例10: pStep

bool pagauss::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   StepResource pStep("Tutorial 5", "app", "5EA0CC75-9E0B-4c3d-BA23-6DB7157BBD54");
   if (pInArgList == NULL || pOutArgList == NULL)
   {
      return false;
   }
   Progress* pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg());
   RasterElement* pCube = pInArgList->getPlugInArgValue<RasterElement>(Executable::DataElementArg());
   if (pCube == NULL)
   {
      std::string msg = "A raster cube must be specified.";
      pStep->finalize(Message::Failure, msg);
      if (pProgress != NULL) 
      {
         pProgress->updateProgress(msg, 0, ERRORS);
      }
      return false;
   }
   RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(pCube->getDataDescriptor());
   VERIFY(pDesc != NULL);
   if (pDesc->getDataType() == INT4SCOMPLEX || pDesc->getDataType() == FLT8COMPLEX)
   {
      std::string msg = "Edge detection cannot be performed on complex types.";
      pStep->finalize(Message::Failure, msg);
      if (pProgress != NULL) 
      {
         pProgress->updateProgress(msg, 0, ERRORS);
      }
      return false;
   }

   


   FactoryResource<DataRequest> pRequest;
   pRequest->setInterleaveFormat(BSQ);
   DataAccessor pSrcAcc = pCube->getDataAccessor(pRequest.release());

   ModelResource<RasterElement> pResultCube(RasterUtilities::createRasterElement(pCube->getName() +
      "_Edge_Detection_Result", pDesc->getRowCount(), pDesc->getColumnCount(), pDesc->getDataType()));
   if (pResultCube.get() == NULL)
   {
      std::string msg = "A raster cube could not be created.";
      pStep->finalize(Message::Failure, msg);
      if (pProgress != NULL) 
      {
         pProgress->updateProgress(msg, 0, ERRORS);
      }
      return false;
   }
   FactoryResource<DataRequest> pResultRequest;
   pResultRequest->setWritable(true);
   DataAccessor pDestAcc = pResultCube->getDataAccessor(pResultRequest.release());
   

   for (long signed int row = 0; row < pDesc->getRowCount(); ++row)
   {
      if (pProgress != NULL)
      {
         pProgress->updateProgress("Calculating result", row * 100 / pDesc->getRowCount(), NORMAL);
      }
      if (isAborted())
      {
         std::string msg = getName() + " has been aborted.";
         pStep->finalize(Message::Abort, msg);
         if (pProgress != NULL)
         {
            pProgress->updateProgress(msg, 0, ABORT);
         }
         return false;
      }
      if (!pDestAcc.isValid())
      {
         std::string msg = "Unable to access the cube data.";
         pStep->finalize(Message::Failure, msg);
         if (pProgress != NULL) 
         {
            pProgress->updateProgress(msg, 0, ERRORS);
         }
         return false;
      }
      for (long signed int col = 0; col < pDesc->getColumnCount(); ++col)
      {
         switchOnEncoding(pDesc->getDataType(), gauss, pDestAcc->getColumn(), pSrcAcc, row, col,
            pDesc->getRowCount(), pDesc->getColumnCount());
         pDestAcc->nextColumn();
      }

      pDestAcc->nextRow();
   }

   

   if (!isBatch())
   {
      Service<DesktopServices> pDesktop;

      SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(pDesktop->createWindow(pResultCube->getName(),
         SPATIAL_DATA_WINDOW));
//.........这里部分代码省略.........
开发者ID:pratikone,项目名称:gsoc2011-opticks,代码行数:101,代码来源:pagauss.cpp

示例11: pStep

bool BandMath::execute(PlugInArgList* pInputArgList, PlugInArgList* pOutputArgList)
{
   StepResource pStep("Start BandMath", "app", "02E18066-1355-4a5f-ABC5-0366D9890C1C");
   mpStep = pStep.get();

   // Initilize variables
   initialize();

   // Get pointers
   // parse arg in list
   if (!parse(pInputArgList, pOutputArgList))
   {
      meGabbiness = ERRORS;
      displayErrorMessage();
      return false;
   }

   // Get important stuff
   pStep->addProperty("Dataset", mpCube->getFilename());

   const RasterDataDescriptor* pDescriptor = dynamic_cast<const RasterDataDescriptor*>(mpCube->getDataDescriptor());
   if (pDescriptor != NULL)
   {
      mCubeRows = pDescriptor->getRowCount();
      mCubeColumns = pDescriptor->getColumnCount();
      mCubeBands = pDescriptor->getBandCount();
   }

   std::string tmpResultName;

   vector<DataElement*> elements = mpDataModel->getElements("RasterElement");

   vector<DataElement*>::iterator iter;
   for (iter = elements.begin(); iter != elements.end(); ++iter)
   {
      RasterElement* pRaster = static_cast<RasterElement*>(*iter);
      if (pRaster != NULL)
      {
         const RasterDataDescriptor* pCurrentDescriptor =
            dynamic_cast<const RasterDataDescriptor*>(pRaster->getDataDescriptor());
         if (pCurrentDescriptor != NULL)
         {
            if ((mCubeRows == static_cast<int>(pCurrentDescriptor->getRowCount())) &&
               (mCubeColumns == static_cast<int>(pCurrentDescriptor->getColumnCount())) &&
               (mCubeBands == static_cast<int>(pCurrentDescriptor->getBandCount())))
            {
               mCubesList.push_back(pRaster);
            }
         }
      }
   }

   char errorVal[80];
   int errorCode = -1;  

   if (mbInteractive)
   {
      QWidget* pParent = mpDesktop->getMainWidget();

      FrmBM frmASIT(pDescriptor, mCubesList, pParent);

      if (frmASIT.exec() == QDialog::Rejected)
      {
         pStep->finalize(Message::Abort);
         return false;
      }

      mExpression = frmASIT.getExpression(true).toStdString();
      mbDegrees = frmASIT.isDegrees();
      mbCubeMath = frmASIT.isMultiCube();
      mbAsLayerOnExistingView = frmASIT.isResultsMatrix();
   }
   else
   {
      mbCubeMath = false;

      //check for cube math
      unsigned int pos = mExpression.find_first_of(string("cC"));
      if ((pos >= 0) && (pos < (mExpression.length() - 1)) && ((mExpression[pos + 1] > '0') &&
                                                              (mExpression[pos + 1] < '9')))
      {
         mbCubeMath = true;
      }
   }
   if (!createReturnValue(mExpression))
   {
      mstrProgressString = "Could not allocate space for results.";
      meGabbiness = ERRORS;
      displayErrorMessage();
      return false;
   }
   {
      StepResource pResultStep("Compute result", "app", "CDCC12AC-32DD-4831-BC6B-225538C92053");
      mpStep = pResultStep.get();
      pResultStep->addProperty("Expression", mExpression);

      FactoryResource<DataRequest> pReturnRequest;
      pReturnRequest->setInterleaveFormat(BIP);
      pReturnRequest->setWritable(true);
      DataAccessor returnDa = mpResultData->getDataAccessor(pReturnRequest.release());
//.........这里部分代码省略.........
开发者ID:Siddharthk,项目名称:opticks,代码行数:101,代码来源:BandMath.cpp

示例12: parseInputArgList

bool NefImporter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
    
   if (pInArgList == NULL || pOutArgList == NULL)
   {
      return false;
   }
   //setting up mpRasterElement
   parseInputArgList(pInArgList);
   RasterElement* pRaster = getRasterElement();
   
   VERIFY(pRaster != NULL);
   RasterDataDescriptor *pDescriptor = dynamic_cast<RasterDataDescriptor*>(pRaster->getDataDescriptor());

   VERIFY(pDescriptor != NULL);
   FileDescriptor *pFileDescriptor = pDescriptor->getFileDescriptor();
   VERIFY(pFileDescriptor != NULL);

   //data accessor
   //RED
   DimensionDescriptor firstBand = pDescriptor->getActiveBand(0);
   FactoryResource<DataRequest> pRequest;
   pRequest->setInterleaveFormat(BSQ);
   pRequest->setBands(firstBand, firstBand);
   pRequest->setWritable(true);
   DataAccessor firstBandDa = pRaster->getDataAccessor(pRequest.release());

   
   //GREEN
   DimensionDescriptor secondBand = pDescriptor->getActiveBand(1);
   FactoryResource<DataRequest> qRequest;
   qRequest->setInterleaveFormat(BSQ);
   qRequest->setBands(secondBand, secondBand);
   qRequest->setWritable(true);
   DataAccessor secondBandDa = pRaster->getDataAccessor(qRequest.release());

   //BLUE
   DimensionDescriptor thirdBand = pDescriptor->getActiveBand(2);
   FactoryResource<DataRequest> rRequest;
   rRequest->setInterleaveFormat(BSQ);
   rRequest->setBands(thirdBand, thirdBand);
   rRequest->setWritable(true);
   DataAccessor thirdBandDa = pRaster->getDataAccessor(rRequest.release());

   

   std::string filename = pRaster->getFilename();
   Progress *pProgress = getProgress();
   
   FactoryResource<Filename> pFilename;
   pFilename->setFullPathAndName(filename);

   LibRaw RawProcessor;
   putenv ((char*)"TZ=UTC"); 

	#define P1  RawProcessor.imgdata.idata
#define S   RawProcessor.imgdata.sizes
#define C   RawProcessor.imgdata.color
#define T   RawProcessor.imgdata.thumbnail
#define P2  RawProcessor.imgdata.other
#define OUT RawProcessor.imgdata.params

   const char *fname=filename.c_str();
    RawProcessor.open_file(fname);

	// Let us unpack the image
        if (RawProcessor.unpack() != LIBRAW_SUCCESS)
   {
      return false;
   }
    
    /*
	unsigned int *r=NULL;
	unsigned int *g=NULL;
	unsigned int *b=NULL;
	unsigned int *h=NULL;
	*/
    unsigned int *zero=0;
	int row=0,col=0,r=0,c=0;
	
		   
		   /*
		   r=(unsigned int*)(&RawProcessor.imgdata.image[i][0]);
           g=(unsigned int*)(&RawProcessor.imgdata.image[i][1]);
           b=(unsigned int*)(&RawProcessor.imgdata.image[i][2]);
           h=(unsigned int*)(&RawProcessor.imgdata.image[i][3]);
		   */
		   //secondBandDa->toPixel(row,col);
		   //thirdBandDa->toPixel(row,col);

		   
		unsigned short *pData=reinterpret_cast<unsigned short*>(pRaster->getRawData());
		if (pData == NULL)
		{
      return NULL;
		}

		memcpy(pData, RawProcessor.imgdata.rawdata.raw_image, sizeof(unsigned short) * RawProcessor.imgdata.sizes.raw_height * RawProcessor.imgdata.sizes.raw_width);


//.........这里部分代码省略.........
开发者ID:pratikone,项目名称:gsoc2011-opticks,代码行数:101,代码来源:NefImporter.cpp

示例13: bilinear_height

double bilinear_height(DataAccessor pSrcAcc, double I, double J)
   {

	   double z1=0,z2=0,z3=0,z4=0;
       pSrcAcc->toPixel(int(J),int(I));
	   VERIFY(pSrcAcc.isValid());
	   z1 = pSrcAcc->getColumnAsDouble();

       pSrcAcc->toPixel(int(J)+1,int(I));
	   VERIFY(pSrcAcc.isValid());
	   z2 = pSrcAcc->getColumnAsDouble();

       pSrcAcc->toPixel(int(J),int(I)+1);
	   VERIFY(pSrcAcc.isValid());
	   z3 = pSrcAcc->getColumnAsDouble();

       pSrcAcc->toPixel(int(J)+1,int(I)+1);
	   VERIFY(pSrcAcc.isValid());
	   z4 = pSrcAcc->getColumnAsDouble();

       double a=0,b=0,c=0,d=0;    

	   d = z1;
	   a = (z2-z1);
	   b = (z3-z1);
	   c = (z4+z1-z2-z3);
	   
	   double H = a*(J-int(J))+b*(I-int(I))+c*(I-int(I))*(J-int(J))+d; 

	   return H;
   }
开发者ID:GSoC-2012-Nascetti,项目名称:SAR_PlugIn,代码行数:31,代码来源:Orthorectification.cpp

示例14: VERIFY

bool ThresholdData::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   VERIFY(pInArgList != NULL);
   StepResource pStep("Execute Wizard Item", "app", "{2501975d-7cd5-49b0-a3e7-49f7106793c0}");
   pStep->addProperty("Item", getName());
   mpStep = pStep.get();

   if (!extractInputArgs(pInArgList))
   {
      return false;
   }

   const RasterDataDescriptor* pDesc = static_cast<const RasterDataDescriptor*>(mpInputElement->getDataDescriptor());
   VERIFY(pDesc);
   DimensionDescriptor band;
   if (mDisplayBandNumber > 0)
   {
      band = pDesc->getOriginalBand(mDisplayBandNumber - 1);
      if (band.isValid() == false)
      {
         reportError("The specified band is invalid.", "{a529538b-5b82-425d-af10-385a2581beec}");
         return false;
      }
   }
   else
   {
      band = pDesc->getActiveBand(mDisplayBandNumber);
   }
   FactoryResource<DataRequest> pReq;
   pReq->setInterleaveFormat(BSQ);
   pReq->setBands(band, band, 1);
   DataAccessor acc = mpInputElement->getDataAccessor(pReq.release());
   if (!acc.isValid())
   {
      reportError("Unable to access data element.", "{b5f1b7dd-7cf7-4cd5-b5bc-7b747d3561b9}");
      return false;
   }

   // If necessary, convert region units
   if (mRegionUnits != RAW_VALUE)
   {
      Statistics* pStatistics = mpInputElement->getStatistics(band);
      if (pStatistics == NULL)
      {
         reportError("Unable to calculate data statistics.", "{61a44ced-a4aa-4423-b379-5783137eb980}");
         return false;
      }
      mFirstThreshold = convertToRawUnits(pStatistics, mRegionUnits, mFirstThreshold);
      mSecondThreshold = convertToRawUnits(pStatistics, mRegionUnits, mSecondThreshold);
   }
   FactoryResource<BitMask> pBitmask;
   for (unsigned int row = 0; row < pDesc->getRowCount(); ++row)
   {
      reportProgress("Thresholding data", 100 * row / pDesc->getRowCount(),
         "{2fc3dbea-1307-471c-bba2-bf86032be518}");
      for (unsigned int col = 0; col < pDesc->getColumnCount(); ++col)
      {
         VERIFY(acc.isValid());
         double val = ModelServices::getDataValue(pDesc->getDataType(), acc->getColumn(), 0);
         switch (mPassArea)
         {
         case UPPER:
            if (val >= mFirstThreshold)
            {
               pBitmask->setPixel(col, row, true);
            }
            break;
         case LOWER:
            if (val <= mFirstThreshold)
            {
               pBitmask->setPixel(col, row, true);
            }
            break;
         case MIDDLE:
            if (val >= mFirstThreshold && val <= mSecondThreshold)
            {
               pBitmask->setPixel(col, row, true);
            }
            break;
         case OUTSIDE:
            if (val <= mFirstThreshold || val >= mSecondThreshold)
            {
               pBitmask->setPixel(col, row, true);
            }
            break;
         default:
            reportError("Unknown or invalid pass area.", "{19c92b3b-52e9-442b-a01f-b545f819f200}");
            return false;
         }
         acc->nextColumn();
      }
      acc->nextRow();
   }
   std::string aoiName = pDesc->getName() + "_aoi";
   ModelResource<AoiElement> pAoi(aoiName, mpInputElement);
   if (pAoi.get() == NULL)
   {
      reportWarning("Overwriting existing AOI.", "{d953a030-dd63-43a1-98db-b0f491dee123}");
      Service<ModelServices>()->destroyElement(
         Service<ModelServices>()->getElement(aoiName, TypeConverter::toString<AoiElement>(), mpInputElement));
//.........这里部分代码省略.........
开发者ID:Tom-VdE,项目名称:opticks,代码行数:101,代码来源:ThresholdData.cpp

示例15: sqrt

void SamThread::ComputeSam(const T* pDummyData)
{
   int reSamBan_index = 0, row_index = 0, col_index = 0;
   float* pResultsData = NULL;
   int oldPercentDone = -1;
   double spectrumMag = 0.0;
   const T* pData=NULL;
   const RasterDataDescriptor* pDescriptor = static_cast<const RasterDataDescriptor*>(
      mInput.mpCube->getDataDescriptor());
   unsigned int numCols = pDescriptor->getColumnCount();
   unsigned int numBands = pDescriptor->getBandCount();
   unsigned int numRows = (mRowRange.mLast - mRowRange.mFirst + 1);

   int numResultsCols = 0;
   //Sets area to apply the SAM algortihm to. Either
   //the entire cube, or a selected ROI.
   if (mInput.mIterCheck.useAllPixels())
   {
      //Total number of Columns in cube.
      numResultsCols = numCols;
   }
   else
   {
      numResultsCols = mInput.mIterCheck.getNumSelectedColumns();
   }

   if (mInput.mpResultsMatrix == NULL)
   {
      return;
   }

   const RasterDataDescriptor* pResultDescriptor = static_cast<const RasterDataDescriptor*>(
      mInput.mpResultsMatrix->getDataDescriptor());
   // Gets results matrix that was initialized in ProcessAll()
   mRowRange.mFirst = std::max(0, mRowRange.mFirst);
   mRowRange.mLast = std::min(mRowRange.mLast, static_cast<int>(pDescriptor->getRowCount()) - 1);
   FactoryResource<DataRequest> pResultRequest;
   pResultRequest->setRows(pResultDescriptor->getActiveRow(mRowRange.mFirst),
      pResultDescriptor->getActiveRow(mRowRange.mLast));
   pResultRequest->setColumns(pResultDescriptor->getActiveColumn(0),
      pResultDescriptor->getActiveColumn(numResultsCols - 1));
   pResultRequest->setWritable(true);
   DataAccessor resultAccessor = mInput.mpResultsMatrix->getDataAccessor(pResultRequest.release());
   if (!resultAccessor.isValid())
   {
      return;
   }

   // Resamples and sets search signature 
   for (reSamBan_index = 0; reSamBan_index < (int) mInput.mResampledBands.size(); ++reSamBan_index)
   {
      spectrumMag += mInput.mSpectrum[reSamBan_index] * mInput.mSpectrum[reSamBan_index];
   }

   spectrumMag = sqrt(spectrumMag);
   int rowOffset = mInput.mIterCheck.getOffset().mY;
   int startRow = (mRowRange.mFirst + rowOffset);
   int stopRow = (mRowRange.mLast + rowOffset);

   int columnOffset = mInput.mIterCheck.getOffset().mX;
   int startColumn = columnOffset;
   int stopColumn = (numResultsCols + columnOffset - 1);

   FactoryResource<DataRequest> pRequest;
   pRequest->setInterleaveFormat(BIP);
   pRequest->setRows(pDescriptor->getActiveRow(startRow), pDescriptor->getActiveRow(stopRow));
   pRequest->setColumns(pDescriptor->getActiveColumn(startColumn), pDescriptor->getActiveColumn(stopColumn));
   DataAccessor accessor = mInput.mpCube->getDataAccessor(pRequest.release());
   if (!accessor.isValid())
   {
      return;
   }

   for (row_index = startRow; row_index <= stopRow; ++row_index)
   {
      int percentDone = mRowRange.computePercent(row_index-rowOffset);
      if (percentDone > oldPercentDone)
      {
         oldPercentDone = percentDone;
         getReporter().reportProgress(getThreadIndex(), percentDone);
      }
      if (mInput.mpAbortFlag != NULL && *mInput.mpAbortFlag)
      {
         break;
      }

      for (col_index = startColumn; col_index <= stopColumn; ++col_index)
      {  
         VERIFYNRV(resultAccessor.isValid());
         VERIFYNRV(accessor.isValid());
         // Pointer to results data
         pResultsData = reinterpret_cast<float*>(resultAccessor->getColumn());
         if (pResultsData == NULL)
         {
            return;
         }
         if (mInput.mIterCheck.getPixel(col_index, row_index))
         {
            //Pointer to cube/sensor data
            pData = reinterpret_cast<T*>(accessor->getColumn());
//.........这里部分代码省略.........
开发者ID:yuguess,项目名称:GSoC,代码行数:101,代码来源:Sam.cpp


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