diff --git a/envi/envi.h b/envi/envi.h index eb4a468..e10e880 100644 --- a/envi/envi.h +++ b/envi/envi.h @@ -6,7 +6,7 @@ #include "../envi/bip.h" #include "../envi/bil.h" #include -#include "../CImg/CImg.h" +//#include "../image/CImg.h" namespace stim{ diff --git a/image/image.h b/image/image.h index 8ed2098..28b80ab 100644 --- a/image/image.h +++ b/image/image.h @@ -1,6 +1,8 @@ #ifndef STIM_IMAGE_H #define STIM_IMAGE_H +#include "CImg.h" + #include //This static class provides the STIM interface for loading images // Use this interface for all image management - that way the actual library can be changed without problems @@ -10,7 +12,7 @@ template class image{ - CImg data; + cimg_library::CImg data; public: @@ -25,8 +27,18 @@ public: } //create an image from an interlaced buffer - void create_interlaced(T* buffer, unsigned int channels = 1){ + void set_interleaved(T* buffer, unsigned int width, unsigned int height, unsigned int channels = 1){ + + unsigned char* non_interleaved = (unsigned char*)malloc(width * height * 3); + unsigned int S = width * height; + + for(unsigned int i = 0; i < S; i++){ + for(unsigned int c = 0; c < channels; c++){ + non_interleaved[i + c * S] = buffer[i * channels + c]; + } + } + data = cimg_library::CImg(non_interleaved, width, height, 1, channels); } diff --git a/visualization/colormap.h b/visualization/colormap.h index 991c22f..f74074f 100644 --- a/visualization/colormap.h +++ b/visualization/colormap.h @@ -7,7 +7,7 @@ //saving an image to a file uses the CImg library //this currently throws a lot of "unreachable" warnings (as of GCC 4.8.2, nvcc 6.5.12) -#include "../CImg/CImg.h" +#include "../image/image.h" #define BREWER_CTRL_PTS 11 @@ -34,20 +34,23 @@ namespace stim{ enum colormapType {cmBrewer, cmGrayscale, cmRainbow}; -static void buffer2image(unsigned char* buffer, std::string filename, unsigned int x_size, unsigned int y_size) +static void buffer2image(unsigned char* buffer, std::string filename, unsigned int width, unsigned int height) { - unsigned char* non_interleaved = (unsigned char*)malloc(x_size * y_size * 3); + /*unsigned char* non_interleaved = (unsigned char*)malloc(x_size * y_size * 3); unsigned int S = x_size * y_size; for(unsigned int i = 0; i < S; i++){ non_interleaved[i + 0 * S] = buffer[i * 3 + 0]; non_interleaved[i + 1 * S] = buffer[i * 3 + 1]; non_interleaved[i + 2 * S] = buffer[i * 3 + 2]; - } + }*/ //create an image object - cimg_library::CImg image(non_interleaved, x_size, y_size, 1, 3); - image.save(filename.c_str()); + //cimg_library::CImg image(non_interleaved, x_size, y_size, 1, 3); + //image.save(filename.c_str()); + image I; + I.set_interleaved(buffer, width, height, 3); + I.save(filename); } #ifdef __CUDACC__ -- libgit2 0.21.4