[Insight-users] help black window!

Luis Ibanez luis . ibanez at kitware . com
Tue, 27 Aug 2002 17:51:05 -0400


Hi Renaud,

The CannyEdgeDetectionImageFilter works on images
of PixelType=float and normalizes its output
to the range [ 0.0, 1.0 ].

When you cast this image to an unsigned short, all
the values are truncated to zero.

You can prevent this from happening by using any
of the following filters:

- itk::RescaleIntensityImageFilter
http://www.itk.org/Insight/Doxygen/html/classitk_1_1ShiftScaleImageFilter.html

- itk::ShiftScaleImageFilter
http://www.itk.org/Insight/Doxygen/html/classitk_1_1RescaleIntensityImageFilter.html

both filters apply a linear transformation to the
gray levels of the image. The difference is that in
ShiftScale you specify the transform as a multiplier
and an offset value, while with RescaleIntensity you
specify the desired values for the maximum and minimum
of the output.

Note that any of these two filters can also do the
casting for you (from float to unsigned short)


A typical use will be:

typedef itk::RescaleIntensityImageFilter<
                FloatImageType, ShortImageType > RescaleType;

RescaleType::Pointer rescaleFitler = RescaleType::New();

rescaleFilter->SetInput( canny->GetOuput() );
rescaleFilter->SetOutputMinimum(    0.0 );
rescaleFilter->SetOutputMaximum( 3000.0 );

rescaleFilter->Update();

-----------

Please let us know if you find further problems,

Thanks


    Luis	


==================================================
Renaud Winzenrieth wrote:
> Hi everybody,
> I have a problem with the cannyfilter.       This is what I do:
> 
>     vtkBMPReader *imageIn=vtkBMPReader::New();
>     imageIn->SetFileName("D:/renaud/These/Images/TE_00011.BMP");  
> 
>> > >     vtkImageLuminance *il=vtkImageLuminance::New();
>> >     il ->SetInput (imageIn-> GetOutput());
>> > >     vtkImageCast *cast=vtkImageCast::New();
>> >     cast->SetInput(il ->GetOutput());
>> >     cast->SetOutputScalarTypeToFloat ();
>> > > >     vtkImageExport* vtkExporter = vtkImageExport::New();
>> >     vtkExporter->SetInput(cast->GetOutput());
>> >     typedef itk::Image<float, 2> ImageType;
>> >     typedef itk::VTKImageImport<ImageType> ImageImportType;
>> >     ImageImportType::Pointer itkImporter = ImageImportType::New();
>> >     ConnectPipelines(vtkExporter, itkImporter);
>> > >    typedef itk::CannyEdgeDetectionImageFilter<ImageType, 
>> ImageType> >    CannyFilterType;
>> >    CannyFilterType::Pointer cannyFilter=CannyFilterType::New();
>> >  >   cannyFilter->SetInput(itkImporter->GetOutput());
>> >   cannyFilter->SetVariance(0.1);
>> >   cannyFilter->SetMaximumError(0.1);
>> >   cannyFilter->Update();
>> > >   typedef itk::VTKImageExport<ImageType> ImageExportType;
>> >   ImageExportType::Pointer itkExporter = ImageExportType::New();
>> >   itkExporter->SetInput(cannyFilter->GetOutput());
>> >   vtkImageImport* vtkImporter = vtkImageImport::New(); >   
>> ConnectPipelines(itkExporter, vtkImporter);
>> >  >   vtkImageCast *cast1=vtkImageCast::New();
>> >   cast1->SetInput(vtkImporter ->GetOutput());
>> >   cast1-> SetOutputScalarTypeToUnsignedChar();   > >   
>> vtkImageActor* actor = vtkImageActor::New();
>> >   actor->SetInput(cast1->GetOutput());
>> >    >   vtkRenderer* renderer = vtkRenderer::New();
>> >   vtkRenderWindow* renWin = vtkRenderWindow::New();
>> >   vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
>> >  >   renWin->SetSize(256, 256);
>> >   renWin->AddRenderer(renderer);
>> >   iren->SetRenderWindow(renWin);
>> >  >   renderer->AddActor(actor);
>> >   renderer->SetBackground(0.4392, 0.5020, 0.5647);
>> > >   renWin->Render();
>> >   iren->Start();
>> > > > If I just connect the pipeline without perform the connyfilter, 
>> all work > well. But when I use the filter, I only Obtain a black window.
>> > What's wrong?
>> > Is anybody can help me? 
> 
>    Thanks in advance ,    Renaud
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>