summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <[email protected]>2016-07-11 00:03:24 +0300
committerJasem Mutlaq <[email protected]>2016-07-11 00:03:24 +0300
commit25a481407c8ee5888a910c00753f5f25ca321d6b (patch)
treebd297586bf012f05826c60d8fe612d556f74112f
parent754ee1fe08d488338a0204c1c95a4f6cf813f34e (diff)
use qBound to limit value
-rw-r--r--kstars/fitsviewer/fitsdata.cpp30
-rw-r--r--kstars/fitsviewer/fitsdata.h2
2 files changed, 9 insertions, 23 deletions
diff --git a/kstars/fitsviewer/fitsdata.cpp b/kstars/fitsviewer/fitsdata.cpp
index 434e650..5b8eb49 100644
--- a/kstars/fitsviewer/fitsdata.cpp
+++ b/kstars/fitsviewer/fitsdata.cpp
@@ -974,7 +974,7 @@ double FITSData::getHFR(int x, int y)
return -1;
}
-void FITSData::applyFilter(FITSScale type, float *image, double min, double max)
+void FITSData::applyFilter(FITSScale type, float *image, float min, float max)
{
if (type == FITS_NONE /* || histogram == NULL*/)
return;
@@ -1043,10 +1043,8 @@ void FITSData::applyFilter(FITSScale type, float *image, double min, double max)
bufferVal = image[index];
if (bufferVal < min) bufferVal = min;
else if (bufferVal > max) bufferVal = max;
- val = (coeff * log(1 + bufferVal));
- if (val < min) val = min;
- else if (val > max) val = max;
- image_buffer[index] = val;
+ val = (coeff * log(1 + qBound(min, image[index], max)));
+ image_buffer[index] = qBound(min, val, max);
}
}
@@ -1071,10 +1069,7 @@ void FITSData::applyFilter(FITSScale type, float *image, double min, double max)
for (int k=0; k < width; k++)
{
index=k + row;
- bufferVal = (int) image[index];
- if (bufferVal < min) bufferVal = min;
- else if (bufferVal > max) bufferVal = max;
- val = (int) (coeff * sqrt(bufferVal));
+ val = (int) (coeff * sqrt(qBound(min, image[index], max)));
image_buffer[index] = val;
}
}
@@ -1100,10 +1095,7 @@ void FITSData::applyFilter(FITSScale type, float *image, double min, double max)
for (int k=0; k < width; k++)
{
index=k + row;
- bufferVal = image[index];
- if (bufferVal < min) bufferVal = min;
- else if (bufferVal > max) bufferVal = max;
- image_buffer[index] = bufferVal;
+ image_buffer[index] = qBound(min, image[index], max);
}
}
}
@@ -1130,10 +1122,7 @@ void FITSData::applyFilter(FITSScale type, float *image, double min, double max)
for (int k=0; k < width; k++)
{
index=k + row;
- bufferVal = image[index];
- if (bufferVal < min) bufferVal = min;
- else if (bufferVal > max) bufferVal = max;
- image_buffer[index] = bufferVal;
+ image_buffer[index] = qBound(min, image[index], max);
}
}
}
@@ -1185,11 +1174,8 @@ void FITSData::applyFilter(FITSScale type, float *image, double min, double max)
row = offset + j * width;
for (int k=0; k < width; k++)
{
- index=k + row;
- bufferVal = image[index];
- if (bufferVal < min) bufferVal = min;
- else if (bufferVal > max) bufferVal = max;
- image_buffer[index] = bufferVal;
+ index=k + row;
+ image_buffer[index] = qBound(min, image[index], max);
}
}
}
diff --git a/kstars/fitsviewer/fitsdata.h b/kstars/fitsviewer/fitsdata.h
index af84e3f..cd6dee3 100644
--- a/kstars/fitsviewer/fitsdata.h
+++ b/kstars/fitsviewer/fitsdata.h
@@ -159,7 +159,7 @@ public:
void setHistogram(FITSHistogram *inHistogram) { histogram = inHistogram; }
// Filter
- void applyFilter(FITSScale type, float *image=NULL, double min=-1, double max=-1);
+ void applyFilter(FITSScale type, float *image=NULL, float min=-1, float max=-1);
// Rotation counter. We keep count to rotate WCS keywords on save
int getRotCounter() const;