[vtkusers] vtkImageCanvasSource2D output

Morten Wigen morten.wigen at gmail.com
Mon Apr 14 10:44:14 EDT 2014


Hi!
I have a goal to manually add trace points to a generated spectrum. The
spectrum is a vtkImageData, and the trace line I will create is made with
the object vtkImageCanvasSource2D. To merge this on top of each other I use
vtkImageBlend. This is pretty much the same procedure as in the example in
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/DrawOnAnImage.

However, the resulting drawing has got a background to the actual drawing.
So when I put this on top of my spectrum it is occluded by the background
as well as the wanted drawing. The code I use is as follows;


    // Draw a circle in the center of the image
    vtkSmartPointer<vtkImageCanvasSource2D> drawing =
vtkSmartPointer<vtkImageCanvasSource2D>::New();

    drawing->SetNumberOfScalarComponents(3);

    drawing->SetScalarTypeToUnsignedChar();


    drawing->SetExtent(image->GetExtent());
    drawing->SetDrawColor(0, 0, 0);

    drawing->DrawCircle(center[0], center[1], radius);

    drawing->UpdateWholeExtent();

    // Combine the images (blend takes multiple connections on the 0th
    // input port)
    vtkSmartPointer<vtkImageBlend> blend =
    vtkSmartPointer<vtkImageBlend>::New();
    blend->AddInput(image);
    blend->AddInput(drawing->GetOutput());

    blend->SetOpacity(0,1);
    blend->SetOpacity(1,.5); //The transparecy on the drawing

    texture->SetInput(blend->GetOutput());//drawing->GetOutput());
image->GetOutput());

Under you can see the different output images I get when adding the
different images to the texture. (The circle I use is just for testing.)

Does anyone know how to remove this background?
I also wonder why the circle has so low resolution. So if anyone has the
answer to that as well I it would be really great!

Hope to hear from you! :)

Best regards,
Morten Wigen

blend:
[image: Inline image 3]
image:
[image: Inline image 4]

drawing:
[image: Inline image 5]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140414/f34bac2c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Blend.jpg
Type: image/jpeg
Size: 66065 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140414/f34bac2c/attachment-0003.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Spectrum.jpg
Type: image/jpeg
Size: 93712 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140414/f34bac2c/attachment-0004.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Drawing.jpg
Type: image/jpeg
Size: 16787 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140414/f34bac2c/attachment-0005.jpg>


More information about the vtkusers mailing list