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 | 402 | /// Set all elements in the image to a given scalar value |
403 | 403 | |
404 | 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 | 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 | 411 | return *this; |
413 | - | |
414 | 412 | } |
415 | 413 | |
416 | 414 | /// invert the image, given a specified maximum value (ex. maxval = 255, I' = 255 - I) |
... | ... | @@ -426,8 +424,12 @@ public: |
426 | 424 | image<T> stretch(T low, T high) { |
427 | 425 | T maxval = maxv(); |
428 | 426 | T minval = minv(); |
429 | - | |
430 | 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 | 433 | size_t N = size(); //get the number of values in the image |
432 | 434 | T range = maxval - minval; //calculate the current range of the image |
433 | 435 | T desired_range = high - low; //calculate the desired range of the image | ... | ... |