[vtkusers] Butter-Worth LowPass Filter

Kevin H. Hobbs kevin.hobbs.1 at ohiou.edu
Wed Apr 19 08:40:58 EDT 2006


On Wed, 2006-04-19 at 10:40 +0530, mahesh wrote:
> Ok! Lets make a list of our Conversation,so that others too can get
> benefit of it.
> 
> 
> 
> After mailing u i got this thought,what u have said of using
> vtkImageButterworthlowpassfilter for 1-D data.i have used the follwong
> code during my trail.
> 
> 
> bool LowPass(int order,float frequency)
> {
>         long xmin,xmax,ymin,ymax;       
> 
>         int* aImgBits = ptrarray;//m_srcImage->GetBits();
>                 
>         int xdim=0;//m_srcImage->info.dwEffWidth; 
>         int ydim=sz;//m_srcImage->GetHeight();
>         int offset=xdim*ydim;
>         float *tImgbits=new float[sz*2];
> //      fprintf(fptr2, "%s\n", "using vtk to implement lowpas
> started.........");
>         vtkImageImport *importer = vtkImageImport::New();
>         importer->SetDataExtent(0,0, 0,sz-1,
> 0,0);//(0,xdim-1  ,0,ydim-1 ,0,0 );
>         importer->SetWholeExtent(0, 0  ,0,sz-1,0,0 );
>         //importer->SetDataScalarTypeToUnsignedChar();
>         importer->SetDataScalarTypeToInt();
>         importer->SetImportVoidPointer(aImgBits);
> 
>         vtkImageFFT *fft=vtkImageFFT::New();
>         fft->SetDimensionality(1);
>         fft->SetInput(importer->GetOutput());
>         
>         //vtkImageButterworthLowPass
> *filter=vtkImageButterworthLowPass::New();
>         vtkImageButterworthHighPass
> *filter=vtkImageButterworthHighPass::New();
>         filter->SetCutOff(frequency);//0.02);
>         filter->SetInput(fft->GetOutput());
>         filter->SetOrder(order);//2);
> 
>         vtkImageRFFT *rfft=vtkImageRFFT::New();
>         rfft->SetDimensionality(1);
>         rfft->SetInput(filter->GetOutput());
> 
>         vtkImageExtractComponents
> *ecomp=vtkImageExtractComponents ::New();
>         ecomp->SetInput(rfft->GetOutput());
>         ecomp->SetComponents(0);
> 
>         vtkImageExport *exporter = vtkImageExport::New();
>         exporter->SetInput(ecomp->GetOutput());
>         exporter->Export(tImgbits);
> 
>         /*BYTE *pImageData = new BYTE[sz];//[ xdim*ydim];
>         memcpy(pImageData,aImgBits,sz*szof(BYTE));
> 
>         for(int i = ymin;i < ymax ; i++)
>         {
>                 for(int j = xmin; j < xmax ; j++)
>                 {
>                         pImageData[i * xdim + j] = tImgbits[ i * xdim
> + j];
> 
>                 }
>         }*/
> 
>         FILE *fp = fopen("D:\\Out.dat","w");
> 
>         for(int l=0;l<sz * 2;l++)
>         {
>                 //cout<<l<<endl;
>                 cout<<l<<"..."<<tImgbits[l]<<endl;
>                 fprintf(fp,"\n%d....%f",l,tImgbits[l]);
>         }
>         fclose(fp);
>         //memcpy(aImgBits,pImageData,sz*sizeof(BYTE));
> 
>         delete[] tImgbits;      tImgbits = NULL;
> //      delete[] pImageData; pImageData = NULL;
>         importer->Delete();
>         //exporter->Delete();
>         ecomp->Delete();
>         fft->Delete();
>         rfft->Delete();
>         filter->Delete();
> 
>         return 0;
> }
> 
> for ex:if I had an array containing data of array size 40000,after
> filtering i am getting data of double the size than previous
> mentioned.
> 
> Mainly i want to ensure of my data,whether i am in right track or not.
> 
> 
> You had mentioned that there are lot of ways in applying filter for
> 1-D data.I will be very thankful if u direct me to that p'cular ways.
> 
> Regards,
> mahesh
> 


"Please keep the conversation on the list." means that you should
include the VTK Users List <vtkusers at vtk.org> in the recipients of your
e-mail instead of replying to me directly. Most graphical e-mail clients
have a "Reply All" button that automatically does this. When you reply
to the list you contact more people than just me.  People who likely
know more about the topic than I do. Plus the conversation is archived
and becomes searchable online.




-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060419/9d8aab26/attachment.pgp>


More information about the vtkusers mailing list