img3D_IO.h 8.4 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
*                                                                              *
* This library is free software; you can redistribute it and/or modify it      *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your     *
* option) any later version.                                                   *
*                                                                              *
* This library is distributed in the hope that it will be useful, but WITHOUT  *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
* for more details.                                                            *
*                                                                              *
* You should have received a copy of the GNU Lesser General Public License     *
* aint with this library; if not, write to the Free Software Foundation,      *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
*                                                                              *
20
* Web site: http://cgogn.u-strasbg.fr/                                         *
Pierre Kraemer's avatar
Pierre Kraemer committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __IMG3D_IO__
#define __IMG3D_IO__

#include "Utils/os_spec.h"

namespace CGoGN
{

namespace Utils
{

namespace Img3D_IO
{
	/**
	* Image type
	*/
	enum TYPEIMG {BOOL8=1, VAL8, RGB8, VAL16, VALFLOAT};

Sylvain Thery's avatar
Sylvain Thery committed
43 44
#ifdef PORTED_TO_QIMAGE

Pierre Kraemer's avatar
Pierre Kraemer committed
45 46 47 48
	/**
	* Initialization of IO
	* Necessary before any other call
	*/
thery's avatar
thery committed
49
	void initIO();
Pierre Kraemer's avatar
Pierre Kraemer committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63

	/**
	* Load bool image (0/255) 
	* Warning: the allocated data image contain w supplemntary bytes which store information
	* @param filename evident
	* @param w width of image (reference out)
	* @param h height of image (reference out)
	* @param d depth of image (reference out)
	* @param vx voxel size x stored in image (reference out)
	* @param vy voxel size y stored in image (reference out)
	* @param vz voxel size z stored in image (reference out)
	* @param tag image tag (reference out)
	* @return a pointer on the image data (that have been allocated by function)
	*/
Sylvain Thery's avatar
Sylvain Thery committed
64
	unsigned char* loadBool(char* filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& tag);
Pierre Kraemer's avatar
Pierre Kraemer committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80

	/**
	* Save bool image (0/255) 
	* generated image is grey level, each set of 8 plane is compressed to one 8bpp plane
	* Warning: the saved image contain w supplemntary bytes which store informations
	* Warning: origin of image is lower left
	* @param filename evident
	* @param data a pointer on the image data 
	* @param w width of image 
	* @param h height of image 
	* @param d depth of image 
	* @param vx voxel size x 
	* @param vy voxel size y 
	* @param vz voxel size z 
	* @param tag image tag  
	*/
Sylvain Thery's avatar
Sylvain Thery committed
81
	void saveBool(const std::string& filename, unsigned char* data, int w, int h, int d, float vx, float vy, float vz, int tag);
Pierre Kraemer's avatar
Pierre Kraemer committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95

	/**
	* Load 8 bits image, if image is boolean compressed, it uncompress it !
	* Warning: the allocated data image contain w supplemntary bytes which store information
	* @param filename evident
	* @param w width of image (reference out)
	* @param h height of image (reference out)
	* @param d depth of image (reference out)
	* @param vx voxel size x stored in image (reference out)
	* @param vy voxel size y stored in image (reference out)
	* @param vz voxel size z stored in image (reference out)
	* @param tag image tag (reference out)
	* @return a pointer on the image data (that have been allocated by function)
	*/
Sylvain Thery's avatar
Sylvain Thery committed
96
	unsigned char* loadVal_8(const std::string& filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& tag);
Pierre Kraemer's avatar
Pierre Kraemer committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111

	/**
	* Save 8bits val image 
	* Warning: the saved image contain w supplemntary bytes which store informations
	* Warning: origin of image is lower left
	* @param filename evident
	* @param data a pointer on the image data 
	* @param w width of image 
	* @param h height of image 
	* @param d depth of image 
	* @param vx voxel size x 
	* @param vy voxel size y 
	* @param vz voxel size z 
	* @param tag image tag  
	*/
Sylvain Thery's avatar
Sylvain Thery committed
112
	void saveVal(const std::string& filename, unsigned char* data, int w, int h, int d, float vx, float vy, float vz, int tag);
Pierre Kraemer's avatar
Pierre Kraemer committed
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127


	/**
	* Load 16 bits value image 
	* Warning: the allocated data image contain w supplemntary bytes which store information
	* @param filename evident
	* @param w width of image (reference out)
	* @param h height of image (reference out)
	* @param d depth of image (reference out)
	* @param vx voxel size x stored in image (reference out)
	* @param vy voxel size y stored in image (reference out)
	* @param vz voxel size z stored in image (reference out)
	* @param tag image tag (reference out)
	* @return a pointer on the image data (that have been allocated by function)
	*/
Sylvain Thery's avatar
Sylvain Thery committed
128
//	unsigned short* loadVal_16(const std::string& filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& tag);
Pierre Kraemer's avatar
Pierre Kraemer committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143

	/**
	* Save 16bits val image 
	* Warning: the saved image contain w supplemntary bytes which store informations
	* Warning: origin of image is lower left
	* @param filename evident
	* @param data a pointer on the image data 
	* @param w width of image 
	* @param h height of image 
	* @param d depth of image 
	* @param vx voxel size x 
	* @param vy voxel size y 
	* @param vz voxel size z 
	* @param tag image tag  
	*/
Sylvain Thery's avatar
Sylvain Thery committed
144
//	void saveVal_16(const std::string& filename, unsigned short* data, int w, int h, int d, float vx, float vy, float vz, int tag);
Pierre Kraemer's avatar
Pierre Kraemer committed
145 146 147 148 149 150 151 152 153 154 155 156 157 158

	/**
	* Load float value image 
	* Warning: the allocated data image contain w supplemntary bytes which store information
	* @param filename evident
	* @param w width of image (reference out)
	* @param h height of image (reference out)
	* @param d depth of image (reference out)
	* @param vx voxel size x stored in image (reference out)
	* @param vy voxel size y stored in image (reference out)
	* @param vz voxel size z stored in image (reference out)
	* @param tag image tag (reference out)
	* @return a pointer on the image data (that have been allocated by function)
	*/
Sylvain Thery's avatar
Sylvain Thery committed
159
//	float* loadVal_float(const std::string& filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& id);
Pierre Kraemer's avatar
Pierre Kraemer committed
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174

	/**
	* Save float val image 
	* Warning: the saved image contain w supplemntary bytes which store informations
	* Warning: origin of image is lower left
	* @param filename evident
	* @param data a pointer on the image data 
	* @param w width of image 
	* @param h height of image 
	* @param d depth of image 
	* @param vx voxel size x 
	* @param vy voxel size y 
	* @param vz voxel size z 
	* @param tag image tag  
	*/
Sylvain Thery's avatar
Sylvain Thery committed
175
//	void saveVal_float(const std::string& filename, float* data, int w, int h, int d, float vx, float vy, float vz, int tag);
Pierre Kraemer's avatar
Pierre Kraemer committed
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190


	/**
	* Load RGB 8 bits image 
	* Warning: the allocated data image contain w supplemntary bytes which store information
	* @param filename evident
	* @param w width of image (reference out)
	* @param h height of image (reference out)
	* @param d depth of image (reference out)
	* @param vx voxel size x stored in image (reference out)
	* @param vy voxel size y stored in image (reference out)
	* @param vz voxel size z stored in image (reference out)
	* @param tag image tag (reference out)
	* @return a pointer on the image data (that have been allocated by function)
	*/
Sylvain Thery's avatar
Sylvain Thery committed
191
	unsigned char* loadRGB(const std::string& filename, int& w, int& h, int &d, float& vx, float& vy, float& vz, int& id);
Pierre Kraemer's avatar
Pierre Kraemer committed
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206

	/**
	* Save RGB 8 bits image 
	* Warning: the saved image contain 3w supplemntary bytes which store informations
	* Warning: origin of image is lower left
	* @param filename evident
	* @param data a pointer on the image data 
	* @param w width of image 
	* @param h height of image 
	* @param d depth of image 
	* @param vx voxel size x 
	* @param vy voxel size y 
	* @param vz voxel size z 
	* @param tag image tag  
	*/
Sylvain Thery's avatar
Sylvain Thery committed
207 208
	void saveRGB(const std::string& filename, unsigned char* data, int w, int h, int d, float vx, float vy, float vz, int tag);
#endif
Pierre Kraemer's avatar
Pierre Kraemer committed
209 210 211 212 213 214 215 216

} //namespace
} //namespace
} //namespace

#endif