[vtkusers] How show in-situ hybridization image data inside 3DSmesh?

Vidyadhar N Kudalkar vidyadhar at lucidindia.com
Thu Oct 9 02:55:52 EDT 2008


I think you need to assign origin and spacing for the image data which you 
read-in using tiff reader. You can also scale and reposition the mesh read 
from 3DS file.
HTH
Vidyadhar
----- Original Message ----- 
From: "Carl Trapani" <carl at skytopsoftware.com>
To: "vtkusers" <vtkusers at vtk.org>
Sent: Thursday, October 09, 2008 4:00 AM
Subject: [vtkusers] How show in-situ hybridization image data inside 
3DSmesh?


Hi All,

I have a stack of in-situ hybridization sagittal cross section
images of the mouse cerebellum which show gene expression patterns.
I need to display these expression spots within a 3D mesh loaded
from a 3DS file.

I was able to load the 3DS model and my stack of images using
vtk3DSImporter and vtkTIFFReader along with vtkContourFilter
following the Medical1.cxx example. See my code below. A snap
shot of the rendering can be seen here:

http://tinyurl.com/4hjcwh

The 3DS model is white/gray, the spot data contours are red-ish.
The white box is an outline of the image stack.

1) How can I fit the spot data inside the mesh? I tried using
vtkResampleImage, but that did not change the image stack size.
It simply resampled the image to a be coarser. See results here:

http://tinyurl.com/3um653

2) Are there other filters that would better represent my spot data?
While contouring seems to work ok, I'm not sure this is the best
choice. The gene expressions spots are discrete and may not follow
contour lines.

Thanks for any input you might have.
Carl

//-----------BEGIN CODE----------
#include <string>
#include <iostream>

#include "vtkStringArray.h"
#include "vtkProperty.h"

#include "vtk3DSImporter.h"
#include "vtkTIFFReader.h"

#include "vtkImageData.h"

#include "vtkImageCast.h"
#include "vtkImageResample.h"
#include "vtkContourFilter.h"
#include "vtkPolyDataNormals.h"
#include "vtkOutlineFilter.h"

#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"

int main(int argc, char *argv[])
{

    std::string modelName = "model\\p5-object.3DS";
    vtkStringArray* ish_images = vtkStringArray::New();
        ish_images->SetName("ish_images");

        ish_images->InsertNextValue("images\\325-flip_ish_spots.tif");
        ish_images->InsertNextValue("images\\345-flip_ish_spots.tif");
        ish_images->InsertNextValue("images\\365-flip_ish_spots.tif");
        ish_images->InsertNextValue("images\\385-flip_ish_spots.tif");
        ish_images->InsertNextValue("images\\405-flip_ish_spots.tif");
        ish_images->InsertNextValue("images\\425-flip_ish_spots.tif");
        ish_images->InsertNextValue("images\\445-flip_ish_spots.tif");
        ish_images->InsertNextValue("images\\465-flip_ish_spots.tif");
        ish_images->InsertNextValue("images\\485-flip_ish_spots.tif");
        ish_images->InsertNextValue("images\\505-flip_ish_spots.tif");

    // Read 3DS model into the scene
    vtk3DSImporter *importer = vtk3DSImporter::New();
        importer->SetFileName( modelName.c_str() );
        importer->Read();

    // Get importers renderer, render window and setup a
    // render window interactor
    vtkRenderer *ren = importer->GetRenderer();
    vtkRenderWindow *renWin = importer->GetRenderWindow();
    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
        iren->SetRenderWindow( renWin );

    // Read stack of RGB images.
    // Images are all 1392 x 1040 pixels with 0.6µm/pixel resolution.
    // There are 10 images in the stack, each spaced 20µm apart.
    vtkTIFFReader* reader = vtkTIFFReader::New();
        reader->SetFileNames( ish_images );
        reader->SetDataExtent( 0,1391, 0,1039, 1,10 );
        reader->SetDataSpacing( 0.6, 0.6, 100 );
        reader->SetDataOrigin( 0.0, 0.0, 0.0 );
        reader->UpdateWholeExtent();

        cout << endl << "TIFFReader:" << endl;
        reader->PrintSelf(cout, vtkIndent(2));

    //vtkImageCast* cast = vtkImageCast::New();
    //    cast->SetInputConnection( reader->GetOutputPort() );
    //    cast->SetOutputScalarType( reader->GetOutput()->GetScalarType() );
    //    cast->ClampOverflowOn();

    // Resample the images down to fit inside the model?
    vtkImageResample *shrinker = vtkImageResample::New();
        //shrinker->SetInputConnection( cast->GetOutputPort() );
    shrinker->SetInputConnection( reader->GetOutputPort() );
        shrinker->SetAxisMagnificationFactor( 0, 0.1 );
        shrinker->SetAxisMagnificationFactor( 1, 0.1 );
        shrinker->SetAxisMagnificationFactor( 2, 1 );

    // The images have already been manually thresholded.
    // A combined histogram of the gray scale equivalent for
    // all of the RGB images shows a signal range from 51 to 181.
    // The most fequent signal value is 144. By grayscale equivalent
    // I mean:
    //        gray_scale_value = (red + green + blue)/3
    vtkContourFilter *geneExtractor = vtkContourFilter::New();
        geneExtractor->SetInputConnection( shrinker->GetOutputPort() );
        geneExtractor->Update();

        cout << endl << "Initial vtkContourFilter values:" << endl;
        geneExtractor->PrintSelf(cout, vtkIndent(2));

        // Generate 10 contour values between 51 and 181
        geneExtractor->GenerateValues(10, 51, 181);

        cout << endl << "Final vtkContourFilter values:" << endl;
        geneExtractor->PrintSelf(cout, vtkIndent(2));

    vtkPolyDataNormals *geneNormals = vtkPolyDataNormals::New();
        geneNormals->SetInputConnection(geneExtractor->GetOutputPort());
        geneNormals->SetFeatureAngle(60.0);

    vtkPolyDataMapper *geneMapper = vtkPolyDataMapper::New();
        geneMapper->SetInputConnection(geneNormals->GetOutputPort());
        geneMapper->ScalarVisibilityOff();

    vtkActor *geneActor = vtkActor::New();
        geneActor->SetMapper(geneMapper);
        geneActor->GetProperty()->SetDiffuseColor(1, .49, .25);
        geneActor->GetProperty()->SetSpecular(.3);
        geneActor->GetProperty()->SetSpecularPower(20);
        geneActor->GetProperty()->SetOpacity(1.0);

    ren->AddActor( geneActor );

    // Use vtkOutlineFilter to outline the image stack
    vtkOutlineFilter *outlineData = vtkOutlineFilter::New();
        outlineData->SetInputConnection(reader->GetOutputPort());
    vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();
        mapOutline->SetInputConnection(outlineData->GetOutputPort());
    vtkActor *outline = vtkActor::New();
        outline->SetMapper(mapOutline);
        outline->GetProperty()->SetColor( 1.0, 1.0, 1.0 );

    ren->AddActor( outline );

    // Display Model and Volume
    iren->Initialize();
    iren->Start();

    // Clean up
    outline->Delete();
    mapOutline->Delete();
    outlineData->Delete();
    geneActor->Delete();
    geneMapper->Delete();
    geneNormals->Delete();
    geneExtractor->Delete();
    shrinker->Delete();
    reader->Delete();
    iren->Delete();
    importer->Delete();
    ish_images->Delete();

    return 0;
};
//-----------END CODE----------
_______________________________________________
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 




More information about the vtkusers mailing list