58 int main(
int argc,
char * argv[])
62 std::cerr <<
"Missing parameters. " << std::endl;
63 std::cerr <<
"Usage: " << std::endl;
65 <<
" inputImageFile outputImageFile direction"
70 typedef float PixelType;
77 ReaderType::Pointer reader = ReaderType::New();
78 reader->SetFileName(argv[1]);
85 std::cout <<
"ExceptionObject caught !" << std::endl;
86 std::cout << err << std::endl;
90 ImageType::Pointer output = ImageType::New();
91 output->SetRegions(reader->GetOutput()->GetRequestedRegion());
94 IteratorType out(output, reader->GetOutput()->GetRequestedRegion());
115 sobelOperator.CreateDirectional();
128 NeighborhoodIteratorType::RadiusType radius = sobelOperator.GetRadius();
129 NeighborhoodIteratorType it(radius, reader->GetOutput(),
130 reader->GetOutput()->
131 GetRequestedRegion());
146 for (it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out)
148 out.Set(innerProduct(it, sobelOperator));
161 typedef unsigned char WritePixelType;
166 ImageType, WriteImageType> RescaleFilterType;
168 RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
170 rescaler->SetOutputMinimum(0);
171 rescaler->SetOutputMaximum(255);
172 rescaler->SetInput(output);
174 WriterType::Pointer writer = WriterType::New();
175 writer->SetFileName(argv[2]);
176 writer->SetInput(rescaler->GetOutput());
183 std::cout <<
"ExceptionObject caught !" << std::endl;
184 std::cout << err << std::endl;