Commit a8ad91925c3e6085a4440a8e9387bbff5a71c725
1 parent
929095ab
removed warnings from stim::bmp
Showing
1 changed file
with
10 additions
and
8 deletions
Show diff stats
stim/image/image.h
@@ -402,15 +402,13 @@ public: | @@ -402,15 +402,13 @@ public: | ||
402 | /// Set all elements in the image to a given scalar value | 402 | /// Set all elements in the image to a given scalar value |
403 | 403 | ||
404 | /// @param v is the value used to set all values in the image | 404 | /// @param v is the value used to set all values in the image |
405 | - image<T> operator=(T v){ | ||
406 | - | 405 | + void set_all(T v) { //set all elements of the image to a given value v |
407 | size_t N = size(); | 406 | size_t N = size(); |
408 | - | ||
409 | - for(size_t n = 0; n < N; n++) | ||
410 | - img[n] = v; | ||
411 | - | 407 | + for (size_t n = 0; n < N; n++) img[n] = v; |
408 | + } | ||
409 | + image<T> operator=(T v){ | ||
410 | + set_all(v); | ||
412 | return *this; | 411 | return *this; |
413 | - | ||
414 | } | 412 | } |
415 | 413 | ||
416 | /// invert the image, given a specified maximum value (ex. maxval = 255, I' = 255 - I) | 414 | /// invert the image, given a specified maximum value (ex. maxval = 255, I' = 255 - I) |
@@ -426,8 +424,12 @@ public: | @@ -426,8 +424,12 @@ public: | ||
426 | image<T> stretch(T low, T high) { | 424 | image<T> stretch(T low, T high) { |
427 | T maxval = maxv(); | 425 | T maxval = maxv(); |
428 | T minval = minv(); | 426 | T minval = minv(); |
429 | - | ||
430 | image<T> result = *this; //create a new image for output | 427 | image<T> result = *this; //create a new image for output |
428 | + if (maxval == minval) { //if the minimum and maximum values are the same, return an image composed of low | ||
429 | + result = low; | ||
430 | + return result; | ||
431 | + } | ||
432 | + | ||
431 | size_t N = size(); //get the number of values in the image | 433 | size_t N = size(); //get the number of values in the image |
432 | T range = maxval - minval; //calculate the current range of the image | 434 | T range = maxval - minval; //calculate the current range of the image |
433 | T desired_range = high - low; //calculate the desired range of the image | 435 | T desired_range = high - low; //calculate the desired range of the image |