00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __freImageDifferenceSOMetricController_h
00023 #define __freImageDifferenceSOMetricController_h
00024
00025 #include "freSetupOptimizationMultiThreadMetricControllerBase.h"
00026
00027 #include "freImageDifferenceSOMetric.h"
00028
00029 namespace FREE
00030 {
00031
00040 freControllerIDMacro(ImageDifferenceSOMetricControllerBase, "ImageDifferenceSOMetricBase");
00041 template <class TControlledMetric>
00042 class ImageDifferenceSOMetricControllerBase : public SetupOptimizationMultiThreadMetricControllerBase<TControlledMetric>
00043 {
00044 public:
00045 DeclareParameterMacro(ReferenceImage);
00046 DeclareParameterMacro(ResultImage);
00047
00048 typedef TControlledMetric ComponentType;
00049 typedef SetupOptimizationMultiThreadMetricControllerBase<ComponentType> Superclass;
00050
00051 itkTypeMacro(ImageDifferenceSOMetricControllerBase, SetupOptimizationMultiThreadMetricControllerBase);
00052
00053 protected:
00054 ImageDifferenceSOMetricControllerBase()
00055 {
00056
00057 this->UpdateControllerID(ControllerID::ImageDifferenceSOMetricControllerBase);
00058 this->m_Description = "Base class for image difference metric.";
00059 };
00060
00061 virtual void GenerateProfile(CtrlProfile::ControllerProfile& profile,
00062 const SessionComponentCache* pComponentCache,
00063 bool bRegardOldSetup) const
00064 {
00065 Superclass::GenerateProfile(profile,pComponentCache,bRegardOldSetup);
00066
00067
00068 profile.Parameters().AddParameter(Superclass::cParam_MetricScales,CtrlProfile::Parameter::PVTDouble,Superclass::cParamDsc_MetricScales,13,"1.0");
00069 profile.Parameters().AddParameter(cParam_ReferenceImage,CtrlProfile::Parameter::PVTIDPath,cParamDsc_ReferenceImage,1,"");
00070 profile.Parameters().AddParameter(cParam_ResultImage,CtrlProfile::Parameter::PVTIDPath,cParamDsc_ResultImage,1,"");
00071 };
00072
00073 virtual void ActualizeMainComponent(ComponentType* pMainComponent,
00074 SessionComponentCache* pComponentCache,
00075 SessionInfo* pSessionInfo,
00076 const unsigned int& iActLevel) const
00077 {
00078 Superclass::ActualizeMainComponent(pMainComponent, pComponentCache,
00079 pSessionInfo, iActLevel);
00080
00081 std::string sTempPath;
00082 IDPath referenceImagePath;
00083 IDPath resultImagePath;
00084
00085 try
00086 {
00087 SessionAccessor::GetParameterValue(pComponentCache,cParam_ReferenceImage,sTempPath);
00088 referenceImagePath = sTempPath;
00089 SessionAccessor::GetParameterValue(pComponentCache,cParam_ResultImage,sTempPath);
00090 resultImagePath = sTempPath;
00091 }
00092 catchAllNPassMacro("Error while retrieving parameter values.");
00093
00094
00095 pMainComponent->SetReferenceImagePath(referenceImagePath);
00096 pMainComponent->SetResultImagePath(resultImagePath);
00097 };
00098
00099 void
00100 SetStatisticEntryMainComponent(StatisticEntry& rStatisticEntry,
00101 ComponentType* pMainComponent,
00102 SessionComponentCache* pMainComponentCache,
00103 SessionInfo* pSessionInfo,
00104 StatisticDictionary& rDictionary) const
00105 {
00106 typename ComponentType::DecomposedMeasureType values = pMainComponent->GetCurrentDecomposedValue();
00107
00108 std::string sIDPath = pMainComponentCache->GetIDPath();
00109 StatisticValueDefinition* pEntry = rDictionary.GetValueDefinitionByName(sIDPath,"mean error");
00110
00111 if (!pEntry)
00112 {
00113 pEntry = rDictionary.AddValueDefinition(sIDPath,"mean error", "mean pixel difference");
00114 rDictionary.AddValueDefinition(sIDPath,"std error", "standard deviation of the pixel difference.");
00115 rDictionary.AddValueDefinition(sIDPath,"min error", "minimum pixel difference");
00116 rDictionary.AddValueDefinition(sIDPath,"max error", "maximum pixel difference");
00117 rDictionary.AddValueDefinition(sIDPath,"mean image error", "mean sum of differences in images)");
00118 rDictionary.AddValueDefinition(sIDPath,"std image error", "standard deviation of the image difference");
00119 rDictionary.AddValueDefinition(sIDPath,"min image error", "minimum image difference");
00120 rDictionary.AddValueDefinition(sIDPath,"max image error", "maximum image difference");
00121 rDictionary.AddValueDefinition(sIDPath,"failure", "number of failed evaluations");
00122 rDictionary.AddValueDefinition(sIDPath,"mean duration", "mean duration of an evaluation (tenth of a second).");
00123 rDictionary.AddValueDefinition(sIDPath,"std duration", "standard deviation of an evaluation (tenth of a second).");
00124 rDictionary.AddValueDefinition(sIDPath,"min duration", "minimum duration of an evaluation (tenth of a second).");
00125 rDictionary.AddValueDefinition(sIDPath,"max duration", "maximum duration of an evaluation (tenth of a second).");
00126 }
00127
00128 for (unsigned int i = 0; i<values.Size(); i++)
00129 {
00130 rStatisticEntry.AddValue(Convert::ToStr(values[i]),pEntry->GetRefID()+i);
00131 }
00132 };
00133
00134 };
00135
00136 template <class TControlledMetric>
00137 const char* const ImageDifferenceSOMetricControllerBase<TControlledMetric>::cParam_ReferenceImage = "ReferenceImage";
00138 template <class TControlledMetric>
00139 const char* const ImageDifferenceSOMetricControllerBase<TControlledMetric>::cParamDsc_ReferenceImage = "IDPath of the reference image within the session of the adapted setups used as test basis.";
00140 template <class TControlledMetric>
00141 const char* const ImageDifferenceSOMetricControllerBase<TControlledMetric>::cParam_ResultImage = "ResultImage";
00142 template <class TControlledMetric>
00143 const char* const ImageDifferenceSOMetricControllerBase<TControlledMetric>::cParamDsc_ResultImage = "IDPath of the result image of an adapted setup.";
00144
00153 freControllerIDMacro(ImageDifference2DSOMetricController, "Image Difference 2D SO Metric");
00154 class ImageDifference2DSOMetricController : public ImageDifferenceSOMetricControllerBase< ImageDifferenceSOMetric<2> >
00155 {
00156 public:
00157 typedef ImageDifferenceSOMetric<2> ComponentType;
00158 typedef ImageDifferenceSOMetricControllerBase<ComponentType> Superclass;
00159
00160 itkTypeMacro(ImageDifference2DSOMetricController, ImageDifferenceSOMetricControllerBase);
00161
00162 ImageDifference2DSOMetricController();
00163
00164 };
00165
00174 freControllerIDMacro(ImageDifference3DSOMetricController, "Image Difference 3D SO Metric");
00175 class ImageDifference3DSOMetricController : public ImageDifferenceSOMetricControllerBase< ImageDifferenceSOMetric<3> >
00176 {
00177 public:
00178 typedef ImageDifferenceSOMetric<3> ComponentType;
00179 typedef ImageDifferenceSOMetricControllerBase<ComponentType> Superclass;
00180
00181 itkTypeMacro(ImageDifference3DSOMetricController, ImageDifferenceSOMetricControllerBase);
00182
00183 ImageDifference3DSOMetricController();
00184
00185 };
00186
00187 }
00188
00189 #endif