[vtkusers] Question on display changed(or changeable) imagedata
wang minyou
wmy1024 at hotmail.com
Wed Jun 2 08:08:24 EDT 2004
Hello everyone,
I came across some problem on imagedata.
I use BMPReader to readin a picture, change several pixels in it and then
display it. I may do many different changes and wish they could be
displayed in turn. For example, I want to add a circle in the image and the
circle can change with the position of center or the scalar of radius. I
use the function as follow:
bmpReader->GetOutput()->SetScalarComponentFromFloat(outx[i],outy[i],0,0,255.0);
Now the circle can be dispaly, but when the position of center or the
scalar of radius changes, the origin circle still exists, added with a new
circle. That means the last steps of operation on imagedata and current
step of operation are all presented on the window.
Someone have better idea of doing such work? Please help me!
Thank you all very much!
Codes related:
void CSegmentationView::OnRChange(WPARAM wRaram,LPARAM lParam)
{
int centerx=pInfoDlg->nCenterX;
int centery=pInfoDlg->nCenterY;
int radius=pInfoDlg->nRadius;
int wide=pInfoDlg->nWide;
int height=pInfoDlg->nHeight;
int size=(int)(radius*2*3.14159);
double* t=new double[size];
int* datax=new int[size];
int* datay=new int[size];
for(int i=0;i<size;i++)
{
t[i]=(2*3.14159/size)*i;
datax[i]=centerx+(int)(radius*cos(t[i]));
datay[i]=centery+(int)(radius*sin(t[i]));
if(datax[i]<0)
datax[i]=0;
else if(datax[i]>=wide)
datax[i]=wide-1;
if(datay[i]<0)
datay[i]=0;
else if(datay[i]>=height)
datay[i]=height-1;
}
for(i=0;i<size;i++)
{
bmpReader->GetOutput()->SetScalarComponentFromFloat(datax[i],datay[i],0,0,255.0);
bmpReader->GetOutput()->SetScalarComponentFromFloat(datax[i],datay[i],0,1,0.0);
bmpReader->GetOutput()->SetScalarComponentFromFloat(datax[i],datay[i],0,2,0.0);
}
imageActor2->SetInput(bmpReader->GetOutput());
pRender2->AddProp(imageActor2);
pRenWin->Render();
}
_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com
More information about the vtkusers
mailing list