Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • f99a844
  • /
  • lib
  • /
  • itkSortInvTimesImageFilter.txx
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:bf317d85a554ed157973ca75be7693cec03cf948
directory badge Iframe embedding
swh:1:dir:7f21c9a4b7dfafd29925be862d8bd559b684364d
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
itkSortInvTimesImageFilter.txx
//
//  itkOxSortInvTimesImageFilter
//  OxShmolliLib
//
//  Created by Konrad Werys on 5/6/17.
//  Copyright © 2017 Konrad Werys. All rights reserved.
//

#include "CmakeConfigForTomato.h"
#ifdef USE_ITK

namespace  itk {
    template<typename TImageIn, typename TImageOut>
    void
    SortInvTimesImageFilter<TImageIn, TImageOut>
    ::GenerateData() {

        int nSamples = m_InvTimesNonSorted.size();

        // initialize values
        m_InvTimesSorted.set_size(nSamples);
        m_InvTimesSorted.fill(0);

        m_Indices.set_size(nSamples);
        for (int i = 0; i < nSamples; ++i) {
            m_Indices[i] = i;
        }

        // 1. sort invTimes vector
        vnl_index_sort<PixelTypeIn,int> vnlSort;
        vnlSort.vector_sort(m_InvTimesNonSorted, m_InvTimesSorted, m_Indices);

        // 2. apply new idices to repTimes vector
        if (m_RepTimesNonSorted.size() == m_InvTimesNonSorted.size()) {
            m_RepTimesSorted.set_size(nSamples);
            m_RepTimesSorted.fill(0);
            for (int i = 0; i < nSamples; ++i) {
                m_RepTimesSorted[i] = m_RepTimesNonSorted[m_Indices[i]];
            }
        }

        // 3. apply new idices to acqTimes vector
        if (m_RelAcqTimesNonSorted.size() == m_InvTimesNonSorted.size()) {
            m_RelAcqTimesSorted.set_size(nSamples);
            m_RelAcqTimesSorted.fill(0);
            for (int i = 0; i < nSamples; ++i) {
                m_RelAcqTimesSorted[i] = m_RelAcqTimesNonSorted[m_Indices[i]];
            }
        }

        // 4. set/get iterator with certain indices
        typename TImageIn::ConstPointer input = this->GetInput();
        typename TImageOut::Pointer output = this->GetOutput();

        output->SetRegions(input->GetLargestPossibleRegion());
        output->Allocate();

        typedef itk::ImageLinearConstIteratorWithIndex<TImageIn> InputIteratorType;
        typedef itk::ImageLinearIteratorWithIndex<TImageOut> OutputIteratorType;

        typename TImageIn::IndexType idxInput;
        typename TImageIn::IndexType idxOutput;

        InputIteratorType iteratorInput(input, input->GetRequestedRegion());
        OutputIteratorType iteratorOutput(output, output->GetRequestedRegion());

        iteratorInput.SetDirection(2);
        iteratorOutput.SetDirection(2);

        iteratorInput.GoToBegin();
        iteratorOutput.GoToBegin();

        while (!iteratorInput.IsAtEnd()) {

            iteratorInput.GoToBeginOfLine();
            iteratorOutput.GoToBeginOfLine();

            while (!iteratorOutput.IsAtEndOfLine()) {
                idxInput = iteratorInput.GetIndex();
                idxOutput = iteratorOutput.GetIndex();
                // change the order of 3rd dimension according to sorted invTimes
                idxInput[2] = idxInput[2] + m_Indices[idxOutput[2]];
                iteratorOutput.Set( input->GetPixel( idxInput ) );
                ++iteratorOutput;
            }

            iteratorInput.NextLine();
            iteratorOutput.NextLine();
        }
    }
} // end namespace

#endif // USE_ITK

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top