double rspfBandMergeSource::getMaxPixelValue(rspf_uint32 band)const { rspf_uint32 currentBandCount = 0; rspf_uint32 idx = 0; rspf_uint32 maxBands = getNumberOfOutputBands(); if(!maxBands) return 0.0; while((currentBandCount < maxBands)&& (idx < getNumberOfInputs())) { rspfImageSource* temp = PTR_CAST(rspfImageSource, getInput(idx)); if(temp) { rspf_uint32 previousCount = currentBandCount; currentBandCount += temp->getNumberOfOutputBands(); if(band < currentBandCount) { return temp->getMaxPixelValue(band - previousCount); } } ++idx; } return rspf::nan(); }
//***************************************************************************** // PRIVATE METHOD: ossimAtbController::initializeRemappers() // //***************************************************************************** void ossimAtbController::initializeRemappers() { static const char MODULE[] = "ossimAtbController::initializeRemappers()"; if (traceExec()) CLOG << "entering..." << endl; int num_images = getNumberOfInputs(); //*** // Fetch the overall mosaic bounding rect: //*** ossimGridRemapSource* remapper = PTR_CAST(ossimGridRemapSource, getInput(0)); theBoundingRect = remapper->getBoundingRect(); for (int src=1; src<num_images; src++) { theBoundingRect = theBoundingRect.combine(remapper->getBoundingRect()); } //*** // Loop over each contribution image source chain to fetch each image // bounding rect: //*** double dx_ul, dy_ul, dx_lr, dy_lr; double grid_ul_x, grid_ul_y, grid_lr_x, grid_lr_y; for (int src=0; src<num_images; src++) { remapper = PTR_CAST(ossimGridRemapSource, getInput(src)); ossimDrect image_rect (remapper->getBoundingRect()); //*** // Arrive at the number of grid posts from mosaic origin to image's grid // UL and LR corners: //*** dx_ul = (image_rect.ul().x - theBoundingRect.ul().x)/theGridSpacing.x; dy_ul = (image_rect.ul().y - theBoundingRect.ul().y)/theGridSpacing.y; dx_lr = (image_rect.lr().x - theBoundingRect.lr().x)/theGridSpacing.x; dy_lr = (image_rect.lr().y - theBoundingRect.lr().y)/theGridSpacing.y; //*** // Establish the view coordinates for the adjusted image grid: //*** grid_ul_x = theBoundingRect.ul().x + ceil(dx_ul)*theGridSpacing.x; grid_ul_y = theBoundingRect.ul().y + ceil(dy_ul)*theGridSpacing.y; grid_lr_x = theBoundingRect.lr().x + floor(dx_lr)*theGridSpacing.x; grid_lr_y = theBoundingRect.lr().y + floor(dy_lr)*theGridSpacing.y; //*** // Have the remapper initialize a new grid with the given rectangle and // spacing: //*** ossimDrect grid_rect (grid_ul_x, grid_ul_y, grid_lr_x, grid_lr_y); remapper->initialize(grid_rect, theGridSpacing); } if (traceExec()) CLOG << "returning..." << endl; return; }
void ossimFeatherMosaic::initialize() { ossimImageMosaic::initialize(); allocate(); if(theTile.valid()) { theAlphaSum = new ossimImageData(this, OSSIM_FLOAT, 1, theTile->getWidth(), theTile->getHeight()); theResult = new ossimImageData(this, OSSIM_FLOAT, theLargestNumberOfInputBands, theTile->getWidth(), theTile->getHeight()); theAlphaSum->initialize(); theResult->initialize(); } std::vector<ossimIpt> validVertices; if(!getNumberOfInputs()) return; if(theInputFeatherInformation) { delete [] theInputFeatherInformation; theInputFeatherInformation = NULL; } theFeatherInfoSize = getNumberOfInputs(); theInputFeatherInformation = new ossimFeatherInputInformation[theFeatherInfoSize]; for(long index = 0; index < theFeatherInfoSize; ++ index) { validVertices.clear(); ossimImageSource* temp = PTR_CAST(ossimImageSource, getInput(index)); if(temp) { temp->getValidImageVertices(validVertices, OSSIM_CLOCKWISE_ORDER); theInputFeatherInformation[index].setVertexList(validVertices); } } }
//***************************************************************************** // METHOD: ossimAtbController::unlockImage() // // Unlocks a particular source for allowing its adjustment. // //***************************************************************************** bool ossimAtbController::unlockImage(unsigned int index) { if (index >= getNumberOfInputs()) return false; ossimGridRemapSource* remapper = PTR_CAST(ossimGridRemapSource, getInput(index)); if (remapper) remapper->lock(); return true; }
//***************************************************************************** // METHOD: ossimAtbController::disableImage() // // Disable an image in the mosaic from the tonal balancing process. // //***************************************************************************** bool ossimAtbController::disableImage(unsigned int index) { if (index >= getNumberOfInputs()) return false; ossimSource* remapper = PTR_CAST(ossimSource, getInput(index)); if (remapper) remapper->disableSource(); return true; }
void rspfTwoColorView::initialize() { rspfImageCombiner::initialize(); m_newInput = 0; m_oldInput = 0; m_twoColorTile = 0; m_nativeFlag = false; m_byPassFlag = false; if(getNumberOfInputs() < 2) { m_byPassFlag = true; } else { m_oldInput = dynamic_cast<rspfImageSource*>( getInput(0) ); m_newInput = dynamic_cast<rspfImageSource*>( getInput(1) ); //--- // Range check band selection. This can be set from setBandIndexMapping method which // does no error checking because inputs may not be set. //---- if ( m_oldInput.valid() ) { if ( m_oldInputBandIndex >= m_oldInput->getNumberOfOutputBands() ) { m_oldInputBandIndex = 0; } } if ( m_newInput.valid() ) { if ( m_newInputBandIndex >= m_newInput->getNumberOfOutputBands() ) { m_newInputBandIndex = 0; } } if(!m_newInput||!m_oldInput) { m_byPassFlag = true; } else { if((m_newInput->getOutputScalarType() == RSPF_UINT8)&& (m_oldInput->getOutputScalarType() == RSPF_UINT8)) { m_nativeFlag = true; } } } }
void DspNode::stop() { m_running = false; release(); for(ulong i = 0; i < getNumberOfInputs(); i++) { m_inputs[i]->clear(); } for(ulong i = 0; i < getNumberOfOutputs(); i++) { m_outputs[i]->clear(); } }
bool rspfHistogramWriter::loadState(const rspfKeywordlist& kwl, const char* prefix) { bool result = rspfOutputSource::loadState(kwl, prefix); if(result) { if(!getNumberOfInputs()) { setNumberOfInputs(1); } } return result; }
void DspNode::start() throw(DspError&) { sDspChain chain = getChain(); if(chain) { if(m_running) { stop(); } m_samplerate = chain->getSampleRate(); m_vectorsize = chain->getVectorSize(); prepare(); if(m_running) { for(ulong i = 0; i < getNumberOfInputs(); i++) { try { m_inputs[i]->start(shared_from_this()); } catch(DspError& e) { m_running = false; throw e; } m_sample_ins[i] = m_inputs[i]->getVector(); } for(ulong i = 0; i < getNumberOfOutputs(); i++) { try { m_outputs[i]->start(shared_from_this()); } catch(DspError& e) { m_running = false; throw e; } m_sample_outs[i] = m_outputs[i]->getVector(); } } } }
bool ossimBumpShadeTileSource::loadState(const ossimKeywordlist& kwl, const char* prefix) { const char* elevationAngle = kwl.find(prefix, ossimKeywordNames::ELEVATION_ANGLE_KW); const char* azimuthAngle = kwl.find(prefix, ossimKeywordNames::AZIMUTH_ANGLE_KW); if(elevationAngle) { m_lightSourceElevationAngle = ossimString(elevationAngle).toDouble(); } if(azimuthAngle) { m_lightSourceAzimuthAngle = ossimString(azimuthAngle).toDouble(); } const char* lookup = kwl.find(prefix, COLOR_RED_KW); if (lookup) { m_r = ossimString(lookup).toUInt8(); } lookup = kwl.find(prefix, COLOR_GREEN_KW); if (lookup) { m_g = ossimString(lookup).toUInt8(); } lookup = kwl.find(prefix, COLOR_BLUE_KW); if (lookup) { m_b = ossimString(lookup).toUInt8(); } computeLightDirection(); bool result = ossimImageSource::loadState(kwl, prefix); theInputListIsFixedFlag = true; theOutputListIsFixedFlag = false; if(!getNumberOfInputs()) setNumberOfInputs(2); return result; }
DspNode::DspNode(sDspChain chain) noexcept : m_chain(chain), m_nins(0), m_sample_ins(nullptr), m_nouts(0), m_sample_outs(nullptr), m_samplerate(0), m_vectorsize(0), m_inplace(true), m_running(false) { for(ulong i = 0; i < getNumberOfInputs(); i++) { m_inputs.push_back(make_shared<DspInput>(i)); } for(ulong i = 0; i < getNumberOfOutputs(); i++) { m_outputs.push_back(make_shared<DspOutput>(i)); } }
rspf_uint32 rspfBandMergeSource::computeNumberOfInputBands()const { rspf_uint32 result = 0; rspf_uint32 size = getNumberOfInputs(); for(rspf_uint32 index = 0; index < size; ++index) { rspfImageSource* temp = PTR_CAST(rspfImageSource, getInput(index)); if(temp) { if(temp->getNumberOfOutputBands() == 0) { ++result; } else { result += temp->getNumberOfOutputBands(); } } } return result; }
ossimRefPtr<ossimImageData> ossimFeatherMosaic::getTile(const ossimIrect& tileRect, ossim_uint32 resLevel) { long w = tileRect.width(); long h = tileRect.height(); ossimIpt origin = tileRect.ul(); if(!isSourceEnabled()) { return ossimImageMosaic::getTile(tileRect, resLevel); } if(!theTile||!theAlphaSum||!theResult||!theInputFeatherInformation) { initialize(); if(!theTile||!theAlphaSum||!theResult||!theInputFeatherInformation) { return ossimImageMosaic::getTile(tileRect, resLevel); } } ossim_uint32 size = getNumberOfInputs(); theAlphaSum->setImageRectangle(tileRect); theResult->setImageRectangle(tileRect); if(size == 0) { return ossimRefPtr<ossimImageData>(); } if(size == 1) { return ossimImageMosaic::getTile(tileRect, resLevel); } long tileW = theTile->getWidth(); long tileH = theTile->getHeight(); if((w != tileW)|| (h != tileH)) { theTile->setWidth(w); theTile->setHeight(h); if((w*h)!=(tileW*tileH)) { theTile->initialize(); } } theTile->setOrigin(origin); theTile->makeBlank(); switch(theTile->getScalarType()) { case OSSIM_UCHAR: { return combine(static_cast<ossim_uint8>(0), tileRect, resLevel); } case OSSIM_USHORT16: case OSSIM_USHORT11: { return combine(static_cast<ossim_uint16>(0), tileRect, resLevel); } case OSSIM_SSHORT16: { return combine(static_cast<ossim_sint16>(0), tileRect, resLevel); } case OSSIM_DOUBLE: case OSSIM_NORMALIZED_DOUBLE: { return combine(static_cast<double>(0), tileRect, resLevel); } case OSSIM_FLOAT: case OSSIM_NORMALIZED_FLOAT: { return combine(static_cast<float>(0), tileRect, resLevel); } case OSSIM_SCALAR_UNKNOWN: default: { ossimNotify(ossimNotifyLevel_WARN) << "ossimFeatherMosaic::getTile: error, unknown scalar type!!!" << std::endl; } } return ossimRefPtr<ossimImageData>(); }
bool GenericVolumeDisplayUnitHandler::hasInput() const { return getNumberOfInputs() > 0; }
rspfRefPtr<rspfImageData> rspfBandMergeSource::getTile(const rspfIrect& tileRect, rspf_uint32 resLevel) { rspf_uint32 layerIdx = 0; if( ( getNumberOfInputs() == 1) || !isSourceEnabled() ) { return getNextTile(layerIdx, 0, tileRect, resLevel); } // test if initialized if(!theTile.get()) { allocate(); } if(!theTile.get()) { return getNextTile(layerIdx, 0, tileRect, resLevel); } long w = tileRect.width(); long h = tileRect.height(); long tileW = theTile->getWidth(); long tileH = theTile->getHeight(); if((w != tileW)|| (h != tileH)) { theTile->setWidth(w); theTile->setHeight(h); if((w*h)!=(tileW*tileH)) { theTile->initialize(); } else { theTile->makeBlank(); } } else { theTile->makeBlank(); } theTile->setOrigin(tileRect.ul()); rspf_uint32 currentBand = 0; rspf_uint32 maxBands = theTile->getNumberOfBands(); rspf_uint32 inputIdx = 0; for(inputIdx = 0; inputIdx < getNumberOfInputs(); ++inputIdx) { rspfImageSource* input = PTR_CAST(rspfImageSource, getInput(inputIdx)); rspfRefPtr<rspfImageData> currentTile = 0; if(input) { currentTile = input->getTile(tileRect, resLevel); } else { currentTile = 0; } rspf_uint32 maxInputBands = 0; if(!currentTile.get()) { maxInputBands = 1; } else if(currentTile->getNumberOfBands() == 0) { maxInputBands = 1; } else { maxInputBands = currentTile->getNumberOfBands(); } for(rspf_uint32 band = 0; ( (band < maxInputBands) && (currentBand < maxBands)); ++band) { // clear the band with the actual NULL theTile->fill(currentBand, theTile->getNullPix(band)); if(currentTile.valid()) { if((currentTile->getDataObjectStatus() != RSPF_NULL) && (currentTile->getDataObjectStatus() != RSPF_EMPTY)) { memmove(theTile->getBuf(currentBand), currentTile->getBuf(band), currentTile->getSizePerBandInBytes()); } } ++currentBand; } } theTile->validate(); return theTile; }
//***************************************************************************** // METHOD: ossimAtbController::execute() // //***************************************************************************** bool ossimAtbController::execute() { static const char MODULE[] = "ossimAtbController::execute()"; if (traceExec()) CLOG << "entering..." << endl; setPercentComplete(0.0); ossimGridRemapSource* source; //*** // First verify that all objects needed are initialized: //*** int num_images = getNumberOfInputs(); if ((!theGridRemapEngine) || (num_images < 2)) { CLOG << "WARNING: execute method was called but the controller has not " << "been properly initialized. Ignoring request..." << endl; if (traceExec()) CLOG << "returning..." << endl; return false; } //*** // establish the remap grids: //*** initializeRemappers(); setPercentComplete(10.0); //*** // Establish grid of matchpoints: //*** int numPoints = 0; ossimDpt mp_view_pt; theMatchPoints.clear(); for (mp_view_pt.line = theBoundingRect.ul().line; mp_view_pt.line <= theBoundingRect.lr().line; mp_view_pt.line += theGridSpacing.line) { for (mp_view_pt.samp = theBoundingRect.ul().samp; mp_view_pt.samp <= theBoundingRect.lr().samp; mp_view_pt.samp += theGridSpacing.samp) { ossimAtbMatchPoint* mp = new ossimAtbMatchPoint(mp_view_pt, theGridRemapEngine); theMatchPoints.push_back(mp); numPoints++; } } //*** // Loop over each matchpoint to determine which images contribute statistics: //*** setPercentComplete(20.0); for (int mp=0; mp<numPoints; mp++) { ossimDpt view_point (theMatchPoints[mp]->viewPoint()); //*** // Loop over each image source to check if point lies inside its bounding // rectangle, and add its contribution to the matchpoint's collection: //*** for (int src=0; src<num_images; src++) { source = PTR_CAST(ossimGridRemapSource, getInput(src)); if (source) { ossimDrect image_rect (source->getBoundingRect()); if (image_rect.pointWithin(view_point)) theMatchPoints[mp]->addImage(source); } } setPercentComplete(20.0 + 50.0*(mp/numPoints)); } //*** // All contributors have been included in all matchpoints' collections. // Compute the target pixel value for each matchpoint and communicate it // to the corresponding remappers: //*** for (int mp=0; mp<numPoints; mp++) { setPercentComplete(70.0 + 30.0*(mp/numPoints)); theMatchPoints[mp]->assignRemapValues(); } //*** // Finally, enable the remappers: //*** for (int src=0; src<num_images; src++) { source = PTR_CAST(ossimGridRemapSource, getInput(src)); if (source) source->enableSource(); } setPercentComplete(100.0); if (traceExec()) CLOG << "returning..." << endl; return true; }
ossimRefPtr<ossimImageData> ossimBlendMosaic::getTile( const ossimIrect& tileRect, ossim_uint32 resLevel) { // ossimIpt origin = tileRect.ul(); if(!isSourceEnabled()) { return ossimImageMosaic::getTile(tileRect, resLevel); } ossim_uint32 size = getNumberOfInputs(); if(!theTile.get()) { // try to initialize initialize(); // if we still don't have a buffer // then we will leave if(!theTile.get()) { return theTile; } } if(size == 0) { return ossimRefPtr<ossimImageData>(); } if(size == 1) { return ossimImageMosaic::getTile(tileRect, resLevel); } theTile->setImageRectangle(tileRect); theTile->makeBlank(); if(theNormResult.valid()) { theNormResult->setImageRectangle(tileRect); theNormResult->makeBlank(); } switch(theTile->getScalarType()) { case OSSIM_UINT8: { if(!hasDifferentInputs()) { return combine(static_cast<ossim_uint8>(0), tileRect, resLevel); } else { return combineNorm(static_cast<ossim_uint8>(0), tileRect, resLevel); } } case OSSIM_SINT8: { if(!hasDifferentInputs()) { return combine(static_cast<ossim_sint8>(0), tileRect, resLevel); } else { return combineNorm(static_cast<ossim_sint8>(0), tileRect, resLevel); } } case OSSIM_FLOAT32: case OSSIM_NORMALIZED_FLOAT: { if(!hasDifferentInputs()) { return combine(static_cast<float>(0), tileRect, resLevel); } else { return combineNorm(static_cast<float>(0), tileRect, resLevel); } } case OSSIM_UINT16: case OSSIM_USHORT11: { if(!hasDifferentInputs()) { return combine(static_cast<ossim_uint16>(0), tileRect, resLevel); } else { return combineNorm(static_cast<ossim_uint16>(0), tileRect, resLevel); } } case OSSIM_SINT16: { if(!hasDifferentInputs()) { return combine(static_cast<ossim_sint16>(0), tileRect, resLevel); } else { return combineNorm(static_cast<ossim_sint16>(0), tileRect, resLevel); } } case OSSIM_SINT32: { if(!hasDifferentInputs()) { return combine(static_cast<ossim_sint32>(0), tileRect, resLevel); } else { return combineNorm(static_cast<ossim_sint32>(0), tileRect, resLevel); } } case OSSIM_UINT32: { if(!hasDifferentInputs()) { return combine(static_cast<ossim_uint32>(0), tileRect, resLevel); } else { return combineNorm(static_cast<ossim_uint32>(0), tileRect, resLevel); } } case OSSIM_FLOAT64: case OSSIM_NORMALIZED_DOUBLE: { if(!hasDifferentInputs()) { return combine(static_cast<double>(0), tileRect, resLevel); } else { return combineNorm(static_cast<double>(0), tileRect, resLevel); } } case OSSIM_SCALAR_UNKNOWN: default: { ossimNotify(ossimNotifyLevel_NOTICE) << "ossimBlendMosaic::getTile NOTICE:\n" << "Scalar type = " << theTile->getScalarType() << " Not supported by ossimImageMosaic" << endl; } } return ossimRefPtr<ossimImageData>(); }