[Insight-developers] ITK pipeline

wanlin wanlin.zhu at gmail.com
Mon Oct 15 23:20:18 EDT 2012


Try

OutputImageType* rescaleoutputImage;
itk::SmartPointer<OutputImageType> outputImage;


On Tue, Oct 16, 2012 at 10:17 AM, XiongXiang Zhang <zhangxx110 at 126.com>wrote:

> Hi,
> We try to compute the image's PSNR(Peak Signal to Noise Ratio) after
> MedianImageFilter and BilateralImageFilter .In
> circulation, we wanted to keep the image pointer, but failed.
>
> OutputImageType* rescaleoutputImage;
> OutputImageType* outputImage;
> for( i=4;i<10;i++){
>    for( j=4;j<10;j++)
>  {
>     radius[0]=i;
>     radius[1]=j;
>    ReaderType::Pointer reader = ReaderType::New(); //Instance reader
>    reader->SetFileName(noisedFile.c_str() );
>
>   mFilterType::Pointer medianFilter = mFilterType::New();//Instance
> itk::MedianImageFilter
>   medianFilter->SetRadius(radius);
>   medianFilter->SetInput( reader->GetOutput() );
>  OutputImageType* mediaoutput=medianFilter->GetOutput();
>
>      WriterType::Pointer mediawriter= WriterType::New();//Instance writer
>     mediawriter->SetFileName( "temporaryoutput.tif");
>    mediawriter->SetInput(mediaoutput);
>   mediawriter->Update();         //update
>
>   computePSNR->ComputeMSE(mediaoutput);  //Custom function to compute PSNR
>   float roundmediaPSNR=computePSNR->PSNR();
>
>     ReaderType::Pointer Bilateralreader = ReaderType::New(); //Instance
> reader
>   Bilateralreader->SetFileName("temporaryoutput.tif");
>
>    FilterType::Pointer filter = FilterType::New();//Instance
> itk::BilateralImageFilter
>   filter->SetInput(Bilateralreader->GetOutput() );
>
>   const unsigned int Dimension = InputImageType::ImageDimension;//setting parameters
> for BilateralImageFilter
>   double domainSigmas[ Dimension ];
>   for(unsigned int ii=0; ii<Dimension; ii++)
>     {
>       domainSigmas[ii] = i;
>     }
>   const double rangeSigma = j;
>     filter->SetDomainSigma( domainSigmas );
>   filter->SetRangeSigma(  rangeSigma   );
>
>     typedef itk::RescaleIntensityImageFilter<
>                OutputImageType, WriteImageType > RescaleFilterType;
>   RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
>   rescaler->SetOutputMinimum(   0 );
>   rescaler->SetOutputMaximum( 255 );
>
>     rescaler->SetInput( filter->GetOutput() );
>   rescaleoutputImage=rescaler->GetOutput();
>    rescaler->Update();  //update
>
>    computePSNR->ComputeMSE(rescaleoutputImage);// computer PSNR after
> MedianImageFilter and BilateralImageFilter
>   float roundPSNR=computePSNR->PSNR();
>   if(roundPSNR>psnr)  // if the value of PSNR is greater than last turn
>   {
>      mediapsnr=roundmediaPSNR;
>   psnr=roundPSNR;
>      radiusi=radius[0];
>      radiusj=radius[1];
>   BilateraldomainSigma=domainSigmas[0];
>      BilateralrangeSigma=rangeSigma;
>      outputImage=rescaleoutputImage; //keep the image's pointer
>     }
>    }
> }//for
>
>  writer = WriterType::New();
>  writer->SetFileName("outputImage.tif" );
>  writer->SetInput(outputImage); //outputImage is NULL
>  writer->Update();
>
>
>  If no circulation, it work well. Debug it, we found outputImage is NULL
> in the writer. We were surprised that in each round of circulation the
> pointer(outputImage, which point an image ) is released. How can we keep
> the image pointer?
> Thanks.
> XiongXiang Zhang
>
>
>
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20121016/efac8845/attachment.htm>


More information about the Insight-developers mailing list