d32a1854
David Mayerich
added framework f...
|
1
2
|
#ifndef STIM_IMAGE_H
#define STIM_IMAGE_H
|
fbf0ab02
David Mayerich
added support for...
|
3
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
4
5
|
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
|
912d9073
David Mayerich
added vector.h to...
|
6
|
#include <vector>
|
d32a1854
David Mayerich
added framework f...
|
7
|
#include <iostream>
|
a2bf1d08
David Mayerich
general bug fixes...
|
8
|
#include <limits>
|
e252a6d6
David Mayerich
somehow the C++11...
|
9
|
#include <typeinfo>
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
10
|
|
7b3948ab
David Mayerich
added support for...
|
11
|
namespace stim{
|
c8c976a9
David Mayerich
replaced CImg wit...
|
12
13
|
/// This static class provides the STIM interface for loading, saving, and storing 2D images.
/// Data is stored in an interleaved (BIP) format (default for saving and loading is RGB).
|
d32a1854
David Mayerich
added framework f...
|
14
15
16
17
18
19
|
//currently this interface uses CImg
// T = data type (usually unsigned char)
template <class T>
class image{
|
c8c976a9
David Mayerich
replaced CImg wit...
|
20
21
22
23
|
//cimg_library::CImg<T> img;
T* img; //pointer to the image data (assumes RGB for loading/saving)
size_t R[3];
|
a2bf1d08
David Mayerich
general bug fixes...
|
24
25
26
|
size_t X() const { return R[1]; }
size_t Y() const { return R[2]; }
size_t C() const { return R[0]; }
|
c8c976a9
David Mayerich
replaced CImg wit...
|
27
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
28
29
30
31
32
33
34
|
void init(){ //initializes all variables, assumes no memory is allocated
memset(R, 0, sizeof(size_t) * 3); //set the resolution and number of channels to zero
img = NULL;
}
void unalloc(){ //frees any resources associated with the image
if(img) free(img); //if memory has been allocated, free it
|
c8c976a9
David Mayerich
replaced CImg wit...
|
35
|
}
|
1a224b6a
David Mayerich
fixed linux compa...
|
36
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
37
38
39
40
41
42
43
|
void clear(){ //clears all image data
unalloc(); //unallocate previous memory
init(); //re-initialize the variables
}
void allocate(){
|
e9a1b974
Pavel Govyadinov
imlemented Dr. Ma...
|
44
|
unalloc();
|
814eb271
David Mayerich
fixed problems wi...
|
45
|
img = (T*) malloc( sizeof(T) * R[0] * R[1] * R[2] ); //allocate memory
|
c8c976a9
David Mayerich
replaced CImg wit...
|
46
47
48
|
}
void allocate(size_t x, size_t y, size_t c){ //allocate memory based on the resolution
|
c8c976a9
David Mayerich
replaced CImg wit...
|
49
50
51
52
|
R[0] = c; R[1] = x; R[2] = y; //set the resolution
allocate(); //allocate memory
}
|
814eb271
David Mayerich
fixed problems wi...
|
53
|
size_t bytes(){ return size() * sizeof(T); }
|
c8c976a9
David Mayerich
replaced CImg wit...
|
54
55
56
57
|
size_t idx(size_t x, size_t y, size_t c = 0){
return y * C() * X() + x * C() + c;
}
|
1a224b6a
David Mayerich
fixed linux compa...
|
58
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
59
60
|
int cv_type(){
|
e252a6d6
David Mayerich
somehow the C++11...
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
// The following is C++ 11 code, but causes problems on some compilers (ex. nvcc). Below is my best approximation to a solution
//if(std::is_same<T, unsigned char>::value) return CV_MAKETYPE(CV_8U, (int)C());
//if(std::is_same<T, char>::value) return CV_MAKETYPE(CV_8S, (int)C());
//if(std::is_same<T, unsigned short>::value) return CV_MAKETYPE(CV_16U, (int)C());
//if(std::is_same<T, short>::value) return CV_MAKETYPE(CV_16S, (int)C());
//if(std::is_same<T, int>::value) return CV_MAKETYPE(CV_32S, (int)C());
//if(std::is_same<T, float>::value) return CV_MAKETYPE(CV_32F, (int)C());
//if(std::is_same<T, double>::value) return CV_MAKETYPE(CV_64F, (int)C());
if(typeid(T) == typeid(unsigned char)) return CV_MAKETYPE(CV_8U, (int)C());
if(typeid(T) == typeid(char)) return CV_MAKETYPE(CV_8S, (int)C());
if(typeid(T) == typeid(unsigned short)) return CV_MAKETYPE(CV_16U, (int)C());
if(typeid(T) == typeid(short)) return CV_MAKETYPE(CV_16S, (int)C());
if(typeid(T) == typeid(int)) return CV_MAKETYPE(CV_32S, (int)C());
if(typeid(T) == typeid(float)) return CV_MAKETYPE(CV_32F, (int)C());
if(typeid(T) == typeid(double)) return CV_MAKETYPE(CV_64F, (int)C());
|
1a224b6a
David Mayerich
fixed linux compa...
|
78
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
79
|
std::cout<<"ERROR in stim::image::cv_type - no valid data type found"<<std::endl;
|
3ff136b3
David Mayerich
replaced C++11 co...
|
80
|
exit(1);
|
c8c976a9
David Mayerich
replaced CImg wit...
|
81
82
|
}
|
a2bf1d08
David Mayerich
general bug fixes...
|
83
84
|
/// Returns the value for "white" based on the dynamic range (assumes white is 1.0 for floating point images)
T white(){
|
e252a6d6
David Mayerich
somehow the C++11...
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// The following is C++ 11 code, but causes problems on some compilers (ex. nvcc). Below is my best approximation to a solution
//if(std::is_same<T, unsigned char>::value) return UCHAR_MAX;
//if(std::is_same<T, unsigned short>::value) return SHRT_MAX;
//if(std::is_same<T, unsigned>::value) return UINT_MAX;
//if(std::is_same<T, unsigned long>::value) return ULONG_MAX;
//if(std::is_same<T, unsigned long long>::value) return ULLONG_MAX;
//if(std::is_same<T, float>::value) return 1.0f;
//if(std::is_same<T, double>::value) return 1.0;
if(typeid(T) == typeid(unsigned char)) return UCHAR_MAX;
if(typeid(T) == typeid(unsigned short)) return SHRT_MAX;
if(typeid(T) == typeid(unsigned)) return UINT_MAX;
if(typeid(T) == typeid(unsigned long)) return ULONG_MAX;
if(typeid(T) == typeid(unsigned long long)) return ULLONG_MAX;
if(typeid(T) == typeid(float)) return 1.0f;
if(typeid(T) == typeid(double)) return 1.0;
|
a2bf1d08
David Mayerich
general bug fixes...
|
102
103
|
std::cout<<"ERROR in stim::image::white - no white value known for this data type"<<std::endl;
|
e252a6d6
David Mayerich
somehow the C++11...
|
104
|
exit(1);
|
814eb271
David Mayerich
fixed problems wi...
|
105
|
|
a2bf1d08
David Mayerich
general bug fixes...
|
106
107
|
}
|
d32a1854
David Mayerich
added framework f...
|
108
109
110
|
public:
|
a2bf1d08
David Mayerich
general bug fixes...
|
111
|
/// Default constructor - creates an empty image object
|
814eb271
David Mayerich
fixed problems wi...
|
112
|
image(){ init(); } //initialize all variables to zero, don't allocate any memory
|
7b3948ab
David Mayerich
added support for...
|
113
|
|
a2bf1d08
David Mayerich
general bug fixes...
|
114
|
/// Constructor with a filename - loads the specified file
|
c8c976a9
David Mayerich
replaced CImg wit...
|
115
|
image(std::string filename){ //constructor initialize the image with an image file
|
fba6e7e3
Pavel Govyadinov
fixed image.h bug...
|
116
|
init();
|
c8c976a9
David Mayerich
replaced CImg wit...
|
117
|
load(filename);
|
7b3948ab
David Mayerich
added support for...
|
118
119
|
}
|
c8c976a9
David Mayerich
replaced CImg wit...
|
120
|
/// Create a new image from scratch given a number of samples and channels
|
1a224b6a
David Mayerich
fixed linux compa...
|
121
|
image(size_t x, size_t y = 1, size_t c = 1){
|
e9a1b974
Pavel Govyadinov
imlemented Dr. Ma...
|
122
|
init();
|
a2bf1d08
David Mayerich
general bug fixes...
|
123
|
allocate(x, y, c);
|
c8c976a9
David Mayerich
replaced CImg wit...
|
124
|
}
|
f186dbda
Tianshu Cheng
header file for b...
|
125
|
|
a2bf1d08
David Mayerich
general bug fixes...
|
126
|
/// Create a new image with the data given in 'data'
|
c8c976a9
David Mayerich
replaced CImg wit...
|
127
|
image(T* data, size_t x, size_t y, size_t c = 1){
|
e9a1b974
Pavel Govyadinov
imlemented Dr. Ma...
|
128
|
init();
|
c8c976a9
David Mayerich
replaced CImg wit...
|
129
130
|
allocate(x, y, c);
memcpy(img, data, bytes());
|
41acaf5d
David Mayerich
added a CUDA Gaus...
|
131
132
|
}
|
a2bf1d08
David Mayerich
general bug fixes...
|
133
|
/// Copy constructor - duplicates an image object
|
814eb271
David Mayerich
fixed problems wi...
|
134
|
image(const stim::image<T>& I){
|
e9a1b974
Pavel Govyadinov
imlemented Dr. Ma...
|
135
|
init();
|
a2bf1d08
David Mayerich
general bug fixes...
|
136
|
allocate(I.X(), I.Y(), I.C());
|
a2bf1d08
David Mayerich
general bug fixes...
|
137
138
139
140
141
142
143
144
|
memcpy(img, I.img, bytes());
}
/// Destructor - clear memory
~image(){
free(img);
}
|
735a2a24
David Mayerich
started testing o...
|
145
|
stim::image<T>& operator=(const stim::image<T>& I){
|
814eb271
David Mayerich
fixed problems wi...
|
146
|
init();
|
a2bf1d08
David Mayerich
general bug fixes...
|
147
148
149
150
151
152
153
|
if(&I == this) //handle self-assignment
return *this;
allocate(I.X(), I.Y(), I.C());
memcpy(img, I.img, bytes());
return *this;
}
|
c8c976a9
David Mayerich
replaced CImg wit...
|
154
|
/// Load an image from a file
|
d32a1854
David Mayerich
added framework f...
|
155
|
void load(std::string filename){
|
c8c976a9
David Mayerich
replaced CImg wit...
|
156
157
|
cv::Mat cvImage = cv::imread(filename, CV_LOAD_IMAGE_UNCHANGED); //use OpenCV to open the image file
|
a2bf1d08
David Mayerich
general bug fixes...
|
158
|
if(!cvImage.data){
|
814eb271
David Mayerich
fixed problems wi...
|
159
|
std::cout<<"ERROR stim::image::load() - unable to find image "<<filename<<std::endl;
|
a2bf1d08
David Mayerich
general bug fixes...
|
160
161
|
exit(1);
}
|
c8c976a9
David Mayerich
replaced CImg wit...
|
162
|
allocate(cvImage.cols, cvImage.rows, cvImage.channels()); //allocate space for the image
|
814eb271
David Mayerich
fixed problems wi...
|
163
164
165
166
|
T* cv_ptr = (T*)cvImage.data;
if(C() == 1) //if this is a single-color image, just copy the data
memcpy(img, cv_ptr, bytes());
if(C() == 3) //if this is a 3-color image, OpenCV uses BGR interleaving
|
a2bf1d08
David Mayerich
general bug fixes...
|
167
|
set_interleaved_bgr(cv_ptr, X(), Y());
|
d32a1854
David Mayerich
added framework f...
|
168
169
170
171
|
}
//save a file
void save(std::string filename){
|
c8c976a9
David Mayerich
replaced CImg wit...
|
172
173
|
//OpenCV uses an interleaved format, so convert first and then output
T* buffer = (T*) malloc(bytes());
|
a2bf1d08
David Mayerich
general bug fixes...
|
174
175
176
177
|
if(C() == 1)
memcpy(buffer, img, bytes());
else if(C() == 3)
|
9b766f1f
Pavel Govyadinov
completed merge f...
|
178
|
get_interleaved_bgr(buffer);
|
c8c976a9
David Mayerich
replaced CImg wit...
|
179
180
|
cv::Mat cvImage((int)Y(), (int)X(), cv_type(), buffer);
cv::imwrite(filename, cvImage);
|
d32a1854
David Mayerich
added framework f...
|
181
182
|
}
|
8b7be670
David Mayerich
implemented savin...
|
183
|
//create an image from an interleaved buffer
|
814eb271
David Mayerich
fixed problems wi...
|
184
185
|
void set_interleaved_rgb(T* buffer, size_t width, size_t height){
allocate(width, height, 3);
|
c8c976a9
David Mayerich
replaced CImg wit...
|
186
187
|
memcpy(img, buffer, bytes());
}
|
fbf0ab02
David Mayerich
added support for...
|
188
|
|
814eb271
David Mayerich
fixed problems wi...
|
189
190
|
void set_interleaved_bgr(T* buffer, size_t width, size_t height){
allocate(width, height, 3);
|
c8c976a9
David Mayerich
replaced CImg wit...
|
191
192
193
194
195
|
for(size_t c = 0; c < C(); c++){ //copy directly
for(size_t y = 0; y < Y(); y++){
for(size_t x = 0; x < X(); x++){
img[idx(x, y, c)] = buffer[y * X() * C() + x * C() + (2-c)];
}
|
fbf0ab02
David Mayerich
added support for...
|
196
197
|
}
}
|
8b7be670
David Mayerich
implemented savin...
|
198
199
|
}
|
9b766f1f
Pavel Govyadinov
completed merge f...
|
200
|
void get_interleaved_bgr(T* data){
|
8b7be670
David Mayerich
implemented savin...
|
201
202
|
//for each channel
|
c8c976a9
David Mayerich
replaced CImg wit...
|
203
204
205
206
207
208
209
|
for(size_t y = 0; y < Y(); y++){
for(size_t x = 0; x < X(); x++){
for(size_t c = 0; c < C(); c++){
data[y * X() * C() + x * C() + (2-c)] = img[idx(x, y, c)];
}
}
}
|
8b7be670
David Mayerich
implemented savin...
|
210
211
|
}
|
9b766f1f
Pavel Govyadinov
completed merge f...
|
212
213
214
215
|
void get_interleaved_rgb(T* data){
memcpy(data, img, bytes());
}
|
904614c3
David Mayerich
added normalizati...
|
216
217
218
219
220
221
222
223
224
225
226
227
|
//copies data in the given channel order as a non-interleaved image
void get_noninterleaved(T* data){
//for each channel
for(size_t y = 0; y < Y(); y++){
for(size_t x = 0; x < X(); x++){
for(size_t c = 0; c < C(); c++){
data[c * Y() * X() + y * X() + x] = img[idx(x, y, c)];
}
}
}
}
|
9b766f1f
Pavel Govyadinov
completed merge f...
|
228
|
|
9d3ba0b1
David Mayerich
added stim::hsi a...
|
229
|
image<T> channel(size_t c){
|
41acaf5d
David Mayerich
added a CUDA Gaus...
|
230
231
|
//create a new image
|
a2bf1d08
David Mayerich
general bug fixes...
|
232
|
image<T> r(X(), Y(), 1);
|
41acaf5d
David Mayerich
added a CUDA Gaus...
|
233
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
234
235
|
for(size_t x = 0; x < X(); x++){
for(size_t y = 0; y < Y(); y++){
|
8e2fb2b4
David Mayerich
fixed a segmentat...
|
236
|
r.img[r.idx(x, y, 0)] = img[idx(x, y, c)];
|
c8c976a9
David Mayerich
replaced CImg wit...
|
237
238
|
}
}
|
41acaf5d
David Mayerich
added a CUDA Gaus...
|
239
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
240
|
return r;
|
41acaf5d
David Mayerich
added a CUDA Gaus...
|
241
242
243
|
}
|
c8c976a9
David Mayerich
replaced CImg wit...
|
244
245
|
T& operator()(size_t x, size_t y, size_t c = 0){
return img[idx(x, y, c)];
|
3d0b6243
David Mayerich
fixed hsiproc bug...
|
246
247
248
249
250
251
252
|
}
/// Set all elements in the image to a given scalar value
/// @param v is the value used to set all values in the image
image<T> operator=(T v){
|
c8c976a9
David Mayerich
replaced CImg wit...
|
253
|
size_t N = size();
|
3d0b6243
David Mayerich
fixed hsiproc bug...
|
254
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
255
256
|
for(size_t n = 0; n < N; n++)
img[n] = v;
|
3d0b6243
David Mayerich
fixed hsiproc bug...
|
257
258
259
260
261
|
return *this;
}
|
f186dbda
Tianshu Cheng
header file for b...
|
262
263
264
265
266
|
/// Copy the given data to the specified channel
/// @param c is the channel number that the data will be copied to
/// @param buffer is a pointer to the image to be copied to channel c
|
c8c976a9
David Mayerich
replaced CImg wit...
|
267
|
void set_channel(T* buffer, size_t c){
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
268
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
269
270
271
272
273
274
|
size_t x, y;
for(y = 0; y < Y(); y++){
for(x = 0; x < X(); x++){
img[idx(x, y, c)] = buffer[c];
}
}
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
275
276
|
}
|
9d3ba0b1
David Mayerich
added stim::hsi a...
|
277
|
size_t channels(){
|
c8c976a9
David Mayerich
replaced CImg wit...
|
278
|
return C();
|
8b7be670
David Mayerich
implemented savin...
|
279
280
|
}
|
9d3ba0b1
David Mayerich
added stim::hsi a...
|
281
|
size_t width(){
|
c8c976a9
David Mayerich
replaced CImg wit...
|
282
|
return X();
|
8b7be670
David Mayerich
implemented savin...
|
283
284
|
}
|
9d3ba0b1
David Mayerich
added stim::hsi a...
|
285
|
size_t height(){
|
c8c976a9
David Mayerich
replaced CImg wit...
|
286
|
return Y();
|
3d0b6243
David Mayerich
fixed hsiproc bug...
|
287
288
|
}
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
289
|
T* data(){
|
c8c976a9
David Mayerich
replaced CImg wit...
|
290
|
return img;
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
291
292
|
}
|
7b3948ab
David Mayerich
added support for...
|
293
|
//returns the size (number of values) of the image
|
c8c976a9
David Mayerich
replaced CImg wit...
|
294
|
size_t size(){ return C() * X() * Y(); }
|
d32a1854
David Mayerich
added framework f...
|
295
|
|
faef7718
David Mayerich
updates to stim::...
|
296
|
/// Returns the number of nonzero values
|
9d3ba0b1
David Mayerich
added stim::hsi a...
|
297
|
size_t nnz(){
|
faef7718
David Mayerich
updates to stim::...
|
298
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
299
|
size_t N = X() * Y() * C();
|
faef7718
David Mayerich
updates to stim::...
|
300
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
301
302
303
|
size_t nz = 0;
for(size_t n = 0; n < N; n++)
if(img[n] != 0) nz++;
|
faef7718
David Mayerich
updates to stim::...
|
304
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
305
|
return nz; //return the number of nonzero pixels
|
faef7718
David Mayerich
updates to stim::...
|
306
307
308
309
|
}
//this function returns indices of pixels that have nonzero values
|
9d3ba0b1
David Mayerich
added stim::hsi a...
|
310
|
std::vector<size_t> sparse_idx(){
|
faef7718
David Mayerich
updates to stim::...
|
311
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
312
|
std::vector<size_t> s; //allocate an array
|
faef7718
David Mayerich
updates to stim::...
|
313
314
|
s.resize(nnz()); //allocate space in the array
|
c8c976a9
David Mayerich
replaced CImg wit...
|
315
316
|
size_t N = size();
//size_t C = channels();
|
faef7718
David Mayerich
updates to stim::...
|
317
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
318
|
//T* ptr = img.data(); //get a pointer to the image data
|
faef7718
David Mayerich
updates to stim::...
|
319
|
|
9d3ba0b1
David Mayerich
added stim::hsi a...
|
320
|
size_t i = 0;
|
c8c976a9
David Mayerich
replaced CImg wit...
|
321
322
323
324
|
for(size_t n = 0; n < N; n++){
if(img[n] != 0){
s[i] = n;
i++;
|
faef7718
David Mayerich
updates to stim::...
|
325
326
327
328
329
|
}
}
return s; //return the index list
}
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
330
|
|
1a224b6a
David Mayerich
fixed linux compa...
|
331
|
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
332
|
/// Returns the maximum pixel value in the image
|
96f9b10f
Laila Saadatifard
change the header...
|
333
|
T maxv(){
|
c8c976a9
David Mayerich
replaced CImg wit...
|
334
335
|
T max_val = img[0]; //initialize the maximum value to the first one
size_t N = size(); //get the number of pixels
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
336
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
337
|
for (size_t n=0; n<N; n++){ //for every value
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
338
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
339
340
|
if (img[n] > max_val){ //if the value is higher than the current max
max_val = img[n];
|
1a224b6a
David Mayerich
fixed linux compa...
|
341
|
}
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
342
343
|
}
|
1a224b6a
David Mayerich
fixed linux compa...
|
344
|
return max_val;
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
345
|
}
|
d32a1854
David Mayerich
added framework f...
|
346
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
347
|
/// Returns the maximum pixel value in the image
|
96f9b10f
Laila Saadatifard
change the header...
|
348
|
T minv(){
|
c8c976a9
David Mayerich
replaced CImg wit...
|
349
350
|
T min_val = img[0]; //initialize the maximum value to the first one
size_t N = size(); //get the number of pixels
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
351
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
352
353
354
|
for (size_t n=0; n<N; n++){ //for every value
if (img[n] < min_val){ //if the value is higher than the current max
min_val = img[n];
|
1a224b6a
David Mayerich
fixed linux compa...
|
355
|
}
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
356
357
|
}
|
1a224b6a
David Mayerich
fixed linux compa...
|
358
|
return min_val;
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
359
360
|
}
|
a2bf1d08
David Mayerich
general bug fixes...
|
361
362
363
364
365
366
|
/// Invert an image by calculating I1 = alpha - I0, where alpha is the maximum image value
image<T> invert(T white_val){
size_t N = size(); //calculate the total number of values in the image
image<T> r(X(), Y(), C()); //allocate space for the resulting image
for(size_t n = 0; n < N; n++)
r.img[n] = white_val - img[n]; //perform the inversion
|
1a224b6a
David Mayerich
fixed linux compa...
|
367
|
|
a2bf1d08
David Mayerich
general bug fixes...
|
368
369
|
return r; //return the inverted image
}
|
a2bf1d08
David Mayerich
general bug fixes...
|
370
|
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
371
|
image<T> srgb2lab(){
|
c8c976a9
David Mayerich
replaced CImg wit...
|
372
373
|
std::cout<<"ERROR stim::image::srgb2lab - function has been broken, re-implement."<<std::endl;
exit(1);
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
374
375
376
|
}
image<T> convolve2(image<T> mask){
|
1a224b6a
David Mayerich
fixed linux compa...
|
377
|
|
c8c976a9
David Mayerich
replaced CImg wit...
|
378
379
|
std::cout<<"ERROR stim::image::convolve2 - function has been broken, and shouldn't really be in here."<<std::endl;
exit(1);
|
6d30a707
Tianshu Cheng
add cuda/array_ad...
|
380
|
}
|
d32a1854
David Mayerich
added framework f...
|
381
382
|
|
f186dbda
Tianshu Cheng
header file for b...
|
383
|
image<T> rotate(float angle, float cx, float cy){
|
c8c976a9
David Mayerich
replaced CImg wit...
|
384
385
|
std::cout<<"ERROR stim::image::rotate - function has been broken, and shouldn't really be in here."<<std::endl;
exit(1);
|
f186dbda
Tianshu Cheng
header file for b...
|
386
|
}
|
945ee13c
Laila Saadatifard
the get_list func...
|
387
|
|
945ee13c
Laila Saadatifard
the get_list func...
|
388
389
|
// leila's code for non_interleaving data in 3D
//create an data set from an interleaved buffer
|
9d3ba0b1
David Mayerich
added stim::hsi a...
|
390
|
void set_interleaved3(T* buffer, size_t width, size_t height, size_t depth, size_t channels = 3){
|
c8c976a9
David Mayerich
replaced CImg wit...
|
391
392
|
std::cout<<"ERROR stim::image::set_interleaved3 - stim::image no longer supports 3D images."<<std::endl;
exit(1);
|
945ee13c
Laila Saadatifard
the get_list func...
|
393
|
}
|
1a224b6a
David Mayerich
fixed linux compa...
|
394
|
|
d32a1854
David Mayerich
added framework f...
|
395
396
|
};
|
7b3948ab
David Mayerich
added support for...
|
397
398
|
}; //end namespace stim
|
d32a1854
David Mayerich
added framework f...
|
399
400
|
#endif
|