void FITSHistogramCommand::undo() { FITSView *image = tab->getView(); FITSData *image_data = image->getImageData(); QApplication::setOverrideCursor(Qt::WaitCursor); if (delta != NULL) { double min,max,stddev,average,median,snr; min = image_data->getMin(); max = image_data->getMax(); stddev = image_data->getStdDev(); average = image_data->getMean(); median = image_data->getMedian(); snr = image_data->getSNR(); reverseDelta(); restoreStats(); saveStats(min, max, stddev, average, median, snr); } else { switch (type) { case FITS_ROTATE_CW: image_data->applyFilter(FITS_ROTATE_CCW); break; case FITS_ROTATE_CCW: image_data->applyFilter(FITS_ROTATE_CW); break; case FITS_FLIP_H: case FITS_FLIP_V: image_data->applyFilter(type); break; default: break; } } if (histogram != NULL) { histogram->constructHistogram(); if (tab->getViewer()->isStarsMarked()) image_data->findStars(); } image->popFilter(); image->rescale(ZOOM_KEEP_LEVEL); image->updateFrame(); QApplication::restoreOverrideCursor(); }
void Focus::newFITS(IBLOB *bp) { INDI_UNUSED(bp); QString HFRText; // Ignore guide head if there is any. if (!strcmp(bp->name, "CCD2")) return; ISD::CCDChip *targetChip = currentCCD->getChip(ISD::CCDChip::PRIMARY_CCD); FITSView *targetImage = targetChip->getImage(FITS_FOCUS); FITSImage *image_data = targetImage->getImageData(); currentCCD->disconnect(this); if (targetImage == NULL) { qDebug() << "Error: targetImage is NULL!" << endl; return; } image_data->findStars(); double currentHFR= image_data->getHFR(HFR_MAX); HFRText = QString("%1").arg(currentHFR, 0,'g', 3); if (inFocusLoop == false && focusType == FOCUS_MANUAL && HFR == -1) appendLogText(i18n("FITS received. No stars detected.")); HFROut->setText(HFRText); if (inFocusLoop) { capture(); return; } if (focusType == FOCUS_MANUAL || inAutoFocus==false) return; if (canAbsMove) autoFocusAbs(currentHFR); else autoFocusRel(currentHFR); }
void FITSHistogramCommand::redo() { FITSView *image = tab->getImage(); FITSImage *image_data = image->getImageData(); float *image_buffer = image_data->getImageBuffer(); int width = image_data->getWidth(); int height = image_data->getHeight(); memcpy(buffer, image_buffer, width * height * sizeof(float)); switch (type) { case FITS_AUTO: case FITS_LINEAR: image_data->applyFilter(FITS_LINEAR, image_buffer, min, max); break; case FITS_LOG: image_data->applyFilter(FITS_LOG, image_buffer, min, max); break; case FITS_SQRT: image_data->applyFilter(FITS_SQRT, image_buffer, min, max); break; default: image_data->applyFilter(type, image_buffer); break; } if (histogram != NULL) { histogram->updateHistogram(); if (tab->getViewer()->isStarsMarked()) image_data->findStars(); } image->rescale(ZOOM_KEEP_LEVEL); image->updateFrame(); }
bool FITSHistogramCommand::reverseDelta() { FITSView *image = tab->getView(); FITSData *image_data = image->getImageData(); uint8_t *image_buffer = (image_data->getImageBuffer()); unsigned int size = image_data->getSize(); int channels = image_data->getNumOfChannels(); int totalPixels = size * channels; unsigned long totalBytes = totalPixels * image_data->getBytesPerPixel(); uint8_t *output_image = new uint8_t[totalBytes]; if (output_image == NULL) { qWarning() << "Error! not enough memory to create output image" << endl; return false; } uint8_t *raw_delta = new uint8_t[totalBytes]; if (raw_delta == NULL) { delete(output_image); qWarning() << "Error! not enough memory to create image delta" << endl; return false; } int r = uncompress(raw_delta, &totalBytes, delta, compressedBytes); if (r != Z_OK) { qDebug() << "FITSHistogram compression error in reverseDelta()" << endl; delete [] raw_delta; return false; } for (unsigned int i=0; i < totalBytes; i++) output_image[i] = raw_delta[i] ^ image_buffer[i]; image_data->setImageBuffer(output_image); delete [] raw_delta; return true; }
void Guide::newFITS(IBLOB *bp) { INDI_UNUSED(bp); FITSViewer *fv = currentCCD->getViewer(); disconnect(currentCCD, SIGNAL(BLOBUpdated(IBLOB*)), this, SLOT(newFITS(IBLOB*))); ISD::CCDChip *targetChip = currentCCD->getChip(useGuideHead ? ISD::CCDChip::GUIDE_CCD : ISD::CCDChip::PRIMARY_CCD); FITSView *targetImage = targetChip->getImage(FITS_GUIDE); FITSImage *image_data = targetImage->getImageData(); image_data->findStars(); pmath->set_image(targetImage); guider->set_image(targetImage); calibration->set_image(targetImage); fv->show(); if (guider->is_guiding()) { guider->guide(); if (guider->is_guiding()) capture(); } else if (calibration->is_calibrating()) { pmath->do_processing(); calibration->process_calibration(); if (calibration->is_calibrating()) capture(); if (calibration->is_finished()) { guider->set_ready(true); tabWidget->setTabEnabled(1, true); } } }
void FITSHistogramCommand::undo() { FITSView *image = tab->getImage(); FITSImage *image_data = image->getImageData(); memcpy( image_data->getImageBuffer(), buffer, image_data->getWidth() * image_data->getHeight() * sizeof(float)); image_data->calculateStats(true); if (histogram != NULL) { histogram->updateHistogram(); if (tab->getViewer()->isStarsMarked()) image_data->findStars(); } image->rescale(ZOOM_KEEP_LEVEL); image->updateFrame(); }
void FITSHistogramCommand::redo() { FITSView *image = tab->getView(); FITSData *image_data = image->getImageData(); uint8_t *image_buffer = image_data->getImageBuffer(); unsigned int size = image_data->getSize(); int channels = image_data->getNumOfChannels(); int BBP = image_data->getBytesPerPixel(); QApplication::setOverrideCursor(Qt::WaitCursor); if (delta != NULL) { double min,max,stddev,average,median,snr; min = image_data->getMin(); max = image_data->getMax(); stddev = image_data->getStdDev(); average = image_data->getMean(); median = image_data->getMedian(); snr = image_data->getSNR(); reverseDelta(); restoreStats(); saveStats(min, max, stddev, average, median, snr); } else { saveStats(image_data->getMin(), image_data->getMax(), image_data->getStdDev(), image_data->getMean(), image_data->getMedian(), image_data->getSNR()); // If it's rotation of flip, no need to calculate delta if (type >= FITS_ROTATE_CW && type <= FITS_FLIP_V) { image_data->applyFilter(type, image_buffer); } else { uint8_t *buffer = new uint8_t[size * channels * BBP]; if (buffer == NULL) { qWarning() << "Error! not enough memory to create image buffer in redo()" << endl; QApplication::restoreOverrideCursor(); return; } memcpy(buffer, image_buffer, size * channels * BBP); float dataMin = min, dataMax = max; switch (type) { case FITS_AUTO: case FITS_LINEAR: image_data->applyFilter(FITS_LINEAR, NULL, &dataMin, &dataMax); break; case FITS_LOG: image_data->applyFilter(FITS_LOG, NULL, &dataMin, &dataMax); break; case FITS_SQRT: image_data->applyFilter(FITS_SQRT, NULL, &dataMin, &dataMax); break; default: image_data->applyFilter(type); break; } calculateDelta(buffer); delete [] buffer; } } if (histogram != NULL) { histogram->constructHistogram(); if (tab->getViewer()->isStarsMarked()) image_data->findStars(); } image->pushFilter(type); image->rescale(ZOOM_KEEP_LEVEL); image->updateFrame(); QApplication::restoreOverrideCursor(); }
void Capture::newFITS(IBLOB *bp) { ISD::CCDChip *tChip = NULL; if (!strcmp(bp->name, "CCD2")) tChip = currentCCD->getChip(ISD::CCDChip::GUIDE_CCD); else tChip = currentCCD->getChip(ISD::CCDChip::PRIMARY_CCD); if (tChip != targetChip) return; if (targetChip->getCaptureMode() == FITS_FOCUS || targetChip->getCaptureMode() == FITS_GUIDE) return; // If the FITS is not for our device, simply ignore if (QString(bp->bvp->device) != currentCCD->getDeviceName() || (startB->isEnabled() && previewB->isEnabled())) return; if (calibrationState == CALIBRATE_START) { calibrationState = CALIBRATE_DONE; seqTimer->start(seqDelay); return; } if (darkSubCheck->isChecked() && calibrationState == CALIBRATE_DONE) { calibrationState = CALIBRATE_NONE; FITSView *calibrateImage = targetChip->getImage(FITS_CALIBRATE); FITSView *currentImage = targetChip->getImage(FITS_NORMAL); FITSImage *image_data = currentImage->getImageData(); if (calibrateImage && currentImage) image_data->subtract(calibrateImage->getImageData()->getImageBuffer()); } if (seqTotalCount < 0) { jobs.removeOne(activeJob); delete (activeJob); activeJob = NULL; stopSequence(); return; } seqCurrentCount++; imgProgress->setValue(seqCurrentCount); appendLogText(i18n("Received image %1 out of %2.", seqCurrentCount, seqTotalCount)); currentImgCountOUT->setText( QString::number(seqCurrentCount)); // if we're done if (seqCurrentCount == seqTotalCount) { stopSequence(); activeJob->status = SequenceJob::JOB_DONE; activeJob->statusCell->setText(SequenceJob::statusStrings[activeJob->status]); jobCount--; if (jobCount > 0) { jobIndex++; SequenceJob *job = jobs.at(jobIndex); executeJob(job); } } else seqTimer->start(seqDelay); }