Skip to content

Commit a82f59e

Browse files
hjmjohnsondzenanz
authored andcommitted
ENH: Adding media wiki examples to sphinx examples
Moved several hundered wiki-examples from the media wiki site to the sphinx examples site.
1 parent 8f2d2a1 commit a82f59e

File tree

849 files changed

+42946
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

849 files changed

+42946
-3
lines changed

src/Bridge/VtkGlue/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ add_example(ConvertAnitkImageTovtkImageData)
22
add_example(ConvertAnRGBitkImageTovtkImageData)
33
add_example(ConvertvtkImageDataToAnitkImage)
44
add_example(ConvertRGBvtkImageDataToAnitkImage)
5+
6+
add_example(VTKImageToITKImage)
7+
compare_to_baseline(EXAMPLE_NAME VTKImageToITKImage
8+
BASELINE_PREFIX OutputBaseline
9+
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cmake_minimum_required(VERSION 3.10.2)
2+
3+
project(VTKImageToITKImage)
4+
5+
find_package(ITK REQUIRED)
6+
include(${ITK_USE_FILE})
7+
8+
9+
add_executable(VTKImageToITKImage Code.cxx)
10+
target_link_libraries(VTKImageToITKImage ${ITK_LIBRARIES})
11+
12+
install(TARGETS VTKImageToITKImage
13+
DESTINATION bin/ITKExamples/Bridge/VtkGlue
14+
COMPONENT Runtime
15+
)
16+
17+
install(FILES Code.cxx CMakeLists.txt
18+
DESTINATION share/ITKExamples/Code/Bridge/VtkGlue/VTKImageToITKImage/
19+
COMPONENT Code
20+
)
21+
22+
23+
enable_testing()
24+
add_test(NAME VTKImageToITKImageTest
25+
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/VTKImageToITKImage)
26+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*=========================================================================
2+
*
3+
* Copyright Insight Software Consortium
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0.txt
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*=========================================================================*/
18+
#include <itkImage.h>
19+
20+
#include <itkVTKImageToImageFilter.h>
21+
22+
#include "vtkSmartPointer.h"
23+
#include "vtkPNGReader.h"
24+
#include <vtkImageLuminance.h>
25+
26+
#include "QuickView.h"
27+
28+
int main(int argc, char*argv[])
29+
{
30+
if(argc < 2)
31+
{
32+
std::cerr << "Required: filename" << std::endl;
33+
return EXIT_FAILURE;
34+
}
35+
36+
vtkSmartPointer<vtkPNGReader> reader =
37+
vtkSmartPointer<vtkPNGReader>::New();
38+
reader->SetFileName(argv[1]);
39+
// reader->SetNumberOfScalarComponents(1); //doesn't seem to work - use ImageLuminance instead
40+
reader->Update();
41+
42+
43+
// Must convert image to grayscale because itkVTKImageToImageFilter only accepts single channel images
44+
vtkSmartPointer<vtkImageLuminance> luminanceFilter =
45+
vtkSmartPointer<vtkImageLuminance>::New();
46+
luminanceFilter->SetInputConnection(reader->GetOutputPort());
47+
luminanceFilter->Update();
48+
49+
using ImageType = itk::Image<unsigned char, 2>;
50+
51+
using VTKImageToImageType = itk::VTKImageToImageFilter<ImageType>;
52+
53+
VTKImageToImageType::Pointer vtkImageToImageFilter = VTKImageToImageType::New();
54+
vtkImageToImageFilter->SetInput(luminanceFilter->GetOutput());
55+
//vtkImageToImageFilter->SetInput(reader->GetOutput());
56+
vtkImageToImageFilter->Update();
57+
58+
ImageType::Pointer image = ImageType::New();
59+
image->Graft(vtkImageToImageFilter->GetOutput()); // Need to do this because QuickView can't accept const
60+
61+
QuickView viewer;
62+
viewer.AddImage(image.GetPointer()); // Need to do this because QuickView can't accept smart pointers
63+
viewer.Visualize();
64+
65+
return EXIT_SUCCESS;
66+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
VTK Image To ITK Image
2+
======================
3+
.. warning::
4+
**Fix Problem**
5+
Contains problems not fixed from original wiki.
6+
.. index::
7+
single: VTKImageToImageFilter
8+
9+
Synopsis
10+
--------
11+
12+
Convert a VTK image to an ITK image.
13+
14+
15+
Results
16+
-------
17+
.. note::
18+
**Help Wanted**
19+
Implementation of Results for sphinx examples containing this message.
20+
Reconfiguration of CMakeList.txt may be necessary.
21+
`Write An Example <https://itk.org/ITKExamples/Documentation/Contribute/WriteANewExample.html`>
22+
23+
Code
24+
----
25+
26+
C++
27+
...
28+
29+
.. literalinclude:: Code.cxx
30+
:lines: 18-
31+
32+
Classes demonstrated
33+
--------------------
34+
35+
.. breathelink:: itk::VTKImageToImageFilter

src/Bridge/VtkGlue/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ VtkGlue
88
ConvertAnRGBitkImageTovtkImageData/Documentation.rst
99
ConvertvtkImageDataToAnitkImage/Documentation.rst
1010
ConvertRGBvtkImageDataToAnitkImage/Documentation.rst
11+
VTKImageToITKImage/Documentation.rst

src/Compatibility/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory_if_module_enabled(Deprecated)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
add_example(ResampleRGBImage)
3+
compare_to_baseline(EXAMPLE_NAME ResampleRGBImage
4+
BASELINE_PREFIX OutputBaseline
5+
)
6+
7+
add_example(ResampleITKVectorImage)
8+
compare_to_baseline(EXAMPLE_NAME ResampleITKVectorImage
9+
BASELINE_PREFIX OutputBaseline
10+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
cmake_minimum_required(VERSION 3.10.2)
2+
3+
project(ResampleITKVectorImage)
4+
5+
find_package(ITK REQUIRED)
6+
include(${ITK_USE_FILE})
7+
8+
9+
add_executable(ResampleITKVectorImage Code.cxx)
10+
target_link_libraries(ResampleITKVectorImage ${ITK_LIBRARIES})
11+
12+
install(TARGETS ResampleITKVectorImage
13+
DESTINATION bin/ITKExamples/Compatibility/Deprecated
14+
COMPONENT Runtime
15+
)
16+
17+
install(FILES Code.cxx CMakeLists.txt
18+
DESTINATION share/ITKExamples/Code/Compatibility/Deprecated/ResampleITKVectorImage/
19+
COMPONENT Code
20+
)
21+
22+
enable_testing()
23+
add_test(NAME ResampleITKVectorImageTest
24+
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ResampleITKVectorImage)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*=========================================================================
2+
*
3+
* Copyright Insight Software Consortium
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0.txt
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*=========================================================================*/
18+
/*
19+
#include "itkImage.h"
20+
#include "itkVectorResampleImageFilter.h"
21+
#include "itkVectorImage.h"
22+
23+
int main(int, char *[])
24+
{
25+
typedef itk::VectorImage<double, 2> VectorImageType;
26+
27+
VectorImageType::Pointer image = VectorImageType::New();
28+
itk::Index<2> start;
29+
start.Fill(0);
30+
31+
itk::Size<2> size;
32+
size.Fill(10);
33+
34+
itk::ImageRegion<2> region(start,size);
35+
image->SetRegions(region);
36+
image->SetNumberOfComponentsPerPixel(3);
37+
image->Allocate();
38+
image->FillBuffer(itk::NumericTraits<VectorImageType::InternalPixelType>::Zero);
39+
40+
typedef itk::VectorResampleImageFilter< VectorImageType, VectorImageType > VectorResampleFilterType;
41+
VectorResampleFilterType::Pointer vectorResampleFilter = VectorResampleFilterType::New();
42+
vectorResampleFilter->SetInput(image);
43+
vectorResampleFilter->Update();
44+
45+
return EXIT_SUCCESS;
46+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Resample A Vector Image
2+
=======================
3+
.. note::
4+
**Wish List**
5+
Still needs additional work to finish proper creation of example.
6+
.. index::
7+
single: VectorResampleImageFilter
8+
9+
Synopsis
10+
--------
11+
12+
Resample an itk::VectorImage.
13+
14+
15+
Results
16+
-------
17+
.. note::
18+
**Help Wanted**
19+
Implementation of Results for sphinx examples containing this message.
20+
Reconfiguration of CMakeList.txt may be necessary.
21+
`Write An Example <https://itk.org/ITKExamples/Documentation/Contribute/WriteANewExample.html`>
22+
Code
23+
----
24+
25+
C++
26+
...
27+
28+
.. literalinclude:: Code.cxx
29+
:lines: 18-
30+
31+
Classes demonstrated
32+
--------------------
33+
34+
.. breathelink:: itk::VectorResampleImageFilter
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
cmake_minimum_required(VERSION 3.10.2)
2+
3+
project(ResampleRGBImage)
4+
5+
find_package(ITK REQUIRED)
6+
include(${ITK_USE_FILE})
7+
8+
9+
add_executable(ResampleRGBImage Code.cxx)
10+
target_link_libraries(ResampleRGBImage ${ITK_LIBRARIES})
11+
12+
install(TARGETS ResampleRGBImage
13+
DESTINATION bin/ITKExamples/Compatibility/Deprecated
14+
COMPONENT Runtime
15+
)
16+
17+
install(FILES Code.cxx CMakeLists.txt
18+
DESTINATION share/ITKExamples/Code/Compatibility/Deprecated/ResampleRGBImage/
19+
COMPONENT Code
20+
)
21+
22+
23+
enable_testing()
24+
add_test(NAME ResampleRGBImageTest
25+
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ResampleRGBImage)

0 commit comments

Comments
 (0)