本文整理汇总了C++中writertype::Pointer::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::Update方法的具体用法?C++ Pointer::Update怎么用?C++ Pointer::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类writertype::Pointer
的用法示例。
在下文中一共展示了Pointer::Update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc,char ** argv){
typedef itk::Image<float,3> ImageType;
typedef itk::Image<float,2> SliceType;
typedef itk::ImageFileReader<ImageType> ReaderType;
typedef itk::ImageFileWriter<SliceType> WriterType;
typedef itk::BoundedReciprocalImageFilter<ImageType,ImageType> BoundedReciprocalType;
BoundedReciprocalType::Pointer boundedReciprocal = BoundedReciprocalType::New();
typedef ttt::AdvectiveDiffusion2DIterationImageFilter<SliceType,SliceType> AdvectionDiffusion2DIterationType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->UpdateOutputInformation();
typedef itk::ExtractImageFilter<ImageType,SliceType> ExtractorType;
ExtractorType::Pointer extractor = ExtractorType::New();
ImageType::RegionType extractionRegion = reader->GetOutput()->GetLargestPossibleRegion();
extractionRegion.SetSize(2,0);
boundedReciprocal->SetInput(reader->GetOutput());
extractor->SetInput(boundedReciprocal->GetOutput());
extractor->SetExtractionRegion(extractionRegion);
extractor->SetDirectionCollapseToIdentity();
AdvectionDiffusion2DIterationType::Pointer advectionDiffusionIteration =AdvectionDiffusion2DIterationType::New();
advectionDiffusionIteration->SetInput(extractor->GetOutput());
advectionDiffusionIteration->SetNumberOfThreads(1.0);
WriterType::Pointer sliceWriter = WriterType::New();
sliceWriter->SetInput(extractor->GetOutput());
sliceWriter->SetFileName(argv[2]);
sliceWriter->Update();
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(argv[3]);
writer->SetInput(advectionDiffusionIteration->GetOutput());
writer->Update();
}
示例2: writeMesh
void writeMesh(MeshType* mesh, const char* filename) {
typedef itk::MeshFileWriter<MeshType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput(mesh);
writer->SetFileName(filename);
writer->Update();
}
示例3: writeBinaryImage
void writeBinaryImage(BinaryImageType* image, const char* filename) {
typedef itk::ImageFileWriter<BinaryImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput(image);
writer->SetFileName(filename);
writer->Update();
}
示例4: saveFile
void saveFile(char* filename, ImageType* image)
{
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(filename);
writer->SetInput(image);
writer->Update();
}
示例5: saveNRRDFile
void NRRDTools::saveNRRDFile(const cleaver::FloatField *field, const std::string &name) {
auto dims = field->dataBounds().size;
ImageType::Pointer img = ImageType::New();
itk::Index<3> start; start.Fill(0);
ImageType::SizeType size;
size[0] = static_cast<size_t>(dims[0]);
size[1] = static_cast<size_t>(dims[1]);
size[2] = static_cast<size_t>(dims[2]);
ImageType::RegionType region(start, size);
img->SetRegions(region);
img->Allocate();
img->FillBuffer(0);
for (size_t i = 0; i < dims[0]; i++) {
for (size_t j = 0; j < dims[1]; j++) {
for (size_t k = 0; k < dims[2]; k++) {
ImageType::IndexType pixelIndex;
pixelIndex[0] = i;
pixelIndex[1] = j;
pixelIndex[2] = k;
auto data = ((cleaver::FloatField*)field)->data();
img->SetPixel(pixelIndex, data[i + size[0] * j + size[0] * size[1] * k]);
}
}
}
WriterType::Pointer write = WriterType::New();
write->SetFileName(name + ((name.find_first_of(".nrrd") == std::string::npos) ? ".nrrd" : ""));
write->SetInput(img);
write->Update();
}
示例6: writeLabelImage
void writeLabelImage( LabeledImageType::Pointer image, const std::string &fname) {
try {
ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();
colormapper->SetInput( image );
colormapper->Update();
RGBImageType::ConstPointer colorImage = colormapper->GetOutput();
colormapper = NULL;
typedef itk::Image< RGBPixelType, 2 > OutputImage2DType;
typedef itk::ImageSeriesWriter< RGBImageType, OutputImage2DType > WriterType;
WriterType::Pointer writer = WriterType::New();
typedef itk::NumericSeriesFileNames NamesGeneratorType;
NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
nameGenerator->SetSeriesFormat( fname.c_str() );
nameGenerator->SetStartIndex( 1 );
nameGenerator->SetEndIndex( colorImage->GetBufferedRegion().GetSize()[2] );
writer->SetFileNames( nameGenerator->GetFileNames() );
writer->SetInput( colorImage );
writer->Update();
} catch( itk::ExceptionObject & exp ) {
std::cerr << "Exception caught !" << std::endl;
std::cerr << exp << std::endl;
}
}
示例7: on_actionSaveSegmentation_triggered
void LidarSegmentationWidget::on_actionSaveSegmentation_triggered()
{
// Ask the user for a filename to save the segment mask image to
QString fileName = QFileDialog::getSaveFileName(this,
"Save Segment Mask Image", ".", "PNG Files (*.png)");
if(fileName.isEmpty())
{
return;
}
// Write the file (object is white)
typedef itk::ImageFileWriter<Mask> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(fileName.toStdString());
writer->SetInput(this->GraphCut.GetSegmentMask());
writer->Update();
/*
// Write the inverted file (object is black)
Mask::Pointer inverted = Mask::New();
Helpers::InvertBinaryImage(this->GraphCut.GetSegmentMask(), inverted);
//typedef itk::ImageFileWriter<ImageAdaptorType> WriterType;
typedef itk::ImageFileWriter<Mask> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(fileName.toStdString());
writer->SetInput(inverted);
writer->Update();
*/
}
示例8: actionSave_Segmentation_triggered
void InnerWidget::actionSave_Segmentation_triggered()
{
// Ask the user for a filename to save the segment mask image to
QString fileName = QFileDialog::getSaveFileName(this,
tr("Save Segment Mask Image"), "/home/doriad", tr("Image Files (*.png *.bmp)"));
/*
// Convert the image from a 1D vector image to an unsigned char image
typedef itk::CastImageFilter< GrayscaleImageType,
itk::Image<itk::CovariantVector<unsigned char, 1>, 2 > > CastFilterType;
CastFilterType::Pointer castFilter = CastFilterType::New();
castFilter->SetInput(this->GraphCut->GetSegmentMask());
typedef itk::NthElementImageAdaptor< itk::Image<itk:: CovariantVector<unsigned char, 1>, 2 >,
unsigned char> ImageAdaptorType;
ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
adaptor->SelectNthElement(0);
adaptor->SetImage(castFilter->GetOutput());
*/
// Write the file
//typedef itk::ImageFileWriter< ImageAdaptorType > WriterType;
typedef itk::ImageFileWriter<Mask> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(fileName.toStdString());
//writer->SetInput(adaptor);
writer->SetInput(this->GraphCut->GetSegmentMask());
writer->Update();
}
示例9: main
int main(int argc, char *argv[])
{
// Verify arguments
if(argc < 6)
{
std::cerr << "Required: outputFilename sizeX sizeY components value" << std::endl;
return EXIT_FAILURE;
}
// Parse arguments
std::string outputFilename = argv[1];
std::stringstream ss;
ss << argv[2] << " " << argv[3] << " " << argv[4];
itk::Size<2> size = {{0,0}};
unsigned int components = 0;
float value = 0.0f;
ss >> size[0] >> size[1] >> components >> value;
// Output arguments
std::cout << "outputFilename " << outputFilename << std::endl;
std::cout << "size " << size << std::endl;
std::cout << "value " << value << std::endl;
ImageType::Pointer image = ImageType::New();
itk::Index<2> index = {{0,0}};
itk::ImageRegion<2> region(index, size);
image->SetRegions(region);
image->SetNumberOfComponentsPerPixel(components);
image->Allocate();
typename itk::ImageRegionIterator<ImageType> imageIterator(image, image->GetLargestPossibleRegion());
ImageType::PixelType pixel;
pixel.SetSize(components);
pixel.Fill(value);
while(!imageIterator.IsAtEnd())
{
imageIterator.Set(pixel);
++imageIterator;
}
// Write the result
typedef itk::ImageFileWriter<ImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(outputFilename);
writer->SetInput(image);
writer->Update();
return EXIT_SUCCESS;
}
示例10: main
int main(int argc, char** argv) {
if(argc != 3){
std::cout << "Usage: Test2DImage inputFilename outputFilename";
return 1;
}
typedef signed int InputPixelType;
const unsigned int Dimension = 2;
typedef itk::Image<InputPixelType, Dimension> InputImageType;
typedef itk::RGBPixel<unsigned char> RGBPixelType;
typedef itk::Image<RGBPixelType, 2> RGBImageType;
typedef itk::ImageFileReader<InputImageType> ReaderType;
typedef itk::ImageFileWriter<RGBImageType> WriterType;
typedef itk::GDCMImageIO ImageIOType;
typedef itk::GradientAnisotropicDiffusionImageFilter<InputImageType,
InputImageType> DiffusionFilterType;
typedef itk::GradientMagnitudeImageFilter<InputImageType, InputImageType>
GradientMagnitudeFilterType;
typedef itk::Functor::ScalarToRGBPixelFunctor<int> ColorMapFunctorType;
typedef itk::UnaryFunctorImageFilter<InputImageType,
RGBImageType, ColorMapFunctorType> ColorMapFilterType;
typedef itk::JPEGImageIO JImageIOType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
ImageIOType::Pointer GDCMImageIO = ImageIOType::New();
JImageIOType::Pointer JPEGImageIO = JImageIOType::New();
ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();
reader->SetFileName(argv[1]);
reader->SetImageIO(GDCMImageIO);
try {
reader->Update();
}
catch (itk::ExceptionObject & e) {
std::cerr << "exception in file reader " << std::endl;
std::cerr << e << std::endl;
return 1;
}
DiffusionFilterType::Pointer diffusion = DiffusionFilterType::New();
diffusion->SetNumberOfIterations(1);
diffusion->SetConductanceParameter(4);
diffusion->SetTimeStep(0.125);
GradientMagnitudeFilterType::Pointer gradient = GradientMagnitudeFilterType::New();
diffusion->SetInput(reader->GetOutput());
gradient->SetInput(diffusion->GetOutput());
gradient->Update();
MyWatershedSegmenter<InputImageType> watershed(gradient->GetOutput());
watershed.buildLowerCompleteImage();
watershed.buildLabeledImage();
colormapper->SetInput(watershed.returnFinalImage());
writer->SetInput(colormapper->GetOutput());
writer->UseInputMetaDataDictionaryOff();
writer->SetImageIO(JPEGImageIO);
writer->SetFileName(argv[2]);
writer->Update();
}
示例11: main
int main( int argc, char * argv[] )
{
if( argc < 7 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << std::endl;
std::cerr << " <InputImage> <OutputImage> <LowerThreshold>";
std::cerr << " <UpperThreshold> <OutsideValue> <InsideValue>"
<< std::endl;
return EXIT_FAILURE;
}
const unsigned int Dimension = 2;
typedef unsigned char PixelType;
const char * InputImage = argv[1];
const char * OutputImage = argv[2];
const PixelType LowerThreshold = static_cast<PixelType>(atoi( argv[3] ) );
const PixelType UpperThreshold = static_cast<PixelType>(atoi( argv[4] ) );
const PixelType OutsideValue = static_cast<PixelType>(atoi( argv[5] ) );
const PixelType InsideValue = static_cast<PixelType>(atoi( argv[6] ) );
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageFileReader< ImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( InputImage );
typedef itk::BinaryThresholdImageFilter< ImageType, ImageType >
FilterType;
FilterType::Pointer filter = FilterType::New();
filter->SetInput( reader->GetOutput() );
filter->SetLowerThreshold( LowerThreshold );
filter->SetUpperThreshold( UpperThreshold );
filter->SetOutsideValue( OutsideValue );
filter->SetInsideValue( InsideValue );
typedef itk::ImageFileWriter< ImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( OutputImage );
writer->SetInput( filter->GetOutput() );
try
{
writer->Update();
}
catch( itk::ExceptionObject & e )
{
std::cerr << "Error: " << e << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
示例12: Combine
void MriWatcherGUI::Combine()
{
QString m_filename = QFileDialog::getSaveFileName(
this,
tr("Save As"),
QDir::currentPath(),
tr("*.gipl *.hdr *.mha *.mhd") );
if( m_filename.isEmpty() )
{
g_combine->setDown(false);
return;
}
if( m_filename.lastIndexOf(".") == -1 )
{
m_filename += ".gipl";
}
int xc; int yc; int zc;
m_imagemanager.GetCrosshair(&xc, &yc, &zc);
ImageType::Pointer m_newimage =
CreateNewImage(m_imagesize[0], m_imagesize[1], m_numberofimages, m_imagespacing[0], m_imagespacing[1],
m_imagespacing[2]);
IteratorType m_itnewimage(m_newimage, m_newimage->GetLargestPossibleRegion() );
m_itnewimage.GoToBegin();
for( int z = 0; z < m_numberofimages; z++ )
{
ImageType::Pointer m_image = m_imageframelist[z]->g_imageframe->GetInputImage2();
IteratorType m_itimage(m_image, m_image->GetLargestPossibleRegion() );
m_itimage.GoToBegin();
for( unsigned int i = 0; i < zc * m_imagesize[0] * m_imagesize[1]; i++ )
{
++m_itimage;
}
for( unsigned int y = 0; y < m_imagesize[0]; y++ )
{
for( unsigned int x = 0; x < m_imagesize[1]; x++ )
{
m_itnewimage.Set(m_itimage.Get() );
++m_itimage;
++m_itnewimage;
}
}
}
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(m_filename.toLatin1().constData() );
writer->SetInput(m_newimage);
writer->Update();
g_combine->setDown(false);
}
示例13: main
int main(int argc, char* argv[])
{
if( argc < 2 )
{
std::cerr<<argv[0]<<" InputImage"<<std::endl;
return EXIT_FAILURE;
}
typedef RGBImageType InputImageType;
typedef RGBImageType2D OutputImageType;
typedef itk::ImageFileReader< InputImageType > ReaderType;
//typedef itk::ImageFileReader< UCharImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( argv[1] );
std::cout<<argv[1]<<std::endl;
try
{
reader->Update();
}
catch( itk::ExceptionObject & excep )
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
}
InputImageType::Pointer in = reader->GetOutput();
Focus *f = new Focus( in );
f->SetRadius(10);
//std::vector<float> vars = f->FindVariance(1.93,4.57,300);
f->MakeVarianceImage();
//OutputImageType::Pointer p = f->MakeProjection();
OutputImageType::Pointer p = f->MakeProjectionColor();
delete f;
typedef itk::ImageFileWriter< OutputImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( "best.tif" );
writer->SetInput( p );
try
{
writer->Update();
}
catch( itk::ExceptionObject & excep )
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
}
std::cerr << "PRESS ENTER TO EXIT\n";
getchar();
}
示例14: main
int main (int argc, char *argv[])
{
// Verify arguments
if(argc != 3)
{
std::cerr << "Required arguments: InputFileName OutputFileName" << std::endl;
return EXIT_FAILURE;
}
// Parse arguments
std::string inputFileName = argv[1];
std::string outputFileName = argv[2];
// Output arguments
std::cout << "Input image: " << inputFileName << std::endl;
std::cout << "Output image: " << outputFileName << std::endl;
//typedef itk::Image<unsigned char, 2> ImageType;
typedef itk::RGBPixel<float> RGBFloatPixelType; // We must use float pixels so that the averaging operation does not overflow
typedef itk::Image<RGBFloatPixelType> RGBFloatImageType;
typedef itk::ImageFileReader<RGBFloatImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(inputFileName);
reader->Update();
SmallHoleFiller<RGBFloatImageType> smallHoleFiller;
smallHoleFiller.SetImage(reader->GetOutput());
RGBFloatImageType::PixelType green;
green.SetRed(0);
green.SetGreen(255);
green.SetBlue(0);
smallHoleFiller.SetHolePixel(green);
smallHoleFiller.GenerateMaskFromImage();
smallHoleFiller.Fill();
typedef itk::RGBPixel<unsigned char> RGBUCharPixelType;
typedef itk::Image<RGBUCharPixelType> RGBUCharImageType;
typedef itk::CastImageFilter<RGBFloatImageType, RGBUCharImageType> CastFilterType;
CastFilterType::Pointer castFilter = CastFilterType::New();
castFilter->SetInput(smallHoleFiller.GetOutput());
castFilter->Update();
typedef itk::ImageFileWriter< RGBUCharImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(outputFileName);
writer->SetInput(castFilter->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}
示例15: writeSeries
// ------------------------------------------------------------------------
void DicomParser::writeSeries(const DicomSeries &series, const QString &outputFolder)
{
// create the series name
QString name = QString::fromStdString(series.description);
name.replace(" ","_");
name += "_" + QString::number(series.images.front().seriesNumber);
name += ".nrrd";
QDir path(outputFolder);
QString fullPath = path.absoluteFilePath(name);
std::vector<DicomImage> images = series.images;
std::sort(images.begin(), images.end());
// write and build the output images
typedef itk::Image<unsigned short, 3> ImageType;
typedef itk::Image<unsigned short, 4> OutputImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
typedef itk::JoinSeriesImageFilter<ImageType, OutputImageType> JoinerType;
JoinerType::Pointer joiner = JoinerType::New();
ImageType::Pointer orig;
for(unsigned int i = 0; i < images.size(); i++)
{
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(images[i].filename);
std::cout << images[i].filename << std::endl;
reader->SetImageIO(itk::GDCMImageIO::New());
reader->Update();
ImageType::Pointer im = reader->GetOutput();
if(i == 0) orig = im;
im->SetOrigin(orig->GetOrigin());
im->SetDirection(orig->GetDirection());
im->SetSpacing(orig->GetSpacing());
joiner->SetInput(i, reader->GetOutput());
}
std::cout << joiner->GetOutput()->GetDirection() << std::endl;
typedef itk::ImageFileWriter<OutputImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput(joiner->GetOutput());
writer->SetFileName(fullPath.toStdString());
writer->SetImageIO(itk::NrrdImageIO::New());
writer->Update();
}