[Insight-users] Re: Confirmation on the output

Luis Ibanez luis . ibanez at kitware . com
Fri, 21 Jun 2002 09:34:56 -0400


This is a multi-part message in MIME format.
--------------090307080702020500030200
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit


Hi cspl,

The output that you are getting form the
Laplacian looks quite noisy.  It seems that
the current implementation of the Laplacian
filter is expecting "float" type of images.

The Laplacian filter that you are using is
implemented by performing convolution with
a kernel but without any previous smoothing.

That means that it is sensitive to a particular
scale of edges (basically of 1 pixel width).
A more robust way of dealing with edges is to
tune your detection to the  scales of interest
in your image.


Could you help us doing the following
experiment ?

If you have a recent CVS checkout of ITK,
build the Example : GaussianFilter2D.

http://www.itk.org/HTML/GaussianFilter.htm

I'm attaching the MetaImage header file
to this email, that will help you read
your raw image as a MetaImage.

The GaussianFilter2D examples expects
2D MetaImages or PNG files.

You will have to edit the input.mha file
and at the end replace "input.raw" with
the actual filename of your 2D input file.
Make sure that you have both the .mha and
the .raw files in the same directory.

Load the image by clicking on the "Load"
button, select a sigma (starting with low
values, close to 1.0) and then Click on
"Execute". Once all buttons are green,
take a look at the outputs:

"Modulus": the magnitude of the gradient
"Smooth" : input convolved with a gaussian
"Laplacian": input after a laplacian filter


If you are interested in locating contours
you may find more useful the output of the
"Modulus" than the one from the Laplacian.

take a look at the Laplacian and the gradient
magnitued in the web page of the example:
http://www.itk.org/HTML/GaussianFilter.htm

The laplacian will give you zero-crossings
on the contours, but not a good mechanism
for detection.

A more robust way of detecting contours is
to combine the information of the modulus
with the information from the Laplacian.

Using a Sigma around 3.0 to 5.0. You can use
the Modulus for "detection" of edges, and
the Laplacian's zero-crossings for locating
those contours with precision.

Basically you will be looking for pixels
whose Gradient Modulus is high and its
Laplacian is in a Zero-Crossing.


Please let us know if you find any problems


Thanks


     Luis

======================================

cspl wrote:
> Dear Mr.Luis,
> 
> I got the Laplacian Filter o/p.But I am not sure it is exact o/p of
> Laplacian filter.Because I have seen in some other tool it is giving
> different o/p.Please make sure that is it correct o/p or not.I attached
> herewith my LaplacianImageFilter o/p.I have written code as follows.
> 
> int main(int argc,char** argv)
> {
> 
>   const char * inputFileName  =  argv[1];
>   const char * outputFileName = argv[4];
> 
>   const unsigned int nx =atoi(argv[2]);
>   const unsigned int ny =atoi(argv[3]);
> 
>   typedef  unsigned short    PixelType;
>   const    unsigned int     Dimension = 2;
> 
> 
> 
>   typedef  itk::Image< PixelType, Dimension >     ImageType;
> 
> 
> 
>   // Read a Raw File
>   typedef  itk::ImageFileReader< ImageType >      FileSourceType;
>   typedef  itk::RawImageIO<PixelType,Dimension>   RawReaderType;
> 
> 
>   FileSourceType::Pointer fileSource = FileSourceType::New();
>   fileSource->SetFileName( inputFileName  );
>   RawReaderType::Pointer  rawReader  = RawReaderType::New();
>   rawReader->SetDimensions( 0, nx );
>   rawReader->SetDimensions( 1, ny );
>   fileSource->SetImageIO( rawReader );
>   fileSource->Update();
>   ImageType::Pointer  image = fileSource->GetOutput();
> 
> 
>  ///Laplician Filter
>   itk::LaplacianImageFilter<ImageType, ImageType>::Pointer
>   lapFilter = itk::LaplacianImageFilter<ImageType, ImageType>::New();
> 
>   lapFilter->SetInput(image);
>   lapFilter->Update();
> 
> 
> 
>   ImageType::Pointer  imageo = lapFilter->GetOutput();
>   // Write a Raw File
>   typedef  itk::ImageFileWriter< ImageType >      FileSinkType;
>   typedef  itk::RawImageIO<PixelType,Dimension>   RawWriterType;
> 
> 
>   FileSinkType::Pointer   fileSink   = FileSinkType::New();
>   RawWriterType::Pointer  rawWriter  = RawWriterType::New();
> 
>   fileSink->SetImageIO( rawWriter );
>   fileSink->SetFileName( outputFileName );
>   fileSink->SetInput(imageo);
>   fileSink->Write();
> 
>   return 0;
> 
> 
> }
> 
> I am giving Raw file as i/p and getting as Raw file o/p.Actually Iwant edge
> detection using Laplacian filter.
> 
> Thanking you,
> Regards,
> Ramakrishna

--------------090307080702020500030200
Content-Type: text/plain;
 name="input.mha"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="input.mha"

NDims = 2
DimSize = 512 512
ElementType = MET_USHORT
ElementSpacing = 1.0 1.0
ElementByteOrderMSB = False
ElementDataFile = input.raw

--------------090307080702020500030200--