CBICA Toolkit  1.0.0
cbicaITKOpenCVUtilities.h File Reference

Some basic utility functions to be used along with OpenCV. More...

#include <algorithm>
#include <functional>
#include "itkImage.h"
#include "itkImageRegionIterator.h"
#include "gdcmMD5.h"
#include "opencv2/core/core.hpp"
Include dependency graph for cbicaITKOpenCVUtilities.h:

Go to the source code of this file.

Functions

cv::Mat Add (const cv::InputArray &input1, const cv::InputArray &input2)
 Wrap of OpenCV's add function.
 
cv::Mat Invert (const cv::InputArray &input)
 Wrap of OpenCV's invert function.
 
template<typename TDataType >
std::vector< TDataType > L2normalize (const std::vector< TDataType > &inputVector)
 Normalize a vector based on its L2 norm. More...
 
cv::Mat Multiply (const cv::Mat &input1, const cv::Mat &input2)
 Wrap of OpenCV's multiply function.
 
cv::Mat Multiply (const cv::Mat &input1, const double input2)
 Wrap of OpenCV's multiply function.
 
cv::Mat Subtract (const cv::InputArray &input1, const cv::InputArray &input2)
 Wrap of OpenCV's subtract function.
 
cv::Mat Transpose (const cv::InputArray &input)
 Wrap of OpenCV's transpose function.
 
template<class TImageType >
cv::Mat VectorizeImages (const std::vector< std::vector< typename TImageType::Pointer > > inputSubjectsAndImages, const std::vector< typename TImageType::Pointer > maskImages, const bool columnMajor, const bool appendInputImagesFromSubjects, const bool maskDefinedPerSubject)
 Vectorizes a set of images. More...
 
template<class TImageType >
cv::Mat VectorizeImages (const std::vector< std::vector< typename TImageType::Pointer > > inputSubjectsAndImages, const std::vector< std::vector< typename TImageType::IndexType > > maskIndeces, const bool appendInputImagesFromSubjects=false, const bool columnMajor=false, const bool maskDefinedPerSubject=false)
 Vectorizes a set of images. More...
 
template<class TImageType >
cv::Mat VectorizeImages (const std::vector< std::vector< typename TImageType::Pointer > > inputSubjectsAndImages, const bool columnMajor=false, const bool appendInputImagesFromSubjects=false)
 Vectorizes a set of images. More...
 

Detailed Description

Some basic utility functions to be used along with OpenCV.

Dependecies: ITK, OpenCV, OpenMP

https://www.cbica.upenn.edu/sbia/software/
softw.nosp@m.are@.nosp@m.cbica.nosp@m..upe.nosp@m.nn.ed.nosp@m.u

Copyright (c) 2015 University of Pennsylvania. All rights reserved.
See COPYING file or https://www.cbica.upenn.edu/sbia/software/license.html

Function Documentation

◆ L2normalize()

std::vector< TDataType > cbica::L2normalize ( const std::vector< TDataType > &  inputVector)

Normalize a vector based on its L2 norm.

Parameters
inputVectorThe vector to normalize
Returns
The normalized vector

References cbica::L2normalize().

Referenced by cbica::L2normalize().

◆ VectorizeImages() [1/3]

cv::Mat cbica::VectorizeImages ( const std::vector< std::vector< typename TImageType::Pointer > >  inputSubjectsAndImages,
const std::vector< typename TImageType::Pointer >  maskImages,
const bool  columnMajor,
const bool  appendInputImagesFromSubjects,
const bool  maskDefinedPerSubject 
)

Vectorizes a set of images.

Parameters
inputSubjectsAndImagesThe subjects and images which are to be vectorized
maskImagesThe masks to be used for the input images
columnMajorIf true, image intensities are converted to column vectors; otherwise they are converted to row vectors; and then they are concatinated
appendInputImagesFromSubjectsIf true, concatenate all image voxels together in a single column/row
maskDefinedPerSubjectIf true, the mask is defined on a per-subject basis instead of per-modality
Returns
An OpenCV Mat: size is [inputSubjectsAndImages[i][j]->GetLargestPossibleRegion().GetSize(), inputSubjectsAndImages[j].size()] if columnMajor is true; transpose otherwise

References cbica::VectorizeImages().

Referenced by cbica::VectorizeImages().

◆ VectorizeImages() [2/3]

cv::Mat cbica::VectorizeImages ( const std::vector< std::vector< typename TImageType::Pointer > >  inputSubjectsAndImages,
const std::vector< std::vector< typename TImageType::IndexType > >  maskIndeces,
const bool  appendInputImagesFromSubjects = false,
const bool  columnMajor = false,
const bool  maskDefinedPerSubject = false 
)

Vectorizes a set of images.

Parameters
inputSubjectsAndImagesThe subjects and images which are to be vectorized
maskIndecesThe mask indeces to be used for the input images
columnMajorIf true, image intensities are converted to column vectors; otherwise they are converted to row vectors; and then they are concatinated
appendInputImagesFromSubjectsIf true, concatenate all image voxels together in a single column/row
maskDefinedPerSubjectIf true, the mask is defined on a per-subject basis instead of per-modality
Returns
An OpenCV Mat: size is [inputSubjectsAndImages[i][j]->GetLargestPossibleRegion().GetSize(), inputSubjectsAndImages[j].size()] if columnMajor is true; transpose otherwise

References cbica::VectorizeImages().

◆ VectorizeImages() [3/3]

cv::Mat cbica::VectorizeImages ( const std::vector< std::vector< typename TImageType::Pointer > >  inputSubjectsAndImages,
const bool  columnMajor = false,
const bool  appendInputImagesFromSubjects = false 
)

Vectorizes a set of images.

Parameters
inputSubjectsAndImagesThe images which are to be vectorized
columnMajorIf true, image intensities are converted to column vectors; otherwise they are converted to row vectors; and then they are concatinated
appendInputImagesFromSubjectsIf true, concatenate all image voxels together in a single column/row
Returns
An OpenCV Mat: size is [inputSubjectsAndImages[i]->GetLargestPossibleRegion().GetSize(), inputSubjectsAndImages.size()] if columnMajor is true; transpose otherwise

References cbica::VectorizeImages().