From a8ad91925c3e6085a4440a8e9387bbff5a71c725 Mon Sep 17 00:00:00 2001 From: David Mayerich Date: Mon, 20 Feb 2017 10:13:39 -0600 Subject: [PATCH] removed warnings from stim::bmp --- stim/image/image.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/stim/image/image.h b/stim/image/image.h index a711abd..a479eb5 100644 --- a/stim/image/image.h +++ b/stim/image/image.h @@ -402,15 +402,13 @@ public: /// Set all elements in the image to a given scalar value /// @param v is the value used to set all values in the image - image operator=(T v){ - + void set_all(T v) { //set all elements of the image to a given value v size_t N = size(); - - for(size_t n = 0; n < N; n++) - img[n] = v; - + for (size_t n = 0; n < N; n++) img[n] = v; + } + image operator=(T v){ + set_all(v); return *this; - } /// invert the image, given a specified maximum value (ex. maxval = 255, I' = 255 - I) @@ -426,8 +424,12 @@ public: image stretch(T low, T high) { T maxval = maxv(); T minval = minv(); - image result = *this; //create a new image for output + if (maxval == minval) { //if the minimum and maximum values are the same, return an image composed of low + result = low; + return result; + } + size_t N = size(); //get the number of values in the image T range = maxval - minval; //calculate the current range of the image T desired_range = high - low; //calculate the desired range of the image -- libgit2 0.21.4