<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><DIV>Hi,</DIV>
<DIV>We try to compute the image's PSNR(Peak Signal to Noise Ratio) after MedianImageFilter and BilateralImageFilter .In </DIV>
<DIV><SPAN class="highlight" space="" rightZone="0|6" leftZone="0|6">circulation, we wanted to keep the image pointer, but failed.</SPAN></DIV>
<DIV><SPAN class="highlight" space="" rightZone="0|6" leftZone="0|6"></SPAN> </DIV>
<DIV><SPAN class="highlight" space="" rightZone="0|6" leftZone="0|6">OutputImageType* rescaleoutputImage;</SPAN></DIV>
<DIV><SPAN class="highlight" space="" rightZone="0|6" leftZone="0|6">OutputImageType* outputImage;</SPAN></DIV>
<DIV><SPAN class="highlight" space="" rightZone="0|6" leftZone="0|6">for( i=4;i<10;i++){<BR> for( j=4;j<10;j++)<BR> {<BR> radius[0]=i;<BR> radius[1]=j;<BR> ReaderType::Pointer reader = ReaderType::New(); //Instance reader<BR> reader->SetFileName(noisedFile.c_str() );</SPAN></DIV><SPAN class="highlight" space="" rightZone="0|6" leftZone="0|6">
<DIV><BR> mFilterType::Pointer medianFilter = mFilterType::New();//Instance itk::MedianImageFilter<BR> medianFilter->SetRadius(radius);<BR> medianFilter->SetInput( reader->GetOutput() );</DIV>
<DIV> OutputImageType* mediaoutput=medianFilter->GetOutput();</DIV>
<DIV> </DIV>
<DIV> WriterType::Pointer mediawriter= WriterType::New();//Instance writer<BR> mediawriter->SetFileName( "temporaryoutput.tif");<BR> mediawriter->SetInput(mediaoutput);<BR> mediawriter->Update(); //update<BR> </DIV>
<DIV> computePSNR->ComputeMSE(mediaoutput); //<SPAN class="highlight" space="" rightZone="0|15" leftZone="0|15">Custom function to compute PSNR</SPAN><BR> float roundmediaPSNR=computePSNR->PSNR();</DIV>
<DIV><BR> ReaderType::Pointer Bilateralreader = ReaderType::New(); //Instance reader </DIV>
<DIV> Bilateralreader->SetFileName("temporaryoutput.tif");</DIV>
<DIV> </DIV>
<DIV> FilterType::Pointer filter = FilterType::New();//Instance itk::BilateralImageFilter<BR> filter->SetInput(Bilateralreader->GetOutput() );</DIV>
<DIV><BR> const unsigned int Dimension = InputImageType::ImageDimension;//<SPAN class="highlight" space="" rightZone="0|12" leftZone="0|12"> setting p<SPAN class="highlight" space="" rightZone="0|12" leftZone="0|12">arameters for BilateralImageFilter</SPAN></SPAN><BR> double domainSigmas[ Dimension ];<BR> for(unsigned int ii=0; ii<Dimension; ii++)<BR> {<BR> domainSigmas[ii] = i;<BR> }<BR> const double rangeSigma = j;<BR> filter->SetDomainSigma( domainSigmas );<BR> filter->SetRangeSigma( rangeSigma );</DIV>
<DIV><BR> typedef itk::RescaleIntensityImageFilter< <BR> OutputImageType, WriteImageType > RescaleFilterType;<BR> RescaleFilterType::Pointer rescaler = RescaleFilterType::New();<BR> rescaler->SetOutputMinimum( 0 );<BR> rescaler->SetOutputMaximum( 255 );<BR> <BR> rescaler->SetInput( filter->GetOutput() );<BR> rescaleoutputImage=rescaler->GetOutput();<BR> rescaler->Update(); //update<BR> <BR> computePSNR->ComputeMSE(rescaleoutputImage);// computer PSNR after MedianImageFilter and BilateralImageFilter<BR> float roundPSNR=computePSNR->PSNR();<BR> if(roundPSNR>psnr) // if the value of PSNR is g<SPAN class="highlight" space="" rightZone="0|6" leftZone="0|6">reater than last turn </SPAN><BR> {<BR> mediapsnr=roundmediaPSNR;<BR> psnr=roundPSNR;<BR> radiusi=radius[0];<BR> radiusj=radius[1];</DIV>
<DIV> BilateraldomainSigma=domainSigmas[0];<BR> BilateralrangeSigma=rangeSigma;<BR> outputImage=rescaleoutputImage; //keep the image's pointer</DIV>
<DIV> }<BR> }<BR>}//for</DIV>
<DIV><BR> writer = WriterType::New();<BR> writer->SetFileName("outputImage.tif" );<BR> writer->SetInput(outputImage); //outputImage is NULL<BR> writer->Update();</DIV>
<DIV> </DIV>
<DIV>
<DIV id="trans-result-content" lang="EN-US" xml:lang="EN-US">
<P src="这段程序抛出错误"><SPAN space="0| " rightZone="18|6" leftZone="18|6"> </SPAN>If no <SPAN class="highlight" space="" rightZone="0|6" leftZone="0|6">circulation, it work well</SPAN>. Debug it, we found outputImage is NULL in the writer. We were surprised that in each round of <SPAN class="highlight" space="" rightZone="0|6" leftZone="0|6">circulation the pointer(outputImage, which point an image ) is released. How can we keep the image pointer?</SPAN></P><SPAN class="highlight" space="" rightZone="0|6" leftZone="0|6"></SPAN></DIV>
<DIV lang="EN-US" xml:lang="EN-US"><SPAN class="highlight" space="" rightZone="0|6" leftZone="0|6">Thanks.</SPAN></DIV>
<DIV lang="EN-US" xml:lang="EN-US"><SPAN class="highlight" space="" rightZone="0|6" leftZone="0|6">XiongXiang Zhang</SPAN></DIV>
<P lang="EN-US" xml:lang="EN-US" src="这段程序抛出错误"><BR> </P></DIV></SPAN></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>