Exemple #1
0
double Cell::GetVesselnessValue(const GradientVectorType & grad_Dx_vector, const GradientVectorType & grad_Dy_vector, const GradientVectorType & grad_Dz_vector)
{
	double Dxx = grad_Dx_vector[0];
	double Dxy = grad_Dx_vector[1];
	double Dxz = grad_Dx_vector[2];
	double Dyx = grad_Dy_vector[0];
	double Dyy = grad_Dy_vector[1];
	double Dyz = grad_Dy_vector[2];
	double Dzx = grad_Dz_vector[0];
	double Dzy = grad_Dz_vector[1];
	double Dzz = grad_Dz_vector[2];

	double grad_GVF_matrix[3][3];
	grad_GVF_matrix[0][0] = Dxx;
	grad_GVF_matrix[0][1] = Dxy;
	grad_GVF_matrix[0][2] = Dxz;
	grad_GVF_matrix[1][0] = Dyx;
	grad_GVF_matrix[1][1] = Dyy;
	grad_GVF_matrix[1][2] = Dyz;
	grad_GVF_matrix[2][0] = Dzx;
	grad_GVF_matrix[2][1] = Dzy;
	grad_GVF_matrix[2][2] = Dzz;

	double eigenvalues[3];
	double eigenvectors[3][3];

	EigenAnalysis::eigen_decomposition(grad_GVF_matrix, eigenvectors, eigenvalues);

	double Lambda1 = eigenvalues[0];
	double Lambda2 = eigenvalues[1];
	double Lambda3 = eigenvalues[2];

	if ( Lambda2 >= 0.0 || Lambda3 > 0.0 )
	{
		return 0.0;
	}
	else
	{
		static const double FrangiAlpha = 0.5;
		static const double FrangiBeta = 0.5;
		static const double FrangiC = 100.0;

		const double A = 2 * pow(FrangiAlpha,2);
		const double B = 2 * pow(FrangiBeta,2);
		const double C = 2 * pow(FrangiC,2);

		const double Ra  = Lambda2 / Lambda3; 
		const double Rb  = Lambda1 / vcl_sqrt ( vnl_math_abs( Lambda2 * Lambda3 )); 
		const double S  = vcl_sqrt( pow(Lambda1,2) + pow(Lambda2,2) + pow(Lambda3,2));

		const double vesMeasure_1  = ( 1 - vcl_exp(-1.0*(( vnl_math_sqr( Ra ) ) / ( A ))) );
		const double vesMeasure_2  = vcl_exp ( -1.0 * ((vnl_math_sqr( Rb )) /  ( B )));
		const double vesMeasure_3  = ( 1 - vcl_exp( -1.0 * (( vnl_math_sqr( S )) / ( C ))) );

		const double V_Saliency = vesMeasure_1 * vesMeasure_2 * vesMeasure_3;

		return V_Saliency;
	}
}
void ScaleSpaceExplorer::DrawVertexness(int scale){
	m_CurrentVertexness=scale;
	m_VertexnessDrawer.SetImage(m_VertexnessImages[scale]);
	m_VertexnessDrawer.Draw();
	m_VertexnessDrawer.SetVisibility(this->m_pUI->showVertexnessCBox->isChecked());

	double shownScale = vcl_exp( vcl_log (m_LowerScaleVertexness) + m_ScaleStepVertexness * scale);


	QString shownScaleString("%1");
	this->m_pUI->vertexnessShownScaleLabel->setText(shownScaleString.arg(shownScale));


	m_VertexLocationsDrawer.SetVertexLocations(m_LocalMaxima[scale]);
	m_VertexLocationsDrawer.SetSpacing(m_Spacing);
	m_VertexLocationsDrawer.Draw();
	m_VertexLocationsDrawer.SetVisibility(this->m_pUI->showVertexLocationsCBox->isChecked());
	this->m_CentralRenderWindow->Render();
}
void ScaleSpaceExplorer::DrawPlateness(int scale){
	m_CurrentPlateness=scale;
	m_PlatenessDrawer.SetImage(m_PlatenessImages[scale]);
	m_PlatenessDrawer.Draw();
	m_PlatenessDrawer.SetVisibility(this->m_pUI->showPlatenessCBox->isChecked());

	double shownScale = vcl_exp( vcl_log (m_LowerScalePlateness) + m_ScaleStepPlateness * scale);


	QString shownScaleString("%1");
	this->m_pUI->platenessShownScaleLabel->setText(shownScaleString.arg(shownScale));



	VertexnessImageType::PointType origin;
	origin=m_PlatenessImages[scale]->GetOrigin();

	vtkSmartPointer<vtkCamera> camera = m_CentralRenderer->GetActiveCamera();
	 camera->ParallelProjectionOn();

	VertexnessImageType::RegionType region = m_PlatenessImages[scale]->GetLargestPossibleRegion();
	float xc = origin[0] + 0.5*(region.GetIndex(0) + region.GetSize(0))*m_Spacing[0];
	float yc = origin[1] + 0.5*(region.GetIndex(1) + region.GetSize(1))*m_Spacing[1];
	float zc = origin[2] + (region.GetIndex(2) + region.GetSize(2))*m_Spacing[2];
	//
	//  float xc = origin[0] + 0.5*(extent[0] + extent[1])*spacing[0];
	//  float yc = origin[1] + 0.5*(extent[2] + extent[3])*spacing[1];
	//  float xd = (extent[1] - extent[0] + 1)*spacing[0]; // not used
	  float yd = (region.GetSize(1) - region.GetIndex(1) + 1)*m_Spacing[1];

	  float d = camera->GetDistance();
	  camera->SetParallelScale(0.5f*static_cast<float>(yd));
	  camera->SetFocalPoint(xc,yc,zc);
	  camera->SetPosition(xc,yc,-d-10);



	  m_CentralRenderWindow->SetAlphaBitPlanes(1); //enable usage of alpha channel

	this->m_CentralRenderWindow->Render();
}
void ScaleSpaceExplorer::ComputePlateness(){

	int steps=this->m_pUI->stepsPlatenessSpinBox->value();
	m_LowerScalePlateness = this->m_pUI->lowerScalePlatenessSpinBox->value();
	m_UpperScalePlateness = this->m_pUI->upperScalePlatenessSpinBox->value();

	double range = vcl_log(m_UpperScalePlateness) - vcl_log(m_LowerScalePlateness);
	this->m_ScaleStepPlateness = range/(steps);

	m_PlatenessImages.resize(steps+1);
	for(int i=0;i<=steps;i++){
		//double scale = m_LowerScale + m_ScaleStep*i;
		double scale=vcl_exp( vcl_log (m_LowerScalePlateness) + m_ScaleStepPlateness * i);
		typedef ttt::MultiScaleHessianSmoothed3DToObjectnessMeasureImageFilter<ttt::PlatenessMeasurementFunction,PlatenessImageType> PlatenessFilterType;

		typedef ttt::PlatenessMeasurementFunction PlatenessFunctionType;

		PlatenessFunctionType::Pointer platenessFunction = PlatenessFunctionType::New();

		PlatenessFilterType::Pointer m_Plateness=PlatenessFilterType::New();

		m_Plateness->SetObjectnessMeasurementFunction(platenessFunction);

		m_Plateness->SetSigmaMin(scale);
		m_Plateness->SetSigmaMax(scale);
		m_Plateness->SetNumberOfSigmaSteps(1);
		m_Plateness->SetInput(m_ReescaledImage);
		m_Plateness->Update();

		m_PlatenessImages[i]=m_Plateness->GetOutput();

	}
	typedef itk::MinimumMaximumImageCalculator<VertexnessImageType> MinimumMaximumImageCalculator;

	MinimumMaximumImageCalculator::Pointer  maximumCalculator=MinimumMaximumImageCalculator::New();

	std::vector<float> maximums(steps+1);
	for(int i=0;i<=steps;i++){
		maximumCalculator->SetImage(m_PlatenessImages[i]);
		maximumCalculator->Compute();
		maximums[i]=maximumCalculator->GetMaximum();
	}

	float totalMax = (*std::max_element(maximums.begin(),maximums.end()));


	for(int i=0;i<=steps;i++){
		typedef typename itk::RescaleIntensityImageFilter<ImageType,ImageType> Rescaler01Type;
		Rescaler01Type::Pointer rescaler = Rescaler01Type::New();
		rescaler->SetOutputMinimum(0);
		rescaler->SetOutputMaximum(maximums[i]/totalMax);
		rescaler->SetInput(m_PlatenessImages[i]);
		rescaler->Update();
		m_PlatenessImages[i]=rescaler->GetOutput();
	}

	this->m_pUI->platenessScaleSlider->setMinimum(0);
	this->m_pUI->platenessScaleSlider->setMaximum(steps);
	this->m_pUI->platenessScaleSlider->setValue(0);
	DrawPlateness(0);
}