18 #ifndef __itkCoreAtomImageToUnaryCorrespondenceMatrixProcess_txx
19 #define __itkCoreAtomImageToUnaryCorrespondenceMatrixProcess_txx
29 template<
typename TSourceImage >
33 itkDebugMacro(<<
"itkCoreAtomImageToUnaryCorrespondenceMatrixProcess::itkCoreAtomImageToUnaryCorrespondenceMatrixProcess() called");
51 template<
typename TSourceImage >
56 return static_cast<DataObject*
>(CorrespondenceMatrixType::New().GetPointer());
62 template<
typename TSourceImage >
67 if (this->GetNumberOfOutputs() < 1)
79 template<
typename TSourceImage >
84 itkDebugMacro(<<
"CoreAtomImageToUnaryCorrespondenceMatrixProcess: Setting first core atom image input")
87 SetNthInput(1, const_cast<TSourceImage *>( image1 ) );
93 template<
typename TSourceImage >
98 itkDebugMacro(<<
"CoreAtomImageToUnaryCorrespondenceMatrixProcess: Setting second core atom image input")
100 SetNthInput(0, const_cast<TSourceImage *>( image2 ) );
106 template<
typename TSourceImage >
112 return const_cast<TSourceImage *
>(this->GetNthInput(0));
118 template<
typename TSourceImage >
124 return const_cast<TSourceImage *
>(this->GetNthInput(1));
130 template<
typename TSourceImage >
135 itkDebugMacro(<<
"itkCoreAtomImageToUnaryCorrespondenceMatrixProcess::GenerateData() called");
137 m_Metric = UnaryMetricType::New();
144 m_Rows = m_CoreAtomImageA->GetMedialNodeCount();
145 m_Columns = m_CoreAtomImageB->GetMedialNodeCount();
147 if(m_CorrespondenceMatrix->set_size(m_Rows,m_Columns))
149 itkDebugMacro(<<
"m_CorrespondenceMatrix resized successfully");
153 itkDebugMacro(<<
"m_CorrespondenceMatrix resize failed");
161 BloxIterator bloxItA = BloxIterator(m_CoreAtomImageA,
162 m_CoreAtomImageA->GetRequestedRegion() );
164 BloxIterator bloxItB = BloxIterator(m_CoreAtomImageB,
165 m_CoreAtomImageB->GetRequestedRegion() );
173 typedef unsigned char CorrespondencePixelType;
176 CorrespondenceImageType::IndexType pixelIndex;
177 CorrespondenceImageType::SizeType size;
181 CorrespondenceImageType::RegionType region;
182 CorrespondenceImageType::IndexType index;
184 region.SetIndex( index );
185 region.SetSize(size);
187 CorrespondenceImageType::Pointer CorrespondenceImage;
188 CorrespondenceImage = CorrespondenceImageType::New();
190 CorrespondenceImage->SetRegions( region );
191 CorrespondenceImage->Allocate();
192 CorrespondenceImage->FillBuffer(0);
195 FileWriterType::Pointer imageWriter;
196 imageWriter = FileWriterType::New();
202 for ( bloxItA.GoToBegin(); !bloxItA.IsAtEnd(); ++bloxItA)
206 if( pPixelA->empty() )
212 for ( bloxItB.GoToBegin(); !bloxItB.IsAtEnd(); ++bloxItB)
216 if( pPixelB->empty() )
221 m_Metric->SetMedialNodes(pPixelA, pPixelB);
222 m_Metric->Initialize();
223 MetricValue = m_Metric->GetResult();
227 m_CorrespondenceMatrix->put(counterA, counterB, MetricValue);
229 pixelIndex[0] = counterA;
230 pixelIndex[1] = counterB;
234 CorrespondenceImage->SetPixel(pixelIndex,
235 static_cast<CorrespondencePixelType>(100*m_CorrespondenceMatrix->get(counterA,counterB)) );
247 std::cerr <<
"WROTE CORRESPONDANCE IMAGE TO CorrespondenceImage1.png" << std::endl;
248 imageWriter->SetInput(CorrespondenceImage);
249 imageWriter->SetFileName(
"CorrespondenceImage1.png");
250 imageWriter->SetImageIO(io);
251 imageWriter->Write();
253 itkDebugMacro(<<
"Finished CoreAtomImageToUnaryCorrespondenceMatrixProcess\n");
259 template<
typename TSourceImage >
264 Superclass::PrintSelf(os,indent);
265 os << indent <<
"Columns: " << this->GetColumns() << std::endl;
266 os << indent <<
"Rows: " << this->GetRows() << std::endl;