Skip to content

Instantly share code, notes, and snippets.

View N-Dekker's full-sized avatar

Niels Dekker N-Dekker

  • LKEB, Leiden University Medical Center
View GitHub Profile
@N-Dekker
N-Dekker / IncreaseCapacityNeighborhoodAllocatorVector.cxx
Created January 13, 2019 19:58
Estimates duration of increasing the capacity of `std::vector<itk::NeighborhoodAllocator<int>>`
/*
Estimates the runtime duration that it takes to increase the capacity of
an `std::vector<itk::NeighborhoodAllocator<int>>`.
With VS2017, the `vector::reserve` in this test appears to run more than 4x faster,
now that `itk::NeighborhoodAllocator` has a move-constructor that is `noexcept`.
Related to the discussion, "Regarding C++11 noexcept" at the ITK forum:
https://discourse.itk.org/t/regarding-c-11-noexcept/1517
@N-Dekker
N-Dekker / EstimateAxisAlignedBoundingBoxRegion.hxx
Last active April 6, 2019 11:57
EstimateAxisAlignedBoundingBoxRegion (ITK5)
/*
Estimates the axis-aligned minimum bounding box of the buffered region of an image.
Roughly equivalent to ImageMaskSpatialObject::GetAxisAlignedBoundingBoxRegion() from
"itkImageMaskSpatialObject.hxx", at
github.com/InsightSoftwareConsortium/ITK/blob/91ab86f63eb5fc9799bb25fa49e76adf0d1b5251/Modules/Core/SpatialObjects/include
Related to:
"ENH: GTest for ImageMaskSpatialObject::GetAxisAlignedBoundingBoxRegion()"
@N-Dekker
N-Dekker / gist:b5b85167efb752af1e0c0198d8d0ee68
Created November 22, 2020 21:04
Print ITK Transform classes and their number of parameters
/*
Related to:
https://github.com/SuperElastix/elastix/pull/358#issuecomment-731736374
Niels Dekker, LKEB, Leiden University Medical Center, 2020
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
*/
@N-Dekker
N-Dekker / ElastixTranslationExample.cxx
Created February 10, 2022 09:44
ElastixTranslationExample for elastix 4.8 lib interface
/*=========================================================================
*
* Copyright UMC Utrecht and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// Script to add in-class {} member initializers to ITK classes that have one or more virtual member function,
// itkNewMacro, itkSimpleNewMacro, or itkCreateAnotherMacro calls.
//
// Only tested with Visual Studio 2019 (C++14).
//
// Needs to have the directory path to the ITK sources as command-line argument, for example:
#include <chrono>
using namespace std::chrono;
const auto timePoint = high_resolution_clock::now();
// Do the time consuming work here!
std::cout << " Duration: "
<< duration_cast<duration<double>>(high_resolution_clock::now() - timePoint).count() << " seconds" << std::endl;
@N-Dekker
N-Dekker / function-template-argument.cpp
Last active December 11, 2023 21:35
std::function versus template argument
// Related to https://github.com/InsightSoftwareConsortium/ITK/pull/4347
// PERF: Replace `std::function` with template argument MultiThreaderBase ParallelizeImageRegion, ParallelizeImageRegionRestrictDirection
// Niels Dekker, LKEB, Leiden University Medical Center, 2023
#include <itkImageRegion.h>
#include <algorithm>
#include <chrono>
#include <numeric>
#include <vector>