[Insight-users] Plotting BSpline controlpoints/deformation vectors?
Luis Ibanez
luis.ibanez at kitware.com
Sun Aug 16 11:12:59 EDT 2009
Hi Motes,
You could compose an RGB image to be the final output.
In that case you will be able to mark some pixels with a
visible color (e.g. red).
You will find examples on the use of RGB images in the
ITK Software Guide.
http://www.itk.org/ItkSoftwareGuide.pdf
You simply have to use the itk::RGBPixel<> as the pixel
type of the image that you compose as output.
You may find useful also the following Insight Journal paper:
http://www.insight-journal.org/browse/publication/79
http://hdl.handle.net/1926/172
Regards,
Luis
------------------------------------------------------------------------------------
On Sun, Aug 16, 2009 at 4:52 AM, motes motes <mort.motes at gmail.com> wrote:
> I am looking for a more basic approach. I have tried to update the pixel
> values manually:
>
>
> void updatePixel(){
> std::string input = image_dir + "2D/deform/lena.png";
> std::string output = image_dir + "2D/deform/lena_updated_pixel.png";
>
> fixedImageReader = ImageReaderType::New();
> WriterType::Pointer writer = WriterType::New();
> CastFilterType::Pointer caster = CastFilterType::New();
>
> // Read the input image.
> fixedImageReader->SetFileName(input);
> fixedImageReader->Update(); // make sure this is called before
> accessing the image.
>
> // Modify the input image.
> ImageType::Pointer fixedImage = fixedImageReader->GetOutput();
> ImageType::IndexType pixelIndex;
> pixelIndex[0] = 10;
> pixelIndex[1] = 10;
> ImageType::PixelType pixelValue;
> pixelValue = fixedImage->GetPixel(pixelIndex);
> std::cout << "pixelValue = " << pixelValue << std::endl;
>
>
> fixedImage->SetPixel(pixelIndex, 255);
> // Write the output image.
> writer->SetFileName(output);
> caster->SetInput(fixedImageReader->GetOutput());
> writer->SetInput(caster->GetOutput());
> try {
> writer->Update();
> }
> catch(itk::ExceptionObject & err) {
> std::cerr << "ExceptionObject caught !" << std::endl;
> std::cerr << err << std::endl;
>
> }
> std::cout << "Updated image: " << output << " stored!\n";
>
> }
>
>
> But this not visible unless I update a range of pixels and further it will
> not work in white areas. Unless there are some "markers" (crosses,
> triangles, squares - in color) in ITK that can be written to an image I
> think I will try to do it in gnuplot after the image has been processed.
>
>
>
>
>
>
>
>
> On Sun, Aug 16, 2009 at 2:46 AM, Luis Ibanez <luis.ibanez at kitware.com>wrote:
>
>> Hi Motes,
>>
>> Something that comes to mind is that you could mark the closest
>> pixels to your control points in the image that you are saving.
>>
>> E.g. if you are using a CT image, you could use values around
>> 2000 to highlight the closest pixel to every control point.
>>
>> A second option is that you could create an itkMesh with these
>> points, save it as a vtkPolyData in a .vtk legacy file by using the
>> itkVTKPolyDataWriter, and load it into Paraview, along with your
>> 2D image, then use the Glyph filter on the loaded vtkPolyData.
>>
>> You may also find useful this paper from the Insight Journal:
>>
>> "Gridding Graphic Graticules"
>> by Tustison N., Avants B., Gee J.
>> http://www.insight-journal.org/browse/publication/140
>> http://hdl.handle.net/1926/475
>>
>>
>> Regards,
>>
>>
>> Luis
>>
>>
>> --------------------------------------------------------------
>> On Wed, Aug 12, 2009 at 8:02 AM, motes motes <mort.motes at gmail.com>wrote:
>>
>>>
>>> On Tue, Aug 11, 2009 at 1:41 PM, motes motes <mort.motes at gmail.com>wrote:
>>>
>>>> I am using one of the basic BSplineDeformableTransform examples on some
>>>> 2D CT images of a brain.
>>>>
>>>> Now for each 5 or 10 iteration I would like to view the currently
>>>> registered image and the corresponding BSpline controlpoints (deformation
>>>> vectors).
>>>>
>>>> Are there any functionality in ITK that deals with this kind of
>>>> visualization of registered images in progress and the corresponding
>>>> controlpoints (deformation vectors)?
>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Ok I have now written some code that writes the registered image to disk
>>> after a sequence of N iterations.
>>>
>>> In the future I hope to enable movement of control points in my
>>> application. Therefore I would also like to plot the current position of the
>>> control points on the current registered image.
>>>
>>> I am working on the following idea. When I store the current registered
>>> image, I write the position of the control points to a file.
>>>
>>> Later I can (hopefully) in eg. gnuplot load the image and read in the
>>> corresponding control points and plot them on top of the image.
>>>
>>> If anyone know of a better/easier way (maybe ITK already has examples
>>> showing this?) they are most welcome to give suggestions!
>>>
>>> _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090816/1965ece1/attachment.htm>
More information about the Insight-users
mailing list