[vtkusers] vtkImageAccumulate
Ziad Rahhal
ziz79 at yahoo.com
Tue Oct 11 06:10:13 EDT 2005
Hi,
Thanx Dean for the help. By Adding input->Update(); to
your suggestion, I was able to see the histogram:
Here is my code:
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkVolume16Reader.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkContourFilter.h"
#include "vtkImageAccumulate.h"
#include "vtkXYPlotActor.h"
#include "vtkImageData.h"
#include "vtkImageThreshold.h"
int main (int argc, char **argv)
{
if (argc < 2)
{
cout << "Usage: " << argv[0] <<
"/headsq/quarter" << endl;
return 1;
}
vtkRenderer *aRenderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(aRenderer);
vtkRenderWindowInteractor *iren =
vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
vtkVolume16Reader *v16 = vtkVolume16Reader::New();
v16->SetDataDimensions (64,64);
v16->SetImageRange (1,93);
v16->SetDataByteOrderToLittleEndian();
v16->SetFilePrefix (argv[1]);
v16->SetDataSpacing (3.2, 3.2, 1.5);
vtkImageData *input = (vtkImageData
*)v16->GetOutput();
input->Update();
vtkImageAccumulate* accum =
vtkImageAccumulate::New();
accum->SetInput(input);
accum->SetComponentSpacing(3.2, 3.2,1.5);
double range[2];
input->GetScalarRange(range);
accum->SetComponentExtent(0,
static_cast<int>(range[1] - range[0]), 0, 0, 0, 0);
accum->SetComponentOrigin(static_cast<int>(range[0]),
0, 0);
accum->UpdateWholeExtent();
vtkXYPlotActor* plot = vtkXYPlotActor::New();
plot->ExchangeAxesOff();
plot->SetLabelFormat("%g");
//plot->SetXRange(accum->GetMin()[0],
accum->GetMax()[0]) ;
//or
plot->SetXRange(range[0], range[1]);
plot->SetYRange(0, 20000);
plot->SetXTitle("Iso Surface Level");
plot->SetYTitle("Frequency");
plot->AddInput(accum->GetOutput());
plot->SetXValuesToValue();
aRenderer->AddActor(plot);
renWin->SetSize(640, 480);
// Initialize the event loop and then start it.
iren->Initialize();
iren->Start();
v16->Delete();
accum->Delete();
plot->Delete();
iren->Delete();
renWin->Delete();
aRenderer->Delete();
return 0;
}
The problem is that I am supposed to see a peek in
both : iso surface level of 500 and 1150. For the 1150
it is clearly there but why there is no peek at the
500 Value??
Is it a problem of scaling?
I also need to interact with the plot so the user can
pick at a region of the plot and see what does it
visualize (bone or skin) of the head. It should be
like a GUI.
What class should I use that can help me interacting
with the plot? Anybody has a suggestion?
Thank you.
Ziad
--- Dean Inglis <dean.inglis at camris.ca> wrote:
>
> Here is a pipeline that will do the job:
>
> vtkImageAccumulate* accum =
> vtkImageAccumulate::New();
> accum->SetComponentSpacing(1,0,0);
> accum->SetInput( input /* your vtkImageData */ );
>
> double range[2];
> input->GetScalarRange( range );
> accum->SetComponentExtent( 0 ,
> static_cast<int>(range[1]-range[0]), 0, 0,
> 0, 0 );
> accum->SetComponentOrigin(
> static_cast<int>(range[0]), 0 , 0 );
> accum->UpdateWholeExtent();
>
> vtkXYPlotActor* plot = vtkXYPlotActor::New();
> plot->ExchangeAxesOff();
> plot->SetLabelFormat("%g");
> plot->SetXRange( accum->GetMin()[0],
> accum->GetMax()[0]) ;
> // or
> // plot->SetXRange( range) ;
> plot->AddInput( accum->GetOutput() );
> plot->SetXValuesToValue();
>
> You can do even more interesting things with
> regions of interest
> if you use a vtkImageStencil in your pipeline.
> you could also use a vtkImageThreshold on the
> input to look
> at histogram of soft tissue or hard tissue values
> only.
>
> Dean
>
>
> Hi all,
>
> I am working with a CT dataset consisting of 93
> slices. Probably you all have this dataset as it is
> included in vtk Examples, it is simply the "headsq".
>
> I need to make a histogram of the "skin" and "bone"
> pixels to show how many pixels in the dataset
> represent the skin and how many represent the bone.
>
> I didn't know how to use "vtkImageAccumulate" to
> accomplish this.
>
> The reader is something like the following:
>
> vtkVolume16Reader *v16 = vtkVolume16Reader::New();
> v16->SetDataDimensions (64,64);
> v16->SetImageRange (1,93);
> v16->SetDataByteOrderToLittleEndian();
> v16->SetFilePrefix (argv[1]);
> v16->SetDataSpacing (3.2, 3.2, 1.5);
>
> It would be very appreciated if someone can help me
> or
> give me some hints on how to use
> "vtkImageAccumulate"
> with this dataset.
>
> Thank you
>
>
>
> __________________________________
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
__________________________________
Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs
More information about the vtkusers
mailing list