[vtkusers] histogram

Laurent Mundeleer lmundele at ulb.ac.be
Mon Jan 5 09:54:41 EST 2004


Hi all,

I have some problem making histogram of an image to begin, and a stack 
of images next. I've try to start from th examples of accumulate 
fonction, but I have a blank result. Here's a part of my code :

/////////////////////////
#include "histogramVTK.h"

histogramVTK::histogramVTK()
{
    clip = vtkImageClip::New();
    accumulate = vtkImageAccumulate::New();
//    canvas = vtkImageCanvasSource2D::New();

//    clip->setInput(imageToClip->getOutput());
    accumulate->SetInput(clip->GetOutput());
/* canvas->setInput(accumulate->getOutput());
    canvas->SetScalarTypeToUnsignedChar();
   canvas->SetNumberOfScalarComponents(3);
*/
}
histogramVTK::~histogramVTK()
{
    clip->Delete();
    accumulate->Delete();
}
void histogramVTK::setInput (vtkImageData *imageToClip)
{
    clip->SetInput(imageToClip);
    clip->Update();

}

void histogramVTK::setExtent (int x1,int x2, int y1, int y2, int z1, int z2)
{
    clip->SetOutputWholeExtent(x1, x2, y1, y2, z1, z2);
}

void histogramVTK::initialize (int origin, int numBins, int spacing)
{
    accumulate->SetComponentExtent(0,numBins - 1, 0, 0, 0, 0); // nbr de 
bins min max en x y z
    accumulate->SetComponentOrigin(origin, 0.0, 0.0); // origine du bin 
(0,0,0)
    accumulate->SetComponentSpacing(spacing, 0.0, 0.0); // taille des bins
 /*  
    canvas->setExtent(0, width - 1, 0, height - 1, 0, 0);
    canvas->setDrawColor (255);
    canvas->setDrawColor (172, 174, 241);
    canvas->fillBox 0 (width - 1, 0, height - 1);
    canvas->setDrawColor (0);
    canvas->setDrawColor (137, 28, 28);
*/
    accumulate->Update();
}

vtkImageData* histogramVTK::getHistogram()
{
    return accumulate->GetOutput();
}
//////////////////////////////////////
......
///////////////////////////

vtkImageData* sourceControlVTK::viewHistogram()
{   
    histogram->setInput(reader->GetOutput()); // reader : vtkImageReader
    histogram->initialize(0,200,10);// origine, numBins, spacing
    return histogram->getHistogram();
}
//////////////////////////
........
/////////////////////////
    mapper->SetInput(histo); // output of histogram
////////////////////////

I don't know if it's clear, but maybe you can help me...

thanks

Laurent

-- 
********************************************
Laurent Mundeleer
Université Libre de Bruxelles (ULB)
Service des Systèmes Logiques et Numériques (SLN) CP165/57
50, Av. F.Roosevelt
1050 Bruxelles
Belgium
tel : ++32.2.650.22.97
fax : ++32.2.650.22.98
e-mail : lmundele at ulb.ac.be
********************************************





More information about the vtkusers mailing list