Commit 9a100035 authored by schultezub's avatar schultezub
Browse files

introducing ImageSeries and RawImageReader

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@513 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent eec5a8cd
......@@ -43,7 +43,6 @@
namespace campvis {
class ImageRepresentationLocal;
class AbstractImageRepresentationItk;
/**
* Stores basic information about one (semantic) image of arbitrary dimension.
......@@ -241,6 +240,8 @@ namespace campvis {
const campvis::ImageRepresentationLocal* campvis::ImageData::getRepresentation<ImageRepresentationLocal>(bool performConversion) const;
#ifdef CAMPVIS_HAS_MODULE_ITK
class AbstractImageRepresentationItk;
template<>
const campvis::AbstractImageRepresentationItk* campvis::ImageData::getRepresentation<AbstractImageRepresentationItk>(bool performConversion) const;
#endif
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include "imageseries.h"
#include "imagedata.h"
#include "tgt/assert.h"
namespace campvis {
ImageSeries::ImageSeries()
: AbstractData()
{
}
ImageSeries::~ImageSeries() {
}
ImageSeries* ImageSeries::clone() const {
ImageSeries* toReturn = new ImageSeries();
for (size_t i = 0; i < _images.size(); ++i)
toReturn->_images.push_back(_images[i]);
return toReturn;
}
size_t ImageSeries::getLocalMemoryFootprint() const {
size_t toReturn = sizeof(DataHandle) * _images.capacity();
for (size_t i = 0; i < _images.size(); ++i)
toReturn += static_cast<const ImageData*>(_images[i].getData())->getLocalMemoryFootprint();
return toReturn;
}
size_t ImageSeries::getVideoMemoryFootprint() const {
size_t toReturn = 0;
for (size_t i = 0; i < _images.size(); ++i)
toReturn += static_cast<const ImageData*>(_images[i].getData())->getVideoMemoryFootprint();
return toReturn;
}
void ImageSeries::addImage(ImageData* image) {
_images.push_back(DataHandle(image));
}
void ImageSeries::addImage(DataHandle dh) {
tgtAssert(dynamic_cast<const ImageData*>(dh.getData()) != 0, "DataHandle must contain ImageData!");
_images.push_back(dh);
}
size_t ImageSeries::getNumImages() const {
return _images.size();
}
DataHandle ImageSeries::getImage(size_t index) const {
tgtAssert(index < _images.size(), "Index out of bounds.");
return _images[index];
}
}
\ No newline at end of file
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#ifndef IMAGESERIES_H__
#define IMAGESERIES_H__
#include "core/datastructures/abstractdata.h"
#include "core/datastructures/datahandle.h"
#include <vector>
namespace campvis {
class ImageData;
/**
* Class encapsulating a series of images.
*/
class ImageSeries : public AbstractData {
public:
/**
* Constructor
*/
ImageSeries();
/**
* Virtual destructor
*/
virtual ~ImageSeries();
/**
* Prototype - clone method, some people call this virtual constructor...
* \return A copy of this object.
*/
virtual ImageSeries* clone() const;
/**
* Returns the local memory footprint of the data in bytes.
* \return Number of bytes occupied in local memory by the data.
*/
virtual size_t getLocalMemoryFootprint() const;
/**
* Returns the video memory footprint of the data in bytes.
* \return Number of bytes occupied in video memory by the data.
*/
virtual size_t getVideoMemoryFootprint() const;
/**
* Appends the image \a image to the series.
* \param image Image to be added.
*/
void addImage(ImageData* image);
/**
* Appends the image \a image to the series.
* \note The DataHandle must contain walid image data.
* \param dh DataHandle with image to be added.
*/
void addImage(DataHandle dh);
/**
* Returns the number of images in this series
* \return _images.size()
*/
size_t getNumImages() const;
/**
* Returns a DataHandle with the image number \a index of this series.
* \param index Index of the image to return
* \return _images[index]
*/
DataHandle getImage(size_t index) const;
protected:
std::vector<DataHandle> _images; ///< the images of this series
};
}
#endif // IMAGESERIES_H__
\ No newline at end of file
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include "rawimagereader.h"
#include <fstream>
#include <limits>
#include "core/datastructures/imagedata.h"
#include "core/datastructures/imagerepresentationdisk.h"
namespace campvis {
static const GenericOption<WeaklyTypedPointer::BaseType> baseTypeOptions[7] = {
GenericOption<WeaklyTypedPointer::BaseType>("uint8", "uint8", WeaklyTypedPointer::UINT8),
GenericOption<WeaklyTypedPointer::BaseType>("int8", "int8", WeaklyTypedPointer::INT8),
GenericOption<WeaklyTypedPointer::BaseType>("uint16", "uint16", WeaklyTypedPointer::UINT16),
GenericOption<WeaklyTypedPointer::BaseType>("int16", "int16", WeaklyTypedPointer::INT16),
GenericOption<WeaklyTypedPointer::BaseType>("uint32", "uint32", WeaklyTypedPointer::UINT32),
GenericOption<WeaklyTypedPointer::BaseType>("int32", "int32", WeaklyTypedPointer::INT32),
GenericOption<WeaklyTypedPointer::BaseType>("float", "float", WeaklyTypedPointer::FLOAT),
};
static const GenericOption<EndianHelper::Endianness> endianOptions[2] = {
GenericOption<EndianHelper::Endianness>("b", "Big Endian", EndianHelper::IS_BIG_ENDIAN),
GenericOption<EndianHelper::Endianness>("e", "Little Endian", EndianHelper::IS_LITTLE_ENDIAN),
};
const std::string RawImageReader::loggerCat_ = "CAMPVis.modules.io.RawImageReader";
RawImageReader::RawImageReader()
: AbstractProcessor()
, p_url("url", "Image URL", "")
, p_size("Size", "Image Size", tgt::ivec3(1), tgt::ivec3(1), tgt::ivec3(2048))
, p_numChannels("NumChannels", "Number of Channels per Element", 1, 1, 9)
, p_baseType("BaseType", "Base Type", baseTypeOptions, 7)
, p_offset("Offset", "Byte Offset", 0, 0, std::numeric_limits<int>::max())
, p_endianness("Endianess", "Endianess", endianOptions, 2)
, p_targetImageID("targetImageName", "Target Image ID", "RawImageReader.output", DataNameProperty::WRITE)
, p_imageOffset("ImageOffset", "Image Offset in mm", tgt::vec3(0.f), tgt::vec3(-10000.f), tgt::vec3(10000.f))
, p_voxelSize("VoxelSize", "Voxel Size in mm", tgt::vec3(1.f), tgt::vec3(-100.f), tgt::vec3(100.f))
{
addProperty(&p_url);
addProperty(&p_size);
addProperty(&p_numChannels);
addProperty(&p_baseType);
addProperty(&p_offset);
addProperty(&p_endianness);
addProperty(&p_targetImageID);
addProperty(&p_imageOffset);
addProperty(&p_voxelSize);
}
RawImageReader::~RawImageReader() {
}
void RawImageReader::process(DataContainer& data) {
size_t dimensionality = 3;
if (p_size.getValue().z == 1) {
dimensionality = (p_size.getValue().y == 1) ? 1 : 2;
}
ImageData* image = new ImageData(dimensionality, p_size.getValue(), p_numChannels.getValue());
ImageRepresentationDisk::create(image, p_url.getValue(), p_baseType.getOptionValue(), p_offset.getValue(), p_endianness.getOptionValue());
image->setMappingInformation(ImageMappingInformation(p_size.getValue(), p_imageOffset.getValue(), p_voxelSize.getValue()));
data.addData(p_targetImageID.getValue(), image);
p_targetImageID.issueWrite();
validate(INVALID_RESULT);
}
}
\ No newline at end of file
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#ifndef RAWIMAGEREADER_H__
#define RAWIMAGEREADER_H__
#include <string>
#include "core/pipeline/abstractprocessor.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/numericproperty.h"
#include "core/properties/optionproperty.h"
#include "core/tools/endianhelper.h"
#include "core/tools/weaklytypedpointer.h"
namespace campvis {
/**
* Reads raw images into the pipeline.
*/
class RawImageReader : public AbstractProcessor {
public:
/**
* Constructs a new RawImageReader Processor
**/
RawImageReader();
/**
* Destructor
**/
virtual ~RawImageReader();
/**
* Reads the raw file into an ImageRepresentationDisk representation
* \param data DataContainer to work on
*/
virtual void process(DataContainer& data);
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "RawImageReader"; };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Reads raw images into the pipeline."; };
StringProperty p_url; ///< URL for file to read
IVec3Property p_size; ///< Image size
IntProperty p_numChannels; ///< Number of channels per element
GenericOptionProperty<WeaklyTypedPointer::BaseType> p_baseType; ///< Base type
IntProperty p_offset; ///< Byte offset
GenericOptionProperty<EndianHelper::Endianness> p_endianness; ///< Base type
DataNameProperty p_targetImageID; ///< image ID for read image
Vec3Property p_imageOffset; ///< Image Offset in mm
Vec3Property p_voxelSize; ///< Voxel Size in mm
protected:
static const std::string loggerCat_;
};
}
#endif // RAWIMAGEREADER_H__
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment