diff --git a/kstars/fitsviewer/bayer.c b/kstars/fitsviewer/bayer.c --- a/kstars/fitsviewer/bayer.c +++ b/kstars/fitsviewer/bayer.c @@ -854,28 +854,6 @@ if ((tile > DC1394_COLOR_FILTER_MAX) || (tile < DC1394_COLOR_FILTER_MIN)) return DC1394_INVALID_COLOR_FILTER; - /* add black border */ -#if 0 - int i, iinc, imax; - imax = sx * sy * 4; - for (i = sx * (sy - 1) * 4; i < imax; i++) - { - rgbx[i] = 0; - } - iinc = (sx - 1) * 4; - for (i = (sx - 1) * 4; i < imax; i += iinc) - { - rgbx[i++] = 0; - rgbx[i++] = 0; - rgbx[i++] = 0; - rgbx[i++] = 0; - } - - rgbx += 1; - height -= 1; - width -= 1; -#endif - for (; height--; bayer += bayerStep, rgbx += rgbStep) { const uint16_t *bayerEnd = bayer + width; diff --git a/kstars/fitsviewer/fitsdata.h b/kstars/fitsviewer/fitsdata.h --- a/kstars/fitsviewer/fitsdata.h +++ b/kstars/fitsviewer/fitsdata.h @@ -484,12 +484,6 @@ int partition(int width, int height, QVector &gradient, QVector &ids); void trace(int width, int height, int id, QVector &image, QVector &ids, int x, int y); -#if 0 - QVector thinning(int width, int height, const QVector &gradient, const QVector &direction); - QVector threshold(int thLow, int thHi, const QVector &image); - QVector hysteresis(int width, int height, const QVector &image); -#endif - #ifndef KSTARS_LITE FITSHistogram *histogram { nullptr }; // Pointer to the FITS data histogram #endif diff --git a/kstars/fitsviewer/fitsdata.cpp b/kstars/fitsviewer/fitsdata.cpp --- a/kstars/fitsviewer/fitsdata.cpp +++ b/kstars/fitsviewer/fitsdata.cpp @@ -393,9 +393,6 @@ m_Filename = finalFileName; - - //fits_open_image(&fptr, filename.toLatin1(), READONLY, &status); - // Use open diskfile as it does not use extended file names which has problems opening // files with [ ] or ( ) in their names. fits_open_diskfile(&fptr, m_Filename.toLatin1(), READONLY, &status); @@ -419,12 +416,6 @@ return status; } - /*if (fits_copy_file(fptr, new_fptr, 0, 1, 1, &status)) - { - fits_report_error(stderr, status); - return status; - }*/ - if (fits_copy_header(fptr, new_fptr, &status)) { fits_report_error(stderr, status); @@ -683,10 +674,6 @@ template void FITSData::calculateMinMax() { - //QTime timer; - //timer.start(); - //if (filename.contains("thread")) - //{ T min = std::numeric_limits::max(); T max = std::numeric_limits::min(); @@ -729,49 +716,6 @@ stats.min[n] = min; stats.max[n] = max; } -#if 0 -} -else -{ - T * buffer = reinterpret_cast(imageBuffer); - if (channels == 1) - { - for (unsigned int i = 0; i < stats.samples_per_channel; i++) - { - if (buffer[i] < stats.min[0]) - stats.min[0] = buffer[i]; - else if (buffer[i] > stats.max[0]) - stats.max[0] = buffer[i]; - } - } - else - { - int g_offset = stats.samples_per_channel; - int b_offset = stats.samples_per_channel * 2; - - for (unsigned int i = 0; i < stats.samples_per_channel; i++) - { - if (buffer[i] < stats.min[0]) - stats.min[0] = buffer[i]; - else if (buffer[i] > stats.max[0]) - stats.max[0] = buffer[i]; - - if (buffer[i + g_offset] < stats.min[1]) - stats.min[1] = buffer[i + g_offset]; - else if (buffer[i + g_offset] > stats.max[1]) - stats.max[1] = buffer[i + g_offset]; - - if (buffer[i + b_offset] < stats.min[2]) - stats.min[2] = buffer[i + b_offset]; - else if (buffer[i + b_offset] > stats.max[2]) - stats.max[2] = buffer[i + b_offset]; - } - } - -} - -qCInfo(KSTARS_FITS) << filename << "MinMax calculation took" << timer.elapsed() << "ms"; -#endif } template @@ -799,10 +743,6 @@ template void FITSData::runningAverageStdDev() { - //QTime timer; - //timer.start(); - //if (filename.contains("thread")) - //{ // Create N threads const uint8_t nThreads = 16; @@ -844,82 +784,6 @@ stats.mean[n] = mean / nThreads; stats.stddev[n] = sqrt(variance); } -#if 0 -} -else -{ - T * buffer = reinterpret_cast(imageBuffer); - - if (channels == 1) - { - int m_n = 2; - double m_oldM = 0, m_newM = 0, m_oldS = 0, m_newS = 0; - - for (unsigned int i = 1; i < stats.samples_per_channel; i++) - { - m_newM = m_oldM + (buffer[i] - m_oldM) / m_n; - m_newS = m_oldS + (buffer[i] - m_oldM) * (buffer[i] - m_newM); - - m_oldM = m_newM; - m_oldS = m_newS; - m_n++; - } - - double variance = (m_n == 2 ? 0 : m_newS / (m_n - 2)); - - stats.mean[0] = m_newM; - stats.stddev[0] = sqrt(variance); - } - else - { - int m_n[3] = {2, 2, 2}; - double m_oldM[3] = {0}, m_newM[3] = {0}, m_oldS[3] = {0}, m_newS[3] = {0}; - - T * rBuffer = buffer; - T * gBuffer = buffer + stats.samples_per_channel; - T * bBuffer = buffer + stats.samples_per_channel * 2; - - for (unsigned int i = 1; i < stats.samples_per_channel; i++) - { - m_newM[0] = m_oldM[0] + (rBuffer[i] - m_oldM[0]) / m_n[0]; - m_newS[0] = m_oldS[0] + (rBuffer[i] - m_oldM[0]) * (rBuffer[i] - m_newM[0]); - - m_oldM[0] = m_newM[0]; - m_oldS[0] = m_newS[0]; - m_n[0]++; - - m_newM[1] = m_oldM[1] + (gBuffer[i] - m_oldM[1]) / m_n[1]; - m_newS[1] = m_oldS[1] + (gBuffer[i] - m_oldM[1]) * (gBuffer[i] - m_newM[1]); - - m_oldM[1] = m_newM[1]; - m_oldS[1] = m_newS[1]; - m_n[1]++; - - m_newM[2] = m_oldM[2] + (bBuffer[i] - m_oldM[2]) / m_n[2]; - m_newS[2] = m_oldS[2] + (bBuffer[i] - m_oldM[2]) * (bBuffer[i] - m_newM[2]); - - m_oldM[2] = m_newM[2]; - m_oldS[2] = m_newS[2]; - m_n[2]++; - - } - - double variance = (m_n[0] == 2 ? 0 : m_newS[0] / (m_n[0] - 2)); - stats.mean[0] = m_newM[0]; - stats.stddev[0] = sqrt(variance); - - variance = (m_n[1] == 2 ? 0 : m_newS[1] / (m_n[1] - 2)); - stats.mean[1] = m_newM[1]; - stats.stddev[1] = sqrt(variance); - - variance = (m_n[2] == 2 ? 0 : m_newS[2] / (m_n[2] - 2)); - stats.mean[2] = m_newM[2]; - stats.stddev[2] = sqrt(variance); - } -} - -qCInfo(KSTARS_FITS) << filename << "runningMeanStdDev calculation took" << timer.elapsed() << "ms"; -#endif } void FITSData::setMinMax(double newMin, double newMax, uint8_t channel) @@ -1170,8 +1034,6 @@ int maxID = boundedImage->partition(subW, subH, gradients, ids); - //QVector thresholded = boundedImage->threshold(boundedImage->stats.mean[0], boundedImage->stats.max[0], gradients); - // Not needed anymore delete boundedImage; @@ -1287,14 +1149,6 @@ const T * origBuffer = reinterpret_cast(data->getImageBuffer()) + offset; - /*if (Options::fITSLogging()) - { - QDebug deb = qDebug(); - - for (int i=0; i < subW; i++) - deb << origBuffer[i + cen_y * dataWidth] << ","; - }*/ - for (double x = leftEdge; x <= rightEdge; x += resolution) { double slice = resolution * (origBuffer[static_cast(floor(x)) + cen_y * dataWidth]); @@ -2410,273 +2264,6 @@ default: break; } -#if 0 -} -else -{ - uint32_t index = 0, row = 0, offset = 0; - - switch (type) - { - case FITS_AUTO: - case FITS_LINEAR: - { - for (uint8_t i = 0; i < channels; i++) - { - offset = i * stats.samples_per_channel; - for (uint32_t j = 0; j < height; j++) - { - row = offset + j * width; - for (uint32_t k = 0; k < width; k++) - { - index = k + row; - image[index] = qBound(min, image[index], max); - } - } - } - - if (calcStats) - { - stats.min[0] = min; - stats.max[0] = max; - } - } - break; - - case FITS_LOG: - { - double coeff = max / log(1 + max); - - for (int i = 0; i < channels; i++) - { - offset = i * stats.samples_per_channel; - for (uint32_t j = 0; j < height; j++) - { - row = offset + j * width; - for (uint32_t k = 0; k < width; k++) - { - index = k + row; - image[index] = qBound(min, static_cast(round(coeff * log(1 + qBound(min, image[index], max)))), max); - } - } - } - - if (calcStats) - { - stats.min[0] = min; - stats.max[0] = max; - runningAverageStdDev(); - } - } - break; - - case FITS_SQRT: - { - double coeff = max / sqrt(max); - - for (int i = 0; i < channels; i++) - { - offset = i * stats.samples_per_channel; - for (uint32_t j = 0; j < height; j++) - { - row = offset + j * width; - for (uint32_t k = 0; k < width; k++) - { - index = k + row; - image[index] = qBound(min, static_cast(round(coeff * image[index])), max); - } - } - } - - if (calcStats) - { - stats.min[0] = min; - stats.max[0] = max; - runningAverageStdDev(); - } - } - break; - - // Only difference is how min and max are set - case FITS_AUTO_STRETCH: - case FITS_HIGH_CONTRAST: - { - for (uint32_t i = 0; i < channels; i++) - { - offset = i * stats.samples_per_channel; - for (uint32_t j = 0; j < height; j++) - { - row = offset + j * width; - for (uint32_t k = 0; k < width; k++) - image[k + row] = qBound(min, image[k + row], max); - } - } - if (calcStats) - { - stats.min[0] = min; - stats.max[0] = max; - runningAverageStdDev(); - } - } - break; - - case FITS_EQUALIZE: - { -#ifndef KSTARS_LITE - if (histogram == nullptr) - return; - - T bufferVal = 0; - QVector cumulativeFreq = histogram->getCumulativeFrequency(); - - double coeff = 255.0 / (height * width); - - for (uint32_t i = 0; i < channels; i++) - { - offset = i * stats.samples_per_channel; - for (uint32_t j = 0; j < height; j++) - { - row = offset + j * width; - for (uint32_t k = 0; k < width; k++) - { - index = k + row; - bufferVal = (image[index] - min) / histogram->getBinWidth(); - - if (bufferVal >= cumulativeFreq.size()) - bufferVal = cumulativeFreq.size() - 1; - - image[index] = qBound(min, static_cast(round(coeff * cumulativeFreq[bufferVal])), max); - } - } - } -#endif - } - if (calcStats) - calculateStats(true); - break; - - case FITS_HIGH_PASS: - { - min = stats.mean[0]; - for (uint32_t i = 0; i < channels; i++) - { - offset = i * stats.samples_per_channel; - for (uint32_t j = 0; j < height; j++) - { - row = offset + j * width; - for (uint32_t k = 0; k < width; k++) - { - index = k + row; - image[index] = qBound(min, image[index], max); - } - } - } - - if (calcStats) - { - stats.min[0] = min; - stats.max[0] = max; - runningAverageStdDev(); - } - } - break; - - // Based on http://www.librow.com/articles/article-1 - case FITS_MEDIAN: - { - int BBP = stats.bytesPerPixel; - T * extension = new T[(width + 2) * (height + 2)]; - // Check memory allocation - if (!extension) - return; - // Create image extension - for (uint32_t ch = 0; ch < channels; ch++) - { - offset = ch * stats.samples_per_channel; - uint32_t N = width, M = height; - - for (uint32_t i = 0; i < M; ++i) - { - memcpy(extension + (N + 2) * (i + 1) + 1, image + (N * i) + offset, N * BBP); - extension[(N + 2) * (i + 1)] = image[N * i + offset]; - extension[(N + 2) * (i + 2) - 1] = image[N * (i + 1) - 1 + offset]; - } - // Fill first line of image extension - memcpy(extension, extension + N + 2, (N + 2) * BBP); - // Fill last line of image extension - memcpy(extension + (N + 2) * (M + 1), extension + (N + 2) * M, (N + 2) * BBP); - // Call median filter implementation - - N = width + 2; - M = height + 2; - - // Move window through all elements of the image - for (uint32_t m = 1; m < M - 1; ++m) - for (uint32_t n = 1; n < N - 1; ++n) - { - // Pick up window elements - int k = 0; - float window[9]; - - memset(&window[0], 0, 9 * sizeof(float)); - for (uint32_t j = m - 1; j < m + 2; ++j) - for (uint32_t i = n - 1; i < n + 2; ++i) - window[k++] = extension[j * N + i]; - // Order elements (only half of them) - for (uint32_t j = 0; j < 5; ++j) - { - // Find position of minimum element - int mine = j; - for (uint32_t l = j + 1; l < 9; ++l) - if (window[l] < window[mine]) - mine = l; - // Put found minimum element in its place - const float temp = window[j]; - window[j] = window[mine]; - window[mine] = temp; - } - // Get result - the middle element - image[(m - 1) * (N - 2) + n - 1 + offset] = window[4]; - } - } - - // Free memory - delete[] extension; - - if (calcStats) - runningAverageStdDev(); - } - break; - - case FITS_ROTATE_CW: - rotFITS(90, 0); - rotCounter++; - break; - - case FITS_ROTATE_CCW: - rotFITS(270, 0); - rotCounter--; - break; - - case FITS_FLIP_H: - rotFITS(0, 1); - flipHCounter++; - break; - - case FITS_FLIP_V: - rotFITS(0, 2); - flipVCounter++; - break; - - case FITS_CUSTOM: - default: - return; - break; - } -} - -qCInfo(KSTARS_FITS) << filename << "Apply Filter calculation took" << timer.elapsed() << "ms"; -#endif } QList FITSData::getStarCentersInSubFrame(QRect subFrame) const @@ -3901,93 +3488,6 @@ * Web-Site: http://github.com/hipersayanX/CannyDetector */ -#if 0 -void FITSData::sobel(const QImage &image, QVector &gradient, QVector &direction) -{ - int size = image.width() * image.height(); - gradient.resize(size); - direction.resize(size); - - for (int y = 0; y < image.height(); y++) - { - size_t yOffset = y * image.width(); - const quint8 * grayLine = image.constBits() + yOffset; - - const quint8 * grayLine_m1 = y < 1 ? grayLine : grayLine - image.width(); - const quint8 * grayLine_p1 = y >= image.height() - 1 ? grayLine : grayLine + image.width(); - - int * gradientLine = gradient.data() + yOffset; - int * directionLine = direction.data() + yOffset; - - for (int x = 0; x < image.width(); x++) - { - int x_m1 = x < 1 ? x : x - 1; - int x_p1 = x >= image.width() - 1 ? x : x + 1; - - int gradX = grayLine_m1[x_p1] - + 2 * grayLine[x_p1] - + grayLine_p1[x_p1] - - grayLine_m1[x_m1] - - 2 * grayLine[x_m1] - - grayLine_p1[x_m1]; - - int gradY = grayLine_m1[x_m1] - + 2 * grayLine_m1[x] - + grayLine_m1[x_p1] - - grayLine_p1[x_m1] - - 2 * grayLine_p1[x] - - grayLine_p1[x_p1]; - - gradientLine[x] = qAbs(gradX) + qAbs(gradY); - - /* Gradient directions are classified in 4 possible cases - * - * dir 0 - * - * x x x - * - - - - * x x x - * - * dir 1 - * - * x x / - * x / x - * / x x - * - * dir 2 - * - * \ x x - * x \ x - * x x \ - * - * dir 3 - * - * x | x - * x | x - * x | x - */ - if (gradX == 0 && gradY == 0) - directionLine[x] = 0; - else if (gradX == 0) - directionLine[x] = 3; - else - { - qreal a = 180. * atan(qreal(gradY) / gradX) / M_PI; - - if (a >= -22.5 && a < 22.5) - directionLine[x] = 0; - else if (a >= 22.5 && a < 67.5) - directionLine[x] = 1; - else if (a >= -67.5 && a < -22.5) - directionLine[x] = 2; - else - directionLine[x] = 3; - } - } - } -} -#endif - template void FITSData::sobel(QVector &gradient, QVector &direction) { @@ -4138,113 +3638,6 @@ autoRemoveTemporaryFITS = value; } -#if 0 -QVector FITSData::thinning(int width, int height, const QVector &gradient, const QVector &direction) -{ - QVector thinned(gradient.size()); - - for (int y = 0; y < height; y++) - { - int yOffset = y * width; - const int * gradientLine = gradient.constData() + yOffset; - const int * gradientLine_m1 = y < 1 ? gradientLine : gradientLine - width; - const int * gradientLine_p1 = y >= height - 1 ? gradientLine : gradientLine + width; - const int * directionLine = direction.constData() + yOffset; - int * thinnedLine = thinned.data() + yOffset; - - for (int x = 0; x < width; x++) - { - int x_m1 = x < 1 ? 0 : x - 1; - int x_p1 = x >= width - 1 ? x : x + 1; - - int direction = directionLine[x]; - int pixel = 0; - - if (direction == 0) - { - /* x x x - * - - - - * x x x - */ - if (gradientLine[x] < gradientLine[x_m1] - || gradientLine[x] < gradientLine[x_p1]) - pixel = 0; - else - pixel = gradientLine[x]; - } - else if (direction == 1) - { - /* x x / - * x / x - * / x x - */ - if (gradientLine[x] < gradientLine_m1[x_p1] - || gradientLine[x] < gradientLine_p1[x_m1]) - pixel = 0; - else - pixel = gradientLine[x]; - } - else if (direction == 2) - { - /* \ x x - * x \ x - * x x \ - */ - if (gradientLine[x] < gradientLine_m1[x_m1] - || gradientLine[x] < gradientLine_p1[x_p1]) - pixel = 0; - else - pixel = gradientLine[x]; - } - else - { - /* x | x - * x | x - * x | x - */ - if (gradientLine[x] < gradientLine_m1[x] - || gradientLine[x] < gradientLine_p1[x]) - pixel = 0; - else - pixel = gradientLine[x]; - } - - thinnedLine[x] = pixel; - } - } - - return thinned; -} - -QVector FITSData::threshold(int thLow, int thHi, const QVector &image) -{ - QVector thresholded(image.size()); - - for (int i = 0; i < image.size(); i++) - thresholded[i] = image[i] <= thLow ? 0 : - image[i] >= thHi ? 255 : - 127; - - return thresholded; -} - -QVector FITSData::hysteresis(int width, int height, const QVector &image) -{ - QVector canny(image); - - for (int y = 0; y < height; y++) - for (int x = 0; x < width; x++) - trace(width, height, canny, x, y); - - // Remaining gray pixels becomes black. - for (int i = 0; i < canny.size(); i++) - if (canny[i] == 127) - canny[i] = 0; - - return canny; -} - -#endif template void FITSData::convertToQImage(double dataMin, double dataMax, double scale, double zero, QImage &image) @@ -4770,18 +4163,6 @@ status = sep_extract(&im, 2 * bkg->globalrms, SEP_THRESH_ABS, 10, conv, 3, 3, SEP_FILTER_CONV, 32, 1.0, 1, 1.0, &catalog); if (status != 0) goto exit; -#if 0 - // #4 Aperture photometry - im.noise = &(bkg->globalrms); /* set image noise level */ - im.ndtype = SEP_TFLOAT; - fluxt = flux = (double *)malloc(catalog->nobj * sizeof(double)); - fluxerrt = fluxerr = (double *)malloc(catalog->nobj * sizeof(double)); - areat = area = (double *)malloc(catalog->nobj * sizeof(double)); - flagt = flag = (short *)malloc(catalog->nobj * sizeof(short)); - for (int i = 0; i < catalog->nobj; i++, fluxt++, fluxerrt++, flagt++, areat++) - sep_sum_circle(&im, catalog->x[i], catalog->y[i], 10.0, 5, 0, fluxt, fluxerrt, areat, flagt); -#endif - // TODO // Must detect edge detection // Must limit to brightest 100 (by flux) centers diff --git a/kstars/fitsviewer/fitsview.cpp b/kstars/fitsviewer/fitsview.cpp --- a/kstars/fitsviewer/fitsview.cpp +++ b/kstars/fitsviewer/fitsview.cpp @@ -75,12 +75,6 @@ redScopePixmap = QPixmap(":/icons/center_telescope_red.svg").scaled(32, 32, Qt::KeepAspectRatio, Qt::FastTransformation); magentaScopePixmap = QPixmap(":/icons/center_telescope_magenta.svg").scaled(32, 32, Qt::KeepAspectRatio, Qt::FastTransformation); - - //if (fitsMode == FITS_GUIDE) - //connect(image_frame.get(), SIGNAL(pointSelected(int,int)), this, SLOT(processPointSelection(int,int))); - - // Default size - //resize(INITIAL_W, INITIAL_H); } FITSView::~FITSView() @@ -157,132 +151,6 @@ QScrollArea::resizeEvent(event); } -#if 0 - -bool FITSView::loadFITS(const QString &inFilename, bool silent) -{ - if (floatingToolBar != nullptr) - { - floatingToolBar->setVisible(true); - } - - QProgressDialog fitsProg(this); - - bool setBayerParams = false; - - BayerParams param; - if ((imageData != nullptr) && imageData->hasDebayer()) - { - setBayerParams = true; - imageData->getBayerParams(¶m); - } - - // In case loadWCS is still running for previous image data, let's wait until it's over - wcsWatcher.waitForFinished(); - - delete imageData; - imageData = nullptr; - - filterStack.clear(); - filterStack.push(FITS_NONE); - if (filter != FITS_NONE) - filterStack.push(filter); - - imageData = new FITSData(mode); - - if (setBayerParams) - imageData->setBayerParams(¶m); - - if (mode == FITS_NORMAL) - { - fitsProg.setWindowModality(Qt::WindowModal); - fitsProg.setLabelText(i18n("Please hold while loading FITS file...")); - fitsProg.setWindowTitle(i18n("Loading FITS")); - fitsProg.setValue(10); - qApp->processEvents(); - } - - if (!imageData->loadFITS(inFilename, silent)) - return false; - - if (mode == FITS_NORMAL) - { - if (fitsProg.wasCanceled()) - return false; - else - { - fitsProg.setValue(65); - qApp->processEvents(); - } - } - - emit debayerToggled(imageData->hasDebayer()); - - currentWidth = imageData->width(); - currentHeight = imageData->height(); - - image_width = currentWidth; - image_height = currentHeight; - - image_frame->setSize(image_width, image_height); - - initDisplayImage(); - - // Rescale to fits window - if (firstLoad) - { - currentZoom = 100; - - if (rescale(ZOOM_FIT_WINDOW) != 0) - return false; - - firstLoad = false; - } - else - { - if (rescale(ZOOM_KEEP_LEVEL) != 0) - return false; - } - - if (mode == FITS_NORMAL) - { - if (fitsProg.wasCanceled()) - return false; - else - { - fitsProg.setValue(100); - qApp->processEvents(); - } - } - - setAlignment(Qt::AlignCenter); - - // Load WCS data now if selected and image contains valid WCS header - if (imageData->hasWCS() && Options::autoWCS() && (mode == FITS_NORMAL || mode == FITS_ALIGN) && !wcsWatcher.isRunning()) - { - QFuture future = QtConcurrent::run(imageData, &FITSData::loadWCS); - wcsWatcher.setFuture(future); - } - else - syncWCSState(); - - if (isVisible()) - emit newStatus(QString("%1x%2").arg(image_width).arg(image_height), FITS_RESOLUTION); - - if (showStarProfile) - { - if(floatingToolBar != nullptr) - toggleProfileAction->setChecked(true); - QTimer::singleShot(100, this, SLOT(viewStarProfile())); //Need to wait till the Focus module finds stars, if its the Focus module. - } - - updateFrame(); - - emit imageLoaded(); - - return true; -} -#endif void FITSView::loadFITS(const QString &inFilename, bool silent) { @@ -348,22 +216,7 @@ uint8_t * ASImageBuffer = nullptr; - // if (Options::autoStretch() && (filter == FITS_NONE || (filter >= FITS_ROTATE_CW && filter <= FITS_FLIP_V))) - // { - // // If we perform autostretch, we need to create a buffer to save the raw image data before - // // autostretch filter operation changes the data. - // // After rescaling is done, we - // uint32_t totalBytes = image_width * image_height *imageData->channels() * imageData->getBytesPerPixel(); - // ASImageBuffer = new uint8_t[totalBytes]; - // memcpy(ASImageBuffer, imageData->getImageBuffer(), totalBytes); - // imageData->applyFilter(FITS_AUTO_STRETCH); - // } - // else - // imageData->applyFilter(filter); - imageData->applyFilter(filter); - // if (Options::autoStretch()) - // imageData->applyFilter(FITS_AUTO_STRETCH); // Rescale to fits window on first load if (firstLoad) @@ -391,12 +244,6 @@ } } - // Restore original raw buffer after Autostretch if applicable - // if (ASImageBuffer) - // { - // imageData->setImageBuffer(ASImageBuffer); - // } - setAlignment(Qt::AlignCenter); // Load WCS data now if selected and image contains valid WCS header @@ -532,32 +379,6 @@ } } -#if 0 - int BBP = imageData->getBytesPerPixel(); - filter = filterStack.last(); - - if (Options::autoStretch() && (filter == FITS_NONE || (filter >= FITS_ROTATE_CW && filter <= FITS_FLIP_V))) - { - image_buffer = new uint8_t[size * imageData->channels() * BBP]; - memcpy(image_buffer, imageData->getImageBuffer(), size * imageData->channels() * BBP); - - displayBuffer = true; - - double data_min = -1; - double data_max = -1; - - imageData->applyFilter(FITS_AUTO_STRETCH, image_buffer, &data_min, &data_max); - - min = data_min; - max = data_max; - } - else - { - imageData->applyFilter(filter); - imageData->getMinMax(&min, &max); - } -#endif - scaledImage = QImage(); auto * buffer = reinterpret_cast(displayBuffer); @@ -643,43 +464,6 @@ future.waitForFinished(); } -#if 0 - if (imageData->getNumOfChannels() == 1) - { - /* Fill in pixel values using indexed map, linear scale */ - for (int j = 0; j < image_height; j++) - { - unsigned char * scanLine = display_image->scanLine(j); - - for (int i = 0; i < image_width; i++) - { - val = buffer[j * image_width + i] * bscale + bzero; - scanLine[i] = qBound(0.0, val, 255.0); - } - } - } - else - { - double rval = 0, gval = 0, bval = 0; - QRgb value; - /* Fill in pixel values using indexed map, linear scale */ - for (int j = 0; j < image_height; j++) - { - QRgb * scanLine = reinterpret_cast((display_image->scanLine(j))); - - for (int i = 0; i < image_width; i++) - { - rval = buffer[j * image_width + i]; - gval = buffer[j * image_width + i + size]; - bval = buffer[j * image_width + i + size * 2]; - - value = qRgb(rval * bscale + bzero, gval * bscale + bzero, bval * bscale + bzero); - - scanLine[i] = value; - } - } - } -#endif } // Clear memory if it was allocated. @@ -1610,12 +1394,6 @@ void FITSView::processPointSelection(int x, int y) { - //if (mode != FITS_GUIDE) - //return; - - //image_data->getCenterSelection(&x, &y); - - //setGuideSquare(x,y); emit trackingStarSelected(x, y); }