[vtkusers] vtkImageHighPass,vtkImageLowPass,vtkImageButterworthHighPass,VtkImageButterworthLowPass....Does no filtering at all

Sentil Balaji profbalse at yahoo.co.in
Sat Jan 31 02:12:35 EST 2004


Hey,

    I wrote a program for Image filtering .I tied
vtkIdeal(Low/High)PassFilter and the Butterworth
filter but the code does nothing to the input image.I
dont know where I am going wrong.Can you please guide
me.
----------------
CODE
----------------

#include <VTK\vtkBMPReader.H>
#include <VTK\vtkBMPWriter.H>
#include <VTK\vtkImageFFT.H>
#include <VTK\vtkimageData.H>
#include <VTK\vtkRenderWindow.H>
#include <VTK\vtkRenderer.H>
#include <VTK\vtkActor2D.h>
#include <VTK\vtkRenderWindowInteractor.H>
#include <VTK\vtkImageMapper.H>
#include <VTK\vtkImageIdealHighPass.H>
#include <VTK\vtkImageRFFT.H>
#include <VTK\vtkImageIdealLowPass.H>
#include <VTK\vtkImageExtractComponents.H>
#include <VTK\vtkImageCast.H>
#include <iostream.h>
#include <stdio.h>

void main()
{  
	char A[50];
	int t,s;
	float sh;
	vtkBMPReader *pr=vtkBMPReader::New();
	vtkBMPReader *pr1=vtkBMPReader::New();
	vtkBMPWriter *pw1=vtkBMPWriter::New();
	vtkBMPWriter *pw2=vtkBMPWriter::New();
	vtkImageData *id=vtkImageData::New();
    vtkImageData *idf=vtkImageData::New();
    vtkImageData *idrf=vtkImageData::New();
    vtkImageData *idbh=vtkImageData::New();
	vtkImageMapper *dm=vtkImageMapper::New();
	vtkImageMapper *dm1=vtkImageMapper::New();
	vtkImageExtractComponents
*ec=vtkImageExtractComponents::New();
	vtkImageExtractComponents
*ecr=vtkImageExtractComponents::New();
	vtkImageExtractComponents
*eci=vtkImageExtractComponents::New();
	vtkImageCast *ic=vtkImageCast::New();
	vtkImageCast *icr=vtkImageCast::New();
	vtkImageCast *ici=vtkImageCast::New();
	vtkRenderWindow *w=vtkRenderWindow::New();
	vtkRenderer *r=vtkRenderer::New();
	vtkRenderWindowInteractor
*i=vtkRenderWindowInteractor::New();
	vtkActor2D *a=vtkActor2D::New();
	vtkActor2D *a1=vtkActor2D::New();
	vtkImageIdealHighPass *hp=vtkImageIdealHighPass
::New();
	vtkImageFFT *f=vtkImageFFT::New();
	vtkImageRFFT *rf=vtkImageRFFT::New();
    vtkImageIdealLowPass
*bh=vtkImageIdealLowPass::New();
    w->AddRenderer(r);
	i->SetRenderWindow(w);
	printf("\n\n\t\tENTER THE IMAGE FILE TO BE
FILTERED:");
	gets(A);
	pr->SetFileName(A);
    id->SetDimensions(256,256,0);
	id->SetSpacing(0.78,0.78,0);
	id->SetOrigin(0,0,0);
	id->SetScalarType(VTK_SHORT);
	id->SetNumberOfScalarComponents(1);
	id->AllocateScalars();
	id=pr->GetOutput();
	f->SetInput(id);

    idf->SetDimensions(256,256,0);
	idf->SetSpacing(0.78,0.78,0);
	idf->SetOrigin(0,0,0);
	idf->SetScalarType(VTK_UNSIGNED_CHAR);
	idf->SetNumberOfScalarComponents(1);
	idf->AllocateScalars();
	idf=f->GetOutput();
	ecr->SetInput(idf);
	ecr->SetComponents(0);
    icr->SetInput(ecr->GetOutput());
	icr->SetOutputScalarTypeToUnsignedChar();
	eci->SetInput(idf);
	eci->SetComponents(1);
    ici->SetInput(eci->GetOutput());
	ici->SetOutputScalarTypeToUnsignedChar();
	cout<<"DO YOU WANT TO WRITE THE FOURIER FILE";
	cin>>t;
	if(t==1)
	{
         pw1->SetInput(icr->GetOutput());
		 pw1->SetFileName("C:/VTKREAL.bmp");
		 pw1->Write();
         pw2->SetInput(ici->GetOutput());
		 pw2->SetFileName("C:/VTKIM.bmp");
		 pw2->Write();
	}
	bh->SetInput(idf);
	bh->SetCutOff(100,100,0);
//	bh->SetOrder(50);
    idbh->SetDimensions(256,256,0);
	idbh->SetSpacing(0.78,0.78,0);
	idbh->SetOrigin(0,0,0);
	idbh->SetScalarType(VTK_UNSIGNED_CHAR);
	idbh->SetNumberOfScalarComponents(1);
	idbh->AllocateScalars();
	idbh=bh->GetOutput();
	rf->SetInput(idbh);
    idrf->SetDimensions(256,256,0);
	idrf->SetSpacing(0.78,0.78,0);
	idrf->SetOrigin(0,0,0);
	idrf->SetScalarTypeToUnsignedChar();
	idrf->SetNumberOfScalarComponents(1);
	idrf->AllocateScalars();
	idrf=rf->GetOutput();
	dm1->SetInput(idrf);
    a1->SetMapper(dm1);
	r->AddActor(a1);
   	w->Render();
	ec->SetInput(idrf);
	ec->SetComponents(1);
    ic->SetInput(ec->GetOutput());
	ic->SetOutputScalarTypeToUnsignedChar();
	cout<<"DO YOU WANT TO WRITE THE FILE";
	cin>>t;
	if(t==1)
	{
         pw1->SetInput(ic->GetOutput());
		 pw1->SetFileName("C:/VTKOUT.bmp");
		 pw1->Write();
	}
	i->Start();
	pr->Delete();
	pr1->Delete();
	id->Delete();
	idf->Delete();
	idrf->Delete();
	idbh->Delete();
	dm->Delete();
	dm1->Delete();
	a->Delete();
	a1->Delete();
	bh->Delete();
	r->Delete();
	w->Delete();
    pw1->Delete();


}

------------------------------------------------------

THANKS

Cheers

BeeJay


________________________________________________________________________
Yahoo! India Mobile: Download the latest polyphonic ringtones.
Go to http://in.mobile.yahoo.com



More information about the vtkusers mailing list