Commit 70f0baaf0075c21fca6bdf0095f706617fd13ebc
1 parent
00a7e339
update the image.h (add border), gauss2.cuh (change the kernel size) and argumen…
…ts.h (comment the include file)
Showing
3 changed files
with
18 additions
and
6 deletions
Show diff stats
stim/image/image.h
... | ... | @@ -408,6 +408,22 @@ public: |
408 | 408 | return result; |
409 | 409 | } |
410 | 410 | |
411 | + /// Add a border of width w with the given value around the image | |
412 | + /// @param w specifies the total size of the border | |
413 | + /// @param T is the pixel value (all channels will be the same) | |
414 | + image<T> border(size_t w, T value = 0) { | |
415 | + image<T> result(width() + w * 2, height() + w * 2, channels()); //create an output image | |
416 | + result = value; //assign the border value to all pixels in the new image | |
417 | + for (size_t y = 0; y < height(); y++) { //for each pixel in the original image | |
418 | + for (size_t x = 0; x < width(); x++) { | |
419 | + size_t n = (y + w) * (width() + w * 2) + x + w; //calculate the index of the corresponding pixel in the result image | |
420 | + size_t n0 = idx(x,y); //calculate the index for this pixel in the original image | |
421 | + result.data()[n] = img[n0]; // copy the original image to the result image afer the border area | |
422 | + } | |
423 | + } | |
424 | + return result; | |
425 | + } | |
426 | + | |
411 | 427 | /// Copy the given data to the specified channel |
412 | 428 | |
413 | 429 | /// @param c is the channel number that the data will be copied to | ... | ... |
stim/math/filters/gauss2.cuh
... | ... | @@ -18,8 +18,8 @@ namespace stim { |
18 | 18 | ///@param nstds specifies the number of standard deviations of the Gaussian that will be kept in the kernel |
19 | 19 | template<typename T, typename K> |
20 | 20 | stim::image<T> cpu_gauss2(const stim::image<T>& in, K stdx, K stdy, size_t nstds = 3) { |
21 | - size_t kx = stdx * nstds * 2; //calculate the kernel sizes | |
22 | - size_t ky = stdy * nstds * 2; | |
21 | + size_t kx = stdx * nstds * 2 + 1; //calculate the kernel sizes | |
22 | + size_t ky = stdy * nstds * 2 + 1; | |
23 | 23 | size_t X = in.width() - kx + 1; //calculate the size of the output image |
24 | 24 | size_t Y = in.height() - ky + 1; |
25 | 25 | stim::image<T> r(X, Y, in.channels()); //create an output image | ... | ... |