Permalink
Browse files

cleanup.

  • Loading branch information...
1 parent 75ec859 commit da85b20dbd1212ad2b60c938c9d407e60b6377c8 @daviddoria committed Mar 29, 2012
Showing with 59 additions and 107 deletions.
  1. +3 −1 CMakeLists.txt
  2. +8 −13 ITKQtHelpers.h
  3. +36 −88 ITKQtHelpers.hpp
  4. +1 −1 QtHelpers.cpp
  5. +5 −3 QtHelpers.h
  6. +6 −1 QtHelpers.hpp
View
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.8)
-add_library(libQtHelpers QtHelpers.cpp)
+message("Building QtHelpers")
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
@@ -16,6 +16,8 @@ list(APPEND compileflags "USE_QT_PARALLEL")
FIND_PACKAGE(ITK REQUIRED)
INCLUDE(${ITK_USE_FILE})
+add_library(libQtHelpers QtHelpers.cpp)
+
if(BuildTests)
add_subdirectory(Tests)
endif(BuildTests)
View
@@ -16,8 +16,8 @@
*
*=========================================================================*/
-#ifndef HELPERS_QT_H
-#define HELPERS_QT_H
+#ifndef ITKQtHelpers_H
+#define ITKQtHelpers_H
// Qt
#include <QColor>
@@ -30,19 +30,19 @@ class QTableWidget;
#include "itkImageRegion.h"
// Custom
-#include "DisplayStyle.h"
-#include "ImageProcessing/Mask.h"
+//#include "DisplayStyle.h"
+#include "Mask/Mask.h"
Q_DECLARE_METATYPE(itk::ImageRegion<2>)
-namespace HelpersQt
+namespace ITKQtHelpers
{
////////////////////////////////////
///////// Function templates ///////
////////////////////////////////////
-template <typename TImage>
-QImage GetQImage(const TImage* const image, const itk::ImageRegion<2>& region, const DisplayStyle& style);
+// template <typename TImage>
+// QImage GetQImage(const TImage* const image, const itk::ImageRegion<2>& region, const DisplayStyle& style);
template <typename TImage>
QImage GetQImageColor(const TImage* const image, const itk::ImageRegion<2>& region);
@@ -56,13 +56,8 @@ QImage GetQImageScalar(const TImage* const image, const itk::ImageRegion<2>& reg
template <typename TImage>
QImage GetQImageChannel(const TImage* const image, const itk::ImageRegion<2>& region, const unsigned int channel);
-/** Construct a QImage from a source and target patch.*/
-template <typename TImage>
-QImage GetQImageCombinedPatch(const TImage* const image, const itk::ImageRegion<2>& sourceRegion, const itk::ImageRegion<2>& targetRegion, const Mask* const mask);
-
-
} // end namespace
-#include "QtHelpers.hpp"
+#include "ITKQtHelpers.hpp"
#endif
View
@@ -16,6 +16,9 @@
*
*=========================================================================*/
+#ifndef ITKQtHelpers_HPP
+#define ITKQtHelpers_HPP
+
// ITK
#include "itkRegionOfInterestImageFilter.h"
#include "itkRescaleIntensityImageFilter.h"
@@ -24,40 +27,40 @@
// Custom
#include "Helpers/Helpers.h"
-#include "Helpers/ITKHelpers.h"
+#include "ITKHelpers/ITKHelpers.h"
// Qt
#include <QColor>
-namespace HelpersQt
+namespace ITKQtHelpers
{
-template <typename TImage>
-QImage GetQImage(const TImage* image, const itk::ImageRegion<2>& region, const DisplayStyle& style)
-{
- // Expects an itk::VectorImage
- switch(style.Style)
- {
- case DisplayStyle::COLOR:
- return GetQImageColor<TImage>(image, region);
- break;
- case DisplayStyle::MAGNITUDE:
- return GetQImageMagnitude<TImage>(image, region);
- break;
- case DisplayStyle::CHANNEL:
- {
- typedef itk::Image<typename TImage::InternalPixelType, 2> ScalarImageType;
- typename ScalarImageType::Pointer channelImage = ScalarImageType::New();
- ITKHelpers::ExtractChannel<typename TImage::InternalPixelType>(image, style.Channel, channelImage);
- return GetQImageScalar<ScalarImageType>(channelImage, region);
- break;
- }
- default:
- std::cerr << "No valid style specified." << std::endl;
- return QImage();
- }
- return QImage();
-}
+// template <typename TImage>
+// QImage GetQImage(const TImage* image, const itk::ImageRegion<2>& region, const DisplayStyle& style)
+// {
+// // Expects an itk::VectorImage
+// switch(style.Style)
+// {
+// case DisplayStyle::COLOR:
+// return GetQImageColor<TImage>(image, region);
+// break;
+// case DisplayStyle::MAGNITUDE:
+// return GetQImageMagnitude<TImage>(image, region);
+// break;
+// case DisplayStyle::CHANNEL:
+// {
+// typedef itk::Image<typename TImage::InternalPixelType, 2> ScalarImageType;
+// typename ScalarImageType::Pointer channelImage = ScalarImageType::New();
+// ITKHelpers::ExtractChannel<typename TImage::InternalPixelType>(image, style.Channel, channelImage);
+// return GetQImageScalar<ScalarImageType>(channelImage, region);
+// break;
+// }
+// default:
+// std::cerr << "No valid style specified." << std::endl;
+// return QImage();
+// }
+// return QImage();
+// }
template <typename TImage>
QImage GetQImageColor(const TImage* const image, const itk::ImageRegion<2>& region)
@@ -114,20 +117,20 @@ QImage GetQImageMagnitude(const TImage* image, const itk::ImageRegion<2>& region
magnitudeFilter->SetInput(image);
magnitudeFilter->Update();
- typedef itk::RescaleIntensityImageFilter<ScalarImageType, UnsignedCharScalarImageType> RescaleFilterType;
+ typedef itk::RescaleIntensityImageFilter<ScalarImageType, ITKHelpers::UnsignedCharScalarImageType> RescaleFilterType;
typename RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New();
rescaleFilter->SetOutputMinimum(0);
rescaleFilter->SetOutputMaximum(255);
rescaleFilter->SetInput( magnitudeFilter->GetOutput() );
rescaleFilter->Update();
- typedef itk::RegionOfInterestImageFilter< UnsignedCharScalarImageType, UnsignedCharScalarImageType> RegionOfInterestImageFilterType;
+ typedef itk::RegionOfInterestImageFilter< ITKHelpers::UnsignedCharScalarImageType, ITKHelpers::UnsignedCharScalarImageType> RegionOfInterestImageFilterType;
typename RegionOfInterestImageFilterType::Pointer regionOfInterestImageFilter = RegionOfInterestImageFilterType::New();
regionOfInterestImageFilter->SetRegionOfInterest(region);
regionOfInterestImageFilter->SetInput(rescaleFilter->GetOutput());
regionOfInterestImageFilter->Update();
- itk::ImageRegionIterator<UnsignedCharScalarImageType> imageIterator(regionOfInterestImageFilter->GetOutput(),
+ itk::ImageRegionIterator<ITKHelpers::UnsignedCharScalarImageType> imageIterator(regionOfInterestImageFilter->GetOutput(),
regionOfInterestImageFilter->GetOutput()->GetLargestPossibleRegion());
while(!imageIterator.IsAtEnd())
@@ -190,62 +193,7 @@ QImage GetQImageScalar(const TImage* image, const itk::ImageRegion<2>& region)
}
-template <typename TImage>
-QImage GetQImageCombinedPatch(const TImage* const image, const itk::ImageRegion<2>& sourceRegion, const itk::ImageRegion<2>& targetRegion, const Mask* const mask)
-{
- assert(sourceRegion.GetSize() == targetRegion.GetSize());
-
- QImage qimage(sourceRegion.GetSize()[0], sourceRegion.GetSize()[1], QImage::Format_RGB888);
-
- typedef itk::RegionOfInterestImageFilter<TImage, TImage> RegionOfInterestImageFilterType;
-
- typename RegionOfInterestImageFilterType::Pointer sourcePatchExtractor = RegionOfInterestImageFilterType::New();
- sourcePatchExtractor->SetRegionOfInterest(sourceRegion);
- sourcePatchExtractor->SetInput(image);
- sourcePatchExtractor->Update();
-
- typename RegionOfInterestImageFilterType::Pointer targetPatchExtractor = RegionOfInterestImageFilterType::New();
- targetPatchExtractor->SetRegionOfInterest(targetRegion);
- targetPatchExtractor->SetInput(image);
- targetPatchExtractor->Update();
-
- typedef itk::RegionOfInterestImageFilter<Mask, Mask> RegionOfInterestMaskFilterType;
- typename RegionOfInterestMaskFilterType::Pointer regionOfInterestMaskFilter = RegionOfInterestMaskFilterType::New();
- regionOfInterestMaskFilter->SetRegionOfInterest(targetRegion);
- regionOfInterestMaskFilter->SetInput(mask);
- regionOfInterestMaskFilter->Update();
-
- itk::ImageRegionIterator<TImage> sourcePatchIterator(sourcePatchExtractor->GetOutput(),
- sourcePatchExtractor->GetOutput()->GetLargestPossibleRegion());
-
- itk::ImageRegionIterator<TImage> targetPatchIterator(targetPatchExtractor->GetOutput(),
- targetPatchExtractor->GetOutput()->GetLargestPossibleRegion());
-
- while(!sourcePatchIterator.IsAtEnd())
- {
- itk::Index<2> index = targetPatchIterator.GetIndex();
-
- typename TImage::PixelType pixel;
- if(regionOfInterestMaskFilter->GetOutput()->IsHole(index))
- {
- pixel = sourcePatchIterator.Get();
- }
- else
- {
- pixel = targetPatchIterator.Get();
- }
-
- QColor pixelColor(static_cast<int>(pixel[0]), static_cast<int>(pixel[1]), static_cast<int>(pixel[2]));
- qimage.setPixel(index[0], index[1], pixelColor.rgb());
-
- ++targetPatchIterator;
- ++sourcePatchIterator;
- }
-
- // std::cout << "There were " << numberOfHolePixels << " hole pixels." << std::endl;
-
- //return qimage; // The actual image region
- return qimage.mirrored(false, true); // The flipped image region
-}
} // end namespace
+
+#endif
View
@@ -25,7 +25,7 @@
// STL
#include <iostream>
-namespace HelpersQt
+namespace QtHelpers
{
bool GetColumnIdByHeader(const QTableWidget* table, const std::string& header, int& columnId)
View
@@ -16,8 +16,8 @@
*
*=========================================================================*/
-#ifndef HELPERS_QT_H
-#define HELPERS_QT_H
+#ifndef QtHelpers_H
+#define QtHelpers_H
// Qt
#include <QColor>
@@ -26,7 +26,7 @@
class QGraphicsView;
class QTableWidget;
-namespace HelpersQt
+namespace QtHelpers
{
/** Convert a QColor to an unsigned char[3] */
void QColorToUCharColor(const QColor& color, unsigned char outputColor[3]);
@@ -45,4 +45,6 @@ void SetImageToConstant(QImage& qimage, const QColor& color);
} // end namespace
+#include "QtHelpers.hpp"
+
#endif
View
@@ -16,11 +16,16 @@
*
*=========================================================================*/
+#ifndef QtHelpers_HPP
+#define QtHelpers_HPP
+
// Qt
#include <QColor>
-namespace HelpersQt
+namespace QtHelpers
{
} // end namespace
+
+#endif

0 comments on commit da85b20

Please sign in to comment.