[vtkusers] 3D modeling .. some more help plzzzz ...
Pingkun Yan
pingkun at ieee.org
Thu Sep 30 00:00:07 EDT 2004
Hi Florent,
You may try to replace the vtkContourFilter by the vtkMarchingCubes, which
is specialised for extracting contour in volume image and much faster than
the former in this case. It may not solve the problem, but at least it will
speed up your program. Also, you may specify a color for your rendered
object different from your white background...
HTH
Pingkun
----- Original Message -----
From: <Florent.Chandelier at USherbrooke.ca>
To: <vtkusers at vtk.org>
Sent: Thursday, September 30, 2004 5:24 AM
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