[Insight-users] Filters on 3D images
Luis Ibanez
luis.ibanez@kitware.com
Wed, 27 Nov 2002 09:22:16 -0500
Hi Ramakrishna
From your code it looks like your pipeline is:
Read ->
GaussianFilter -> Threshold ->
ZeroCrossing -> Laplacian -> Write
Is this right ?
--
Some comments about it:
1) the RecursiveGaussianImageFilter may not be
the filter you want in here. This filter
computes the equivalent of a convolution
with a gaussian kernel but does this using
IIR filters. The filter only applies the
processing in *one* of the N-Dimensions.
This filter is not intended to be used alone
but rather in tandem to apply different operations
along different dimension.
If what you want is to blurr the image with
a gaussian kernel, you may want to use the
DiscreteGaussianImageFilter:
http://public.kitware.com/Insight/Doxygen/html/classitk_1_1DiscreteGaussianImageFilter.html
which performs a traditional convolution taking
advantage of the separability of the Gaussian.
2) By thresholding the gaussian you are creating
artificial contours on the image. If your purpose
on the pipeline is to detect contours, this
thresholding here may not be helping much.
I would suggest you to remove it from the pipeline.
3) You are applying the ZeroCrossing filtering
before the Laplacian. The output of Zero crossing
is a binary image. It is usual to apply the
Laplacian first and then take the Zero crossings
of the laplacian as contours. Probably you may
want to revert the order of this two filters.
So,
the suggestion is to try the following pipeline:
Read->DiscreteGaussian->Laplacian->ZeroCrossing->Write
Please let us know if you have further questions,
Thanks
Luis
========================================
cspl wrote:
> Hi All,
>
>
>
> I am working on Laplacian filter.I used this filter for two dimension
> images ,it is working fine.But applying on multiple slices in an
> image(.dcm) filters are not effective on all images.
>
> I have writen code as follows.Please give me suggestion.
>
>
>
> LPSTR __stdcall Laplacian(LPSTR FileName,long Thrval)
> {
> GblCount++;
> DICOMReader TempReader;
> TempReader.StaticVarInit();
> bool Flag = TempReader.ReadDicomImage(FileName);
>
>
>
> char *rep=TempReader.GetDicomInfo(cs_pixel_representation);
> char *bits=TempReader.GetDicomInfo(cs_bits_allocated);
> char *acquistion=TempReader.GetDicomInfo(cs_modality);
> int represent=atoi(rep);
> int type=atoi(bits);
>
>
>
> unsigned short * Buffer = (unsigned short *)
> TempReader.GetAllImageData();
>
>
>
>
> typedef itk::Image<unsigned short,3> ImageType;
> ImageType::Pointer vol_init = ImageType::New();
>
>
>
>
> ImageType::SizeType sz;
> sz[0] = TempReader.width;
> sz[1] = TempReader.height;
> sz[2] = TempReader.Slices;
>
>
>
>
>
>
>
> ImageType::IndexType idx;
> idx[0] = 0;
> idx[1] = 0;
> idx[2] = 0;
>
>
>
>
>
>
>
> ImageType::RegionType reg;
> reg.SetSize(sz);
> reg.SetIndex(idx);
>
>
>
> vol_init->SetRegions(reg);
>
>
>
> vol_init->Allocate();
>
>
>
>
>
>
>
> for(unsigned int z=0; z<TempReader.Slices; ++z )
> {
> idx[2]=z;
>
>
>
> for (unsigned int y = 0; y < TempReader.height; ++y)
> {
> idx[1] = y;
> for (unsigned int x = 0; x < TempReader.width; ++x)
> {
> idx[0] = x;
> vol_init->SetPixel(idx, *(Buffer
> +(z*TempReader.height*TempReader.width)+y *TempReader.width +x) );
> }
> }
> }
>
>
>
>
>
>
>
>
> typedef unsigned short PixelType;
> typedef itk::Image<PixelType, 3> myImage;
>
>
>
>
> itk::RecursiveGaussianImageFilter<myImage, myImage>::Pointer
> gaussianFilter = itk::RecursiveGaussianImageFilter<myImage,
> myImage>::New();
> gaussianFilter->SetInput(vol_init);
>
>
>
> ///Laplician Filter
> itk::ThresholdImageFilter< myImage >:: Pointer
> thr=itk::ThresholdImageFilter<myImage>::New();
> thr->SetInput(gaussianFilter->GetOutput());
> if(strcmp(acquistion,"MR")==0)
> {
>
>
>
> if(type==8 && (represent==1 ||represent==0))
> {
>
>
>
> AfxMessageBox("type 16");
> thr->ThresholdOutside(0,(unsigned short)(Thrval)) ;
>
>
>
> }
> if(type==16 && (represent==1 || represent==0))
> {
> AfxMessageBox("type 16");
> thr->ThresholdOutside(0,(unsigned short)((Thrval))*100 ) ;
> }
> else
> {
> AfxMessageBox("else");
> thr->ThresholdOutside(0,(unsigned short)(Thrval)) ;
> }
>
>
>
> }
>
>
>
> if(strcmp(acquistion,"CT")==0)
> {
>
>
>
> if(type==8 && (represent==1 ||represent==0))
> {
>
> thr->ThresholdOutside(0,(unsigned short)(Thrval)) ;
>
>
>
> }
> if(type==16 && (represent==1 || represent==0))
> {
>
> thr->ThresholdOutside(0,(unsigned short)((Thrval))*250 ) ;
> }
> else
> {
>
> thr->ThresholdOutside(0,(unsigned short)(Thrval)) ;
> }
>
>
>
> }
>
>
>
>
> itk::ZeroCrossingImageFilter<myImage, myImage>::Pointer
> zeroFilter = itk::ZeroCrossingImageFilter<myImage, myImage>::New();
> zeroFilter->SetInput(thr->GetOutput());
>
>
>
> zeroFilter->Update();
>
>
>
>
> itk::LaplacianImageFilter<myImage, myImage>::Pointer
> lapFilter = itk::LaplacianImageFilter<myImage, myImage>::New();
> lapFilter->SetInput(zeroFilter->GetOutput());
>
>
>
> lapFilter->Update();
>
>
>
> myImage::Pointer imageo = lapFilter->GetOutput();
> myImage::IndexType idx1;
>
>
>
> for(unsigned int z=0; z<TempReader.Slices;++z)
> {
> idx1[2]=z;
> for (unsigned int y = 0; y < TempReader.height; ++y)
> {
> idx1[1] = y;
> for (unsigned int x = 0; x < TempReader.width; ++x)
> {
> idx1[0] = x;
> *(Buffer +(z * TempReader.height *TempReader.width) +y
> *TempReader.width +x)=imageo->GetPixel(idx1);
>
>
>
>
> }
> }
> }
>
>
>
>
> memcpy(TempReader.AllBuffers,Buffer,TempReader.width*TempReader.height*TempReader.Slices*sizeof(unsigned
> short));
>
>
>
> LPSTR Temp = TempReader.WriteDicomFile();
> int Len = strlen(Temp);
>
>
>
> LPSTR FName = new char[Len + 1];
> strcpy(FName ,Temp);
> return FName;
> }
>
> Regards,
>
> Ramakrishna
>