Skip to content

Commit 1180a30

Browse files
authored
Merge pull request InsightSoftwareConsortium#6103 from hjmjohnson/ingest-Montage
ENH: Ingest ITKMontage remote module into Modules/Registration/Montage Previously passed all tests, only updated to test the behavior of "Populate ExternalData Cache".
2 parents 7fabe2d + f9fd225 commit 1180a30

626 files changed

Lines changed: 13880 additions & 51 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
cmake_minimum_required(VERSION 3.16.3)
2+
3+
if(CMAKE_CXX_STANDARD EQUAL "98")
4+
message(
5+
FATAL_ERROR
6+
"CMAKE_CXX_STANDARD:STRING=98 is not supported in ITK version 5 and greater."
7+
)
8+
endif()
9+
10+
if(NOT CMAKE_CXX_STANDARD)
11+
set(CMAKE_CXX_STANDARD 17) # Supported values are ``17``, ``20``, and ``23``.
12+
endif()
13+
if(NOT CMAKE_CXX_STANDARD_REQUIRED)
14+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
15+
endif()
16+
if(NOT CMAKE_CXX_EXTENSIONS)
17+
set(CMAKE_CXX_EXTENSIONS OFF)
18+
endif()
19+
20+
project(Montage)
21+
22+
set(Montage_LIBRARIES Montage)
23+
24+
# Suppress warnings about potentially uninstantiated static members
25+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
26+
include(CheckCXXCompilerFlag)
27+
check_cxx_compiler_flag(
28+
"-Wno-undefined-var-template"
29+
COMPILER_HAS_NO_UNDEFINED_VAR_TEMPLATE
30+
)
31+
if(COMPILER_HAS_NO_UNDEFINED_VAR_TEMPLATE)
32+
set(CMAKE_CXX_FLAGS "-Wno-undefined-var-template ${CMAKE_CXX_FLAGS}")
33+
endif()
34+
endif()
35+
36+
if(NOT ITK_SOURCE_DIR)
37+
find_package(ITK REQUIRED)
38+
list(APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR})
39+
include(ITKModuleExternal)
40+
else()
41+
set(ITK_DIR ${CMAKE_BINARY_DIR})
42+
itk_module_impl()
43+
endif()
44+
45+
itk_module_examples()
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Montage
2+
3+
Mosaic-stitching and 3D reconstruction of large datasets from a
4+
collection of partially-overlapping 2D slices, built around phase
5+
correlation image registration. Core classes:
6+
7+
- `itk::PhaseCorrelationImageRegistrationMethod`
8+
- `itk::PhaseCorrelationOperator`
9+
- `itk::PhaseCorrelationOptimizer`
10+
- `itk::TileMontage`
11+
- `itk::TileMergeImageFilter`
12+
- `itk::TileConfiguration`
13+
- `itk::NMinimaMaximaImageCalculator`
14+
15+
## Upstream
16+
17+
This module was originally developed and maintained as a standalone
18+
remote module at
19+
<https://github.com/InsightSoftwareConsortium/ITKMontage>. The
20+
contents of `include/`, `src/`, `test/`, `wrapping/`, and the two
21+
CMake build descriptors (`CMakeLists.txt`, `itk-module.cmake`) were
22+
ingested into ITK via `Utilities/Maintenance/RemoteModuleIngest/`
23+
(see PR #6098 for the tooling).
24+
25+
The standalone upstream repository should be treated as archived
26+
once this ingest lands. Refer to its tags and release history for
27+
provenance, but future development happens in-tree here.
28+
29+
## What is intentionally NOT ingested
30+
31+
The whitelist-based ingest deliberately excludes the following
32+
upstream content from ITK:
33+
34+
- `examples/` — applied demonstration code and sample datasets;
35+
lives with the archived upstream (and selectively relocated to
36+
[`Examples/`](https://github.com/InsightSoftwareConsortium/ITK/tree/main/Examples)
37+
in a follow-up PR if broadly useful).
38+
- `.github/workflows/` — upstream-specific CI configuration; ITK's
39+
in-tree CI covers the module via the central pipeline.
40+
- `CTestConfig.cmake` — pointed at a standalone CDash project that
41+
no longer applies in-tree.
42+
- `README.md`, `LICENSE`, `requirements.txt`, `pyproject.toml` and
43+
similar scaffolding — top-level packaging files that are either
44+
inherited from ITK's own policy (Apache 2.0 license, etc.) or
45+
irrelevant in-tree.
46+
47+
If you need any of the above, consult the archived upstream.
48+
49+
## Compliance level
50+
51+
Previously tracked as a level-3 remote module (see the superseded
52+
`Modules/Remote/Montage.remote.cmake`). In-tree placement does not
53+
automatically raise the compliance level; continued stewardship is
54+
needed to reach levels 4 and 5.
55+
56+
## Contact
57+
58+
Originally authored and maintained by Dženan Zukić
59+
&lt;dzenan.zukic@kitware.com&gt;. In-tree maintenance follows ITK's
60+
standard review process.
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
/*=========================================================================
2+
*
3+
* Copyright NumFOCUS
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+
* https://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+
#ifndef itkNMinimaMaximaImageCalculator_h
19+
#define itkNMinimaMaximaImageCalculator_h
20+
21+
#include "itkMacro.h"
22+
#include "itkObject.h"
23+
#include "itkObjectFactory.h"
24+
#include <mutex>
25+
#include <vector>
26+
27+
namespace itk
28+
{
29+
/** \class NMinimaMaximaImageCalculator
30+
* \brief Computes the N highest and/or lowest intensity values of an image.
31+
*
32+
* This class is templated over input image type. If only Maxima or
33+
* Minima are needed, just call ComputeMaxima() or ComputeMinima().
34+
* Compute() will compute both.
35+
*
36+
* \ingroup Operators
37+
* \ingroup ITKCommon
38+
* \ingroup Montage
39+
*/
40+
template <typename TInputImage>
41+
class ITK_TEMPLATE_EXPORT NMinimaMaximaImageCalculator : public Object
42+
{
43+
public:
44+
ITK_DISALLOW_COPY_AND_MOVE(NMinimaMaximaImageCalculator);
45+
46+
/** Standard class type aliases. */
47+
using Self = NMinimaMaximaImageCalculator;
48+
using Superclass = Object;
49+
using Pointer = SmartPointer<Self>;
50+
using ConstPointer = SmartPointer<const Self>;
51+
52+
/** Method for creation through the object factory. */
53+
itkNewMacro(Self);
54+
55+
/** Run-time type information (and related methods). */
56+
itkOverrideGetNameOfClassMacro(NMinimaMaximaImageCalculator);
57+
58+
/** Type definition for the input image. */
59+
using ImageType = TInputImage;
60+
61+
/** Pointer type for the image. */
62+
using ImagePointer = typename TInputImage::Pointer;
63+
64+
/** Const Pointer type for the image. */
65+
using ImageConstPointer = typename TInputImage::ConstPointer;
66+
67+
/** Type definition for the input image pixel type. */
68+
using PixelType = typename TInputImage::PixelType;
69+
70+
/** Image dimensionality */
71+
static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
72+
// constexpr unsigned ImageDimension = TInputImage::VImageDimension;
73+
74+
/** Type definition for the input image index type. */
75+
using IndexType = typename TInputImage::IndexType;
76+
77+
/** Type definition for the input image region type. */
78+
using RegionType = typename TInputImage::RegionType;
79+
80+
/** Sorted vector of minima or maxima. */
81+
using ValueVector = std::vector<PixelType>;
82+
83+
/** Sorted vector of pixel indices of minima or maxima. */
84+
using IndexVector = std::vector<IndexType>;
85+
86+
87+
/** Set the input image. */
88+
itkSetConstObjectMacro(Image, ImageType);
89+
90+
/** Compute the minimum value of intensity of the input image. */
91+
void
92+
ComputeMinima();
93+
94+
/** Compute the maximum value of intensity of the input image. */
95+
void
96+
ComputeMaxima();
97+
98+
/** Compute the minimum and maximum values of intensity of the input image. */
99+
void
100+
Compute();
101+
102+
/** Return the N minimum intensity values. */
103+
itkGetConstReferenceMacro(Minima, ValueVector);
104+
105+
/** Return the N maximum intensity values. */
106+
itkGetConstReferenceMacro(Maxima, ValueVector);
107+
108+
/** Return the indices of the N minimum intensity values. */
109+
itkGetConstReferenceMacro(IndicesOfMinima, IndexVector);
110+
111+
/** Return the indices of the N maximum intensity values. */
112+
itkGetConstReferenceMacro(IndicesOfMaxima, IndexVector);
113+
114+
/** Set the region over which the values will be computed */
115+
void
116+
SetRegion(const RegionType & region);
117+
118+
/** Get/Set the number of extreme intensity values to keep. */
119+
itkGetConstMacro(N, SizeValueType);
120+
itkSetMacro(N, SizeValueType);
121+
122+
protected:
123+
NMinimaMaximaImageCalculator();
124+
~NMinimaMaximaImageCalculator() override = default;
125+
void
126+
PrintSelf(std::ostream & os, Indent indent) const override;
127+
128+
template <typename TComparator = std::less<PixelType>>
129+
void
130+
SortedInsert(ValueVector & vals,
131+
IndexVector & indices,
132+
const PixelType & val,
133+
const IndexType & ind,
134+
TComparator comp = TComparator());
135+
void
136+
InternalCompute();
137+
138+
private:
139+
ImageConstPointer m_Image;
140+
ValueVector m_Minima;
141+
ValueVector m_Maxima;
142+
IndexVector m_IndicesOfMinima;
143+
IndexVector m_IndicesOfMaxima;
144+
SizeValueType m_N{ 7 };
145+
146+
RegionType m_Region;
147+
bool m_RegionSetByUser{ false };
148+
bool m_ComputeMaxima{ true };
149+
bool m_ComputeMinima{ true };
150+
std::mutex m_Mutex;
151+
};
152+
} // end namespace itk
153+
154+
#ifndef ITK_MANUAL_INSTANTIATION
155+
# include "itkNMinimaMaximaImageCalculator.hxx"
156+
#endif
157+
158+
#endif /* itkNMinimaMaximaImageCalculator_h */

0 commit comments

Comments
 (0)