Skip to content

Commit

Permalink
Fix overflow issue in threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
FolkeV committed May 27, 2019
1 parent 8034030 commit 1e9ca96
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion main.cu
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int main(int argc,char **argv){
cudaMallocManaged(&d_img , numPixels * sizeof(char));

// Pre process image
int imgMean = util::mean(image.data, numPixels);
unsigned int imgMean = util::mean(image.data, numPixels);
util::threshold(d_img, image.data, imgMean, numPixels);

// Run and time kernel
Expand Down
4 changes: 2 additions & 2 deletions utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

namespace util{
// Compute mean of image data
int mean(const unsigned char* img, const int N){
int mean = 0;
unsigned int mean(const unsigned char* img, const int N){
unsigned int mean = 0;

for(int i = 0; i<N; i++){
mean += img[i];
Expand Down

0 comments on commit 1e9ca96

Please sign in to comment.