Commit 25a48140 authored by Jasem Mutlaq's avatar Jasem Mutlaq

use qBound to limit value

parent 754ee1fe
......@@ -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);
}
}
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment