/*========================================================================= Program: FusionViewer Module: $RCSfile: ImageProvider.h,v $ Language: C++ Date: $Date: 2008/01/11 20:28:20 $ Version: $Revision: 1.2 $ Copyright (c) Insightful Corporation. All rights reserved. See Copyright.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ #ifndef _Included_ImageProvider #define _Included_ImageProvider typedef unsigned char GrayPixelType; typedef unsigned short IntermediatePixelType; #include /**\class ImageProvider * \addtogroup FusionViewerJNI * \brief Interface for accessing image sources up to 3 dimensions */ class ImageProvider { public: virtual ~ImageProvider() = 0; // Several image functions need an image axis as a parameter. // The following constants may be used. An enum was not used // because we often loop through the axes or perform other // arithmetic operations on them. static const int X_AXIS = 0; static const int Y_AXIS = 1; static const int Z_AXIS = 2; /** * Copy a 2D slice from the image provider into a 32-bit color output buffer, * performing window and level operations and applying a color lookup table. * * firstDirection - axis that will be the x axis in the output * secondDirection - axis that will be the y axis in the output * @param slice slice to extract along the axis that is neither firstDirection nor secondDirection * @param startX index along firstDirection to start copying from * @param startY index along secondDirection to start copying from * @param width number of pixels along firstDirection to copy * @param height number of pixels along secondDirection to copy * @param offset value subtracted from the source pixel when copying * @param slope value multiplied with the source pixel when copying * @param colormap array of 256 red, green, and blue 8-bit triplets to map source pixels to after * they have been scaled by offset and slope; colormap[0] = red, colormap[1] = green, * colormap[2] = blue for pixel value 0, colormap at 3, 4, and 5 will be pixel value 1, * etc. * @param invert if true, inverts the color map * @param outBuffer address to copy the slice to; this buffer must be width * height * 4 bytes in size * and is to be interpreted as an interleaved 8-bit blue, green, red, alpha buffer. */ virtual void LoadSlice(int firstDirection, int secondDirection, int slice, int startX, int startY, int width, int height, float offset, float slope, GrayPixelType *colormap, bool invert, GrayPixelType *outBuffer) = 0; /** * Copy a 2D slice into an intermediate 12-bit buffer. The pixel value are linearly * scaled into a range from 0 to 4095. This buffer is intended to be transformed using * fixed point math to scale the image. * * @param firstDirection axis that will be the x axis in the output * @param secondDirection axis that will be the y axis in the output * @param slice slice to extract along the axis that is neither firstDirection nor secondDirection * @param outBuffer address to copy the slice to; this buffer must be width * height * 2 bytes in size * and is to be interpreted as 12-bit grayscale values. */ virtual void LoadSlice(int firstDirection, int secondDirection, int slice, IntermediatePixelType *outBuffer) = 0; /** * Measures mean and standard deviation in a rectangle. */ virtual void MeasureROI(int startX, int startY, int width, int height, int firstDirection, int secondDirection, int slice, double& mean, double& stdDev, int& numPixels) = 0; /** * Returns pixel values along a line. */ virtual int MeasureLineProfile(int x1, int y1, int z1, int x2, int y2, int z2, double *elems, int maxNumElems) = 0; /** * Returns the value of the pixel at location x, y, z. */ virtual double GetPixel(int x, int y, int z) = 0; /** * Returns the type used to represent pixels. */ virtual const std::type_info& GetPixelType() = 0; /** * Returns true if the pixel type is unsigned char. This a quick short-cut * to GetPixelType so that a struct does not need to be constructed and returned. */ virtual bool IsByteType() = 0; /** * Returns a pointer to the internal pixel buffer. The caller should type cast to * the correct pixel type. If the caller changes the image, PixelUpdate must be called * to update the stored minimum and maximum values. These values are used by LoadSlice. */ virtual void *GetPixelBuffer() = 0; /** * Tells the ImageProvider that the pixels returned by GetPixelBuffer have been changed. */ virtual void PixelUpdate() = 0; /** * Returns the size of the image in dimension i. */ virtual int GetSize(int i) = 0; /** * Returns the spacing between the centers of pixels in dimension i. */ virtual float GetPixelSpacing(int i) = 0; /** * Returns the minimum pixel value in the image. */ virtual double GetMinValue() = 0; /** * Returns the minimum pixel value in the image. */ virtual double GetMaxValue() = 0; }; #endif