Stretch and calculate stats on demand
This commit is contained in:
+10
-5
@@ -28,18 +28,23 @@ StretchPanel::StretchPanel(QWidget *parent) : QWidget(parent)
|
||||
resetButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
layout->addWidget(resetButton);
|
||||
connect(resetButton, SIGNAL(pressed()), this, SLOT(resetMTF()));
|
||||
|
||||
QPushButton *autoStretchButton = new QPushButton(tr("Autostretch"), this);
|
||||
autoStretchButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
layout->addWidget(autoStretchButton);
|
||||
connect(autoStretchButton, SIGNAL(pressed()), this, SIGNAL(autoStretch()));
|
||||
}
|
||||
|
||||
void StretchPanel::imageLoaded(Image *img)
|
||||
void StretchPanel::stretchImage(Image *img)
|
||||
{
|
||||
if(img)
|
||||
{
|
||||
if(img->rawImage())
|
||||
{
|
||||
double mean, stdDev, median;
|
||||
img->rawImage()->imageStats(&mean, &stdDev, &median, nullptr, nullptr);
|
||||
median /= 65536;
|
||||
double mad = img->rawImage()->MAD() / 65536;
|
||||
double median, mad;
|
||||
img->rawImage()->imageStats(nullptr, nullptr, &median, nullptr, nullptr, &mad);
|
||||
median /= img->rawImage()->norm();
|
||||
mad /= img->rawImage()->norm();
|
||||
float bp = median + mad * BLACK_POINT_SIGMA * MAD_TO_SIGMA;
|
||||
float mid = MTF(median - bp, TARGET_BACKGROUND);
|
||||
m_stfSlider->setMTFParams(bp, mid, 1.0f);
|
||||
|
||||
Reference in New Issue
Block a user