예제 #1
0
bool SmoothingImageFilter::execute()
{
	ImagePtr input = this->getCopiedInputImage();
	if (!input)
		return false;

	DoublePropertyPtr sigma = this->getSigma(mCopiedOptions);

	itkImageType::ConstPointer itkImage = AlgorithmHelper::getITKfromSSCImage(input);

	typedef itk::SmoothingRecursiveGaussianImageFilter<itkImageType, itkImageType> smoothingFilterType;
	smoothingFilterType::Pointer smoohingFilter = smoothingFilterType::New();
	smoohingFilter->SetSigma(sigma->getValue());
	smoohingFilter->SetInput(itkImage);
	smoohingFilter->Update();
	itkImage = smoohingFilter->GetOutput();

	//Convert ITK to VTK
	itkToVtkFilterType::Pointer itkToVtkFilter = itkToVtkFilterType::New();
	itkToVtkFilter->SetInput(itkImage);
	itkToVtkFilter->Update();

	vtkImageDataPtr rawResult = vtkImageDataPtr::New();
	rawResult->DeepCopy(itkToVtkFilter->GetOutput());
	// TODO: possible memory problem here - check debug mem system of itk/vtk

	mRawResult =  rawResult;
	return true;
}
예제 #2
0
void FilterImpl::updateThresholdFromImageChange(QString uid, DoublePropertyPtr threshold)
{
	ImagePtr image = mServices->patient()->getData<Image>(uid);
	if(!image)
		return;
	threshold->setValueRange(DoubleRange(image->getMin(), image->getMax(), 1));
	int oldLower = threshold->getValue();
	// avoid reset if old value is still within range,
	// but reset anyway if old val is 0..1, this can indicate old image was binary.
	if ((image->getMin() > oldLower )||( oldLower > image->getMax() )||( oldLower<=1 ))
	{
		int initLower = ::ceil(double(image->getMin()) + double(image->getRange())/10); // round up
		threshold->setValue(initLower);
	}
//	std::cout << "FilterImpl::imageChangedSlot " << image->getMin() << " "  << image->getMax() << std::endl;
//	std::cout << "            imageChangedSlot() " << threshold->getValue() << std::endl;
}