[Insight-users] derivativeImageFilter
robert tamburo
robert.tamburo at gmail.com
Wed Mar 16 14:07:03 EDT 2011
Looks like concept checking for DerivativeImageFilter. The output image type
likely needs to be signed.
On Wed, Mar 16, 2011 at 1:59 PM, john smith <mkitkinsightuser at gmail.com>wrote:
> and here is my code (if this could help you):
> \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
>
>
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkDerivativeImageFilter.h"
>
>
>
> int main(int argc, char * argv[])
> {
> // Verify command line arguments
> if( argc < 2 )
> {
> std::cerr << "Usage: " << std::endl;
> std::cerr << argv[0] << " inputImageFile" << std::endl;
> return EXIT_FAILURE;
> }
>
> // Parse command line arguments
> std::string inputFilename = argv[1];
>
> // Setup types
> // typedef itk::Image< float, 2 > FloatImageType;
> typedef itk::Image< unsigned char, 2 > ImageType;
>
> typedef itk::ImageFileReader< ImageType > readerType;
> typedef itk::ImageFileWriter< ImageType > writerType;
>
> typedef itk::DerivativeImageFilter<
> ImageType, ImageType > filterType;
>
>
> // Create and setup a reader
> readerType::Pointer reader = readerType::New();
> reader->SetFileName( inputFilename.c_str() );
>
> // Create and setup a derivative filter
> filterType::Pointer derivativeFilter = filterType::New();
> derivativeFilter->SetInput( reader->GetOutput() );
> derivativeFilter->SetDirection(0); // "x" axis
>
>
> writerType::Pointer writer = writerType::New();
> writer->SetFileName("result.png");
> writer->SetInput(derivativeFilter->GetOutput());
>
> try
> {
> writer->Update();
> }
> catch( itk::ExceptionObject exp )
> {
> std::cerr << "Exception caught !" << std::endl;
> std::cerr << exp << std::endl;
> }
>
> return EXIT_SUCCESS;
> }
>
> 2011/3/16 john smith <mkitkinsightuser at gmail.com>
>
>> Hi,
>>
>> I made thechanges and when I run it from the command line window I get a
>> message which is says that png supports unsigned char and unsigned short.
>> But when I make these changes I get failures in the building of the project:
>> *error C2440: 'initializing' : cannot convert from
>> 'itk::Concept::Detail::UniqueType_bool<__formal>' to
>> 'itk::Concept::Detail::UniqueType_bool<__formal>'. *Could somebody help
>> me with this?
>>
>> Thanks in advance
>>
>>
>>
>> 2011/3/15 robert tamburo <robert.tamburo at gmail.com>
>>
>>> Take a look at your writerType typedef.
>>>
>>>
>>> On Tue, Mar 15, 2011 at 9:49 AM, john smith <mkitkinsightuser at gmail.com>wrote:
>>>
>>>> Hi to everyone,
>>>>
>>>> I want to read an image and use a derivative image filter.I wrote the
>>>> following code, but when I get a failure because I thonk that the types of
>>>> reader,writer and derivative image filter do not match each other.Could
>>>> somebody help me?
>>>>
>>>> Thanks in advance
>>>>
>>>> ================DerivativeImageFilter.cxx==========================
>>>> #include "itkImage.h"
>>>> #include "itkImageFileReader.h"
>>>> #include "itkImageFileWriter.h"
>>>> #include "itkDerivativeImageFilter.h"
>>>>
>>>>
>>>>
>>>> int main(int argc, char * argv[])
>>>> {
>>>> // Verify command line arguments
>>>> if( argc < 2 )
>>>> {
>>>> std::cerr << "Usage: " << std::endl;
>>>> std::cerr << argv[0] << " inputImageFile" << std::endl;
>>>> return EXIT_FAILURE;
>>>> }
>>>>
>>>> // Parse command line arguments
>>>> std::string inputFilename = argv[1];
>>>>
>>>> // Setup types
>>>> typedef itk::Image< float, 2 > FloatImageType;
>>>> typedef itk::Image< unsigned char, 2 > UnsignedCharImageType;
>>>>
>>>> typedef itk::ImageFileReader< UnsignedCharImageType > readerType;
>>>> typedef itk::ImageFileReader< UnsignedCharImageType > writerType;
>>>>
>>>> typedef itk::DerivativeImageFilter<
>>>> UnsignedCharImageType, FloatImageType > filterType;
>>>>
>>>> // Create and setup a reader
>>>> readerType::Pointer reader = readerType::New();
>>>> reader->SetFileName( inputFilename.c_str() );
>>>>
>>>> // Create and setup a derivative filter
>>>> filterType::Pointer derivativeFilter = filterType::New();
>>>> derivativeFilter->SetInput( reader->GetOutput() );
>>>> derivativeFilter->SetDirection(0); // "x" axis
>>>>
>>>> typedef itk::ImageFileWriter< writerType > WriterType;
>>>> WriterType::Pointer writer = WriterType::New();
>>>> writer->SetFileName("result.png");
>>>> writer->SetInput(derivativeFilter->GetOutput());
>>>>
>>>> try
>>>> {
>>>> writer->Update();
>>>> }
>>>> catch( itk::ExceptionObject exp )
>>>> {
>>>> std::cerr << "Exception caught !" << std::endl;
>>>> std::cerr << exp << std::endl;
>>>> }
>>>>
>>>> return EXIT_SUCCESS;
>>>> }
>>>>
>>>> _____________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Kitware offers ITK Training Courses, for more information visit:
>>>> http://www.kitware.com/products/protraining.html
>>>>
>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110316/479f2a76/attachment.htm>
More information about the Insight-users
mailing list