Commit 6d30a707f73b83982ac9c8a07fc577013b3c0665
1 parent
13fe3c84
add cuda/array_add.cuh
Showing
3 changed files
with
73 additions
and
3 deletions
Show diff stats
stim/cuda/arraymath.cuh
stim/cuda/gaussian_blur.cuh
stim/image/image.h
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | |
8 | 8 | #include <vector> |
9 | 9 | #include <iostream> |
10 | + | |
10 | 11 | namespace stim{ |
11 | 12 | //This static class provides the STIM interface for loading images |
12 | 13 | // Use this interface for all image management - that way the actual library can be changed without problems |
... | ... | @@ -83,12 +84,23 @@ public: |
83 | 84 | //create a new image |
84 | 85 | image<T> single; |
85 | 86 | |
86 | - single.img = img.channel(c); | |
87 | + single.img = img.get_channel(c); | |
87 | 88 | |
88 | 89 | return single; |
89 | 90 | |
90 | 91 | } |
91 | 92 | |
93 | + image<T> getslice(unsigned int c){ | |
94 | + | |
95 | + //create a new image | |
96 | + image<T> slice; | |
97 | + | |
98 | + slice.img = img.get_slice(c); | |
99 | + | |
100 | + return slice; | |
101 | + | |
102 | + } | |
103 | + | |
92 | 104 | unsigned int channels(){ |
93 | 105 | return (unsigned int)img.spectrum(); |
94 | 106 | } |
... | ... | @@ -101,6 +113,10 @@ public: |
101 | 113 | return img.height(); |
102 | 114 | } |
103 | 115 | |
116 | + T* data(){ | |
117 | + return img.data(); | |
118 | + } | |
119 | + | |
104 | 120 | //returns the size (number of values) of the image |
105 | 121 | unsigned long size(){ |
106 | 122 | return img.size(); |
... | ... | @@ -155,8 +171,61 @@ public: |
155 | 171 | |
156 | 172 | return s; //return the index list |
157 | 173 | } |
174 | + | |
158 | 175 | |
176 | + /// Returns the maximum pixel value in the image | |
177 | + T max(){ | |
178 | + float max = 0; | |
179 | + unsigned long N = width() * height(); //get the number of pixels | |
180 | + | |
181 | + for (unsigned long i=0; i<N; i++){ | |
182 | + | |
183 | + if (img.data()[i] > max) | |
184 | + { | |
185 | + max = img.data()[i]; | |
186 | + } | |
187 | + } | |
188 | + | |
189 | + return max; | |
190 | + } | |
159 | 191 | |
192 | + /// Returns the minimum pixel value in the image | |
193 | + T min(){ | |
194 | + float min = 0; | |
195 | + unsigned long N = width() * height(); //get the number of pixels | |
196 | + | |
197 | + for (unsigned long i=0; i<N; i++){ | |
198 | + | |
199 | + if (img.data()[i] < min) | |
200 | + { | |
201 | + min = img.data()[i]; | |
202 | + } | |
203 | + } | |
204 | + | |
205 | + return min; | |
206 | + | |
207 | + } | |
208 | + | |
209 | + image<T> srgb2lab(){ | |
210 | + | |
211 | + image<T> rgb; | |
212 | + rgb.img = img.get_sRGBtoRGB(); | |
213 | + | |
214 | + image<T> lab; | |
215 | + lab.img = rgb.img.get_RGBtoLab(); | |
216 | + | |
217 | + return lab; | |
218 | + | |
219 | + } | |
220 | + | |
221 | + image<T> convolve2(image<T> mask){ | |
222 | + | |
223 | + image<T> result; | |
224 | + | |
225 | + result.img = img.get_convolve(mask.img); | |
226 | + | |
227 | + return result; | |
228 | + } | |
160 | 229 | |
161 | 230 | |
162 | 231 | }; | ... | ... |