void QAngioSubstractionExtension::setInput(Volume *input)
{
    m_mainVolume = input;

    //Desactivem la sincronització perquè si no quan es canvia l'input no funciona correctament
    m_2DView_1->enableSynchronization(false);
    m_2DView_2->enableSynchronization(false);

    //eliminem l'anterior m_differenceVolume si n'hi ha
    if(m_differenceVolume){
        delete m_differenceVolume;
        m_differenceVolume = 0;
    }


    //Compute the new difference Volume
    m_2DView_1->getViewer()->setInput(m_mainVolume);
    m_imageSelectorSpinBox->setMinimum(1);
    m_imageSelectorSpinBox->setMaximum(m_mainVolume->getDimensions()[2]);
    m_imageSelectorSpinBox->setValue(1);

    computeDifferenceImage(m_imageSelectorSpinBox->value());

    //Només actualitzem l'1 perquè el 2 ja es fa en l'acció computeDifferenceImage
    //Això es fa així perquè l'acció està lligada a un connect
    m_2DView_1->getViewer()->render();

    m_2DView_1->enableSynchronization(true);
    m_2DView_2->enableSynchronization(true);

    m_2DView_2->getViewer()->disableContextMenu();
}
예제 #2
0
int 
main(int argc, char *argv[]) 
{
    try
    {
	    TCLAP::CmdLine cmd("Process Stack of Particle Images", ' ',"100125");
        TCLAP::ValueArg<unsigned int> oMaxSlices("s", "slices", "Limit the number of slices processed", 
                                                 false, std::numeric_limits<unsigned int>::max(), "int");
        cmd.add(oMaxSlices);
        TCLAP::ValueArg<unsigned int> oMaxDelta("m", "delta", "Maximum timestep for difference images", 
                                                 false, std::numeric_limits<unsigned int>::max(), "int");
        cmd.add(oMaxDelta);
        TCLAP::ValueArg<unsigned int> oDeltaInc("i", "increment", "Timestep increment", 
                                                 false, 1, "int");
        cmd.add(oDeltaInc);
        
        TCLAP::UnlabeledValueArg<std::string>  oFileStem("filestem", "Multi-page TIFF Image is filestem.tif", true, "", "filestem");
        cmd.add(oFileStem);
        cmd.parse(argc, argv);

	    npp::StopWatch oStopWatch;
	    oStopWatch.start();
	    
	    // This block is here so the destructors of the 
	    // FreeImageStack objects get called which triggers the saving
	    // of the output data.
	    {
            FreeImageStack oStack(oFileStem.getValue());
            unsigned int nSlices   = std::min<unsigned int>(oMaxSlices.getValue(), oStack.slices());
            unsigned int nMaxDelta = std::min<unsigned int>(oMaxDelta.getValue(), nSlices);
            
                    // Allocate a "fourier-image stack" to receive the fourier transformed images
            NppiSize oResultSizeROI = {oStack.width()/2 + 1, oStack.height()/2 + 1};
            
            FourierImageStack oFourierImages(nSlices, oResultSizeROI.width, oResultSizeROI.height);

            transformStack(oStack, oFourierImages);
            
            FreeImageStack oResultStack(oFileStem.getValue() + "_ConDDM", oResultSizeROI.width, oResultSizeROI.height);
            npp::ImageNPP_32f_C1 oDifferenceImage(oResultSizeROI.width, oResultSizeROI.height);
            for (unsigned int iDelta = 1; iDelta < nMaxDelta; iDelta += oDeltaInc.getValue())
            {
                computeDifferenceImage(oFourierImages, iDelta, oDifferenceImage);
                oResultStack.appendImage(oDifferenceImage);
            }
        } // ending block before we stop the stop watch to complete data writing
        
        oStopWatch.stop();
        std::cout << "Elapsed time: " << oStopWatch.elapsed() / 1000 << " s" << std::endl;
    }
    catch (npp::Exception & rException)
    {
        std::cerr << "Program error! The following exception occurred: \n";
        std::cerr << rException;
        std::cerr << "\nAborting." << std::endl;
        
        return -1;
    }
    catch (...)
    {
        std::cerr << "Program error! An unknow type of exception occurred. \n";
        std::cerr << "Aborting." << std::endl;
        
        return -1;
    }
    
    return 0;
}