[vtkusers] 3D modeling .. some more help plzzzz ...

dean.inglis at camris.ca dean.inglis at camris.ca
Wed Sep 29 20:31:03 EDT 2004


Florent, 

you have to call Update() first on your reader or you will get
odd results if you try to find out the scalar range of
the readers output (see previous response).

If your images are of defatted bone, then why do you care
about non-bone?  The boundary between bone and non-bone
is already being found by the contour filter as you had set up
before.  If you post a sample bmp on a web site I would be
interested in having a look.

Dean

> 
> From: "Florent.Chandelier at USherbrooke.ca" <Florent.Chandelier at USherbrooke.ca>
> Date: 2004/09/29 Wed PM 05:24:18 GMT-04:00
> To: <dean.inglis at camris.ca>
> Subject: Re: [vtkusers] 3D modeling .. some more help plzzzz ...
> 
> First of all, ppl told me the samples I'm working on were defatted 
> before being imaged so the attenuaiton of the beam is due to bone only, 
> so no soft tissue ... that what to can see using matlab histogram of the 
> images ...
> I only have bmp images, not the raw data .. but all my lab work with the 
> bmp files ... but I'm the only one using VTK in the lab (others use 
> licenced soft )
> The aim of my job so far is to  get cavities ( everything but bone 
> structure) to analyse the fluid movements in bone .. using an 
> appropriate model, that I'll have to design after getting the 3D model 
> of the non-bone structure .. that's why I'm not interesting to the bone 
> structure directly.
> 
> Well Here is the answer of your mail :
> 
> here is what I put in my code :
> // read bmp file
>   vtkBMPReader *imagein=vtkBMPReader::New();
>   imagein->SetFilePrefix ("slices"); // name of the files to read
>   imagein->SetDataExtent(0, 255, 0, 255,0,5);
> 
>   float* range = imagein->GetOutput()->GetScalarRange();
>  
>   printf("range 0:%10.3f\n",range[0]);
>   printf("range 1:%10.3f\n",range[1]);
> 
> coz it is float and not double ( imagein is float and I got an error 
> using the double thing) ..... and I may say I'm quite surprised coz the 
> results were respectively 0 and 1 .... but I'm doing the thresholding  
> on 100-220 that works fine ..; and looking under matlab give me a range 
> of 60-255 !!!
> 
> BTW
> a set value of 255 render bone structure
> a setValue of 254 render the bone structure ??? and I don t get why ( 
> I've never try before)
> a set value of 101 render bone structure ??
> a set value of  100 render nothing
> a set value of 99 render nothing, and neither for 97,90,80,60,40,20
> 
> Well I may say I'm quite confused now ...!!! my threshold seems not to 
> work or at least gives me something that I don't understand ... and all 
> the float values I have are between 0 and 1 ... well Thx for pointing 
> this out to me !!
> 
> If you have the time to take a look at it I can send you few slices
> 
> I resend my code in case something have change:
> 
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkStructuredPointsReader.h"
> #include "vtkPiecewiseFunction.h"
> #include "vtkVolumeProperty.h"
> #include "vtkVolumeRayCastCompositeFunction.h"
> #include "vtkVolumeRayCastMapper.h"
> #include "vtkVolume.h"
> #include "vtkBMPReader.h"
> #include "vtkCamera.h"
> #include "vtkContourFilter.h"
> #include "vtkPolyDataNormals.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkActor.h"
> #include "vtkProperty.h"
> #include "vtkDecimatePro.h"
> #include "vtkSmoothPolyDataFilter.h"
> #include "vtkSTLWriter.h"
> #include "vtkTriangleFilter.h"
> #include "vtkImageThreshold.h"
> #include "vtkImageShiftScale.h"
> #include "vtkTriangleFilter.h"
> #include "vtkSTLWriter.h"
> #include "vtkImageData.h"
> 
> 
> 
> 
> void main( int argc, char *argv[] )
> 
> {
> 
>   vtkRenderer *aRenderer = vtkRenderer::New();
>   vtkRenderWindow *renWinf = vtkRenderWindow::New();
>   renWinf->AddRenderer(aRenderer);
>   vtkRenderWindowInteractor *irenf = vtkRenderWindowInteractor::New();
>   irenf->SetRenderWindow(renWinf);
> 
> 
>   // read bmp file
>   vtkBMPReader *imagein=vtkBMPReader::New();
>   imagein->SetFilePrefix ("slices"); // name of the files to read
>   imagein->SetDataExtent(0, 255, 0, 255,0,5);
> 
>   float* range = imagein->GetOutput()->GetScalarRange();
>  
>   printf("range 0:%10.3f\n",range[0]);
>   printf("range 1:%10.3f\n",range[1]);
>  
> 
>   // thresholding and "binarising" the images
> 
>   int TissueLow;
>   int TissueHigh;
> 
>   TissueLow=100;
>   TissueHigh=220;
> 
>   vtkImageThreshold *binimg=vtkImageThreshold::New();
>   binimg->SetInput(imagein->GetOutput());   
>   binimg->ThresholdBetween(TissueLow,TissueHigh);
>   binimg->SetInValue(255); // bone value -> bone will appeared bright
>   binimg->SetOutValue(100); // tissue value -> tissue will be light-gray
> 
>   
>   // rendering
>   vtkContourFilter *Extractor = vtkContourFilter::New();
>   Extractor->SetInput((vtkDataSet *) binimg->GetOutput());
>   Extractor->SetValue(0,97);
>  
> 
>  
>   vtkPolyDataMapper *Mapper = vtkPolyDataMapper::New();
>   Mapper->SetInput(Extractor->GetOutput());
>   Mapper->ScalarVisibilityOff();
> 
> 
>  
>   vtkActor *result = vtkActor::New();
>   result->SetMapper(Mapper);
>   aRenderer->AddActor(result);
>   //aRenderer->SetBackground(1,1,1);
> 
> 
>   // Interact with the data at 3 frames per second
>   irenf->SetDesiredUpdateRate(1.0);
>   irenf->SetStillUpdateRate(0.001);
>   irenf->Start();
> 
> 
>   // Set the size of the render window (expressed in pixels).
>   renWinf->SetSize(300, 300);
>   renWinf->Render();
>   // Start the Interactor
>   irenf->Start();
> 
>  
> 
>   // Clean up
>   renWinf->Delete();
>   aRenderer->Delete();
>   irenf->Delete();
>   imagein->Delete();
>   result->Delete();
>   Mapper->Delete();
>   Extractor->Delete();
>  
>  
> }
> 
> 
> 
> -- 
> Florent Chandelier - florent.chandelier at usherbrooke.ca
> PhD Student at the university of Sherbrooke (QC, Canada)
> Bio mechanical research department - http://www.biomec.gme.usherb.ca/
> 
> Lab Phone : (001) (819)-821-7000
> 
> 




More information about the vtkusers mailing list