void ossimGui::HistogramRemapperEditor::openHistogramButton(bool)
{
    if(!m_histogramRemapper.valid()) return;
    QFileDialog* fd = new QFileDialog( this );
    ossimFilename tempFile = m_histogramRemapper->getHistogramFile();
    if(!tempFile.empty())
    {
        fd->setDirectory(tempFile.path().c_str());
    }

    QString file;
    if (fd->exec() == QDialog::Accepted )
    {
        QStringList files = fd->selectedFiles();
        if(!files.empty())
        {
            ossimFilename f = (*(files.begin())).toStdString();
            setHistogram(f);

        }
    }

    delete fd;
    fd = NULL;

}
void oms::SingleImageChain::setHistogramAndMode(ossimMultiResLevelHistogram* histogram, const std::string& mode)
{
   if(theHistogramRemapper)
   {
      setHistogram(histogram);
      setHistogramStretchMode(mode);
      ossimRefreshEvent evt(theHistogramRemapper);
      theHistogramRemapper->propagateEventToOutputs(evt);
   }
}
// Constructor
Image::Image(Mat image_src) :
image_mat_(image_src)
{
	// Initiate RGB and HSV for this image
	setRGB(image_src);
	setHSV(image_src);

	// Set the histogram of this Image
	setHistogram(image_src);
}
HistogramWidget::HistogramWidget(QWidget *parent)
    : QWidget(parent)
    , m_levels(128)
    , m_isBusy(false)
{
    m_processor.moveToThread(&m_processorThread);
    qRegisterMetaType<QVector<qreal> >("QVector<qreal>");
    connect(&m_processor, SIGNAL(histogramReady(QVector<qreal>)), SLOT(setHistogram(QVector<qreal>)));
    m_processorThread.start(QThread::LowestPriority);
}
Exemple #5
0
//直方图均很,用输入图像得到输出图像
void HistogramEqualization(double *src, double *dst, int width, int height) {
	int hist[GRAY_LEVEL];
	setHistogram(src, hist, width, height);
	double GrayMappingTable[GRAY_LEVEL];
	InitMappingTable(GrayMappingTable, GRAY_LEVEL, TABLE_DOUBLE);
	EqualizationHist(hist, GrayMappingTable);
	for (int i = 0;i<width;i++)
		for (int j = 0;j<height;j++)
			dst[j*width + i] = GrayMappingTable[(int)src[j*width + i]];

}
Exemple #6
0
bool ossimHistogramRemapper::openHistogram(const ossimFilename& histogram_file)
{
   ossimRefPtr<ossimMultiResLevelHistogram> h = new ossimMultiResLevelHistogram();
   if (h->importHistogram(histogram_file))
   {
      setHistogram(h);
      return true;
   }
	
   // Import failed if here!
   return false;
}
HistogramView::HistogramView(std::map<double,double> &histo, QWidget *parent)
    : QGraphicsView(parent),
      m_histogramItems(NULL),
      m_xRatio(1), m_yRatio(1),
      m_minX(0), m_maxX(0),
      m_minY(0), m_maxY(0)
{
    //setAlignment(Qt::AlignCenter); //default
    setScene(new QGraphicsScene(parent));

    setHistogram(histo);
}
bool ossimImageSourceHistogramFilter::setHistogram(const ossimFilename& filename)
{
   ossimRefPtr<ossimMultiResLevelHistogram> histogram = new ossimMultiResLevelHistogram;

   bool result = histogram->importHistogram(filename);

   if(result)
   {
      theFilename = filename;
      setHistogram(histogram);
   }
   
   return result;
}
Exemple #9
0
/******************************
直方图归一化
******************************/
void HistogramSpecification(double *src, double *dst, int* hist, int width, int height) {
	int src_hist[GRAY_LEVEL];
	setHistogram(src, src_hist, width, height);
	double srcMap[GRAY_LEVEL];
	double histMap[GRAY_LEVEL];
	InitMappingTable(srcMap, GRAY_LEVEL, TABLE_DOUBLE);
	EqualizationHist(src_hist, srcMap);
	EqualizationHist(hist, histMap);
	int histMap_[GRAY_LEVEL];
	InitHistogram(histMap_);
	for (int i = 0;i<GRAY_LEVEL;i++)
		histMap_[(int)histMap[i]] = i;
	double dstMap[GRAY_LEVEL];
	for (int i = 0;i<GRAY_LEVEL;i++) {
		dstMap[i] = histMap_[(int)srcMap[i]];
	}

	fillMaptable(dstMap);
	for (int i = 0;i<width;i++)
		for (int j = 0;j<height;j++)
			dst[j*width + i] = dstMap[(int)src[j*width + i]];
}
Exemple #10
0
/** Execute the algorithm.
 */
void ResampleX::exec() {
  // generically having access to the input workspace is a good idea
  MatrixWorkspace_sptr inputWS = getProperty("InputWorkspace");
  MatrixWorkspace_sptr outputWS = getProperty("OutputWorkspace");
  bool inPlace = (inputWS == outputWS); // Rebinning in-place
  m_isDistribution = inputWS->isDistribution();
  m_isHistogram = inputWS->isHistogramData();
  const int numSpectra = static_cast<int>(inputWS->getNumberHistograms());

  // the easy parameters
  m_useLogBinning = getProperty("LogBinning");
  m_numBins = getProperty("NumberBins");
  m_preserveEvents = getProperty("PreserveEvents");

  // determine the xmin/xmax for the workspace
  vector<double> xmins = getProperty("XMin");
  vector<double> xmaxs = getProperty("XMax");
  string error = determineXMinMax(inputWS, xmins, xmaxs);
  if (!error.empty())
    throw std::runtime_error(error);

  bool common_limits = true;
  {
    double xmin_common = xmins[0];
    double xmax_common = xmaxs[0];
    for (size_t i = 1; i < xmins.size(); ++i) {
      if (xmins[i] != xmin_common) {
        common_limits = false;
        break;
      }
      if (xmaxs[i] != xmax_common) {
        common_limits = false;
        break;
      }
    }
  }
  if (common_limits) {
    g_log.debug() << "Common limits between all spectra\n";
  } else {
    g_log.debug() << "Does not have common limits between all spectra\n";
  }

  // start doing actual work
  EventWorkspace_const_sptr inputEventWS =
      boost::dynamic_pointer_cast<const EventWorkspace>(inputWS);
  if (inputEventWS != nullptr) {
    if (m_preserveEvents) {
      if (inPlace) {
        g_log.debug() << "Rebinning event workspace in place\n";
      } else {
        g_log.debug() << "Rebinning event workspace out of place\n";
        outputWS = inputWS->clone();
      }
      auto outputEventWS =
          boost::dynamic_pointer_cast<EventWorkspace>(outputWS);

      if (common_limits) {
        // get the delta from the first since they are all the same
        BinEdges xValues(0);
        const double delta = this->determineBinning(xValues.mutableRawData(),
                                                    xmins[0], xmaxs[0]);
        g_log.debug() << "delta = " << delta << "\n";
        outputEventWS->setAllX(xValues);
      } else {
        // initialize progress reporting.
        Progress prog(this, 0.0, 1.0, numSpectra);

        // do the rebinning
        PARALLEL_FOR_IF(Kernel::threadSafe(*inputEventWS, *outputWS))
        for (int wkspIndex = 0; wkspIndex < numSpectra; ++wkspIndex) {
          PARALLEL_START_INTERUPT_REGION
          BinEdges xValues(0);
          const double delta = this->determineBinning(
              xValues.mutableRawData(), xmins[wkspIndex], xmaxs[wkspIndex]);
          g_log.debug() << "delta[wkspindex=" << wkspIndex << "] = " << delta
                        << " xmin=" << xmins[wkspIndex]
                        << " xmax=" << xmaxs[wkspIndex] << "\n";
          outputEventWS->setHistogram(wkspIndex, xValues);
          prog.report(name()); // Report progress
          PARALLEL_END_INTERUPT_REGION
        }
        PARALLEL_CHECK_INTERUPT_REGION
      }
    }    // end if (m_preserveEvents)
    else // event workspace -> matrix workspace
    {
      //--------- Different output, OR you're inplace but not preserving Events
      g_log.information() << "Creating a Workspace2D from the EventWorkspace "
                          << inputEventWS->getName() << ".\n";
      outputWS = create<DataObjects::Workspace2D>(
          *inputWS, numSpectra, HistogramData::BinEdges(m_numBins + 1));

      // Initialize progress reporting.
      Progress prog(this, 0.0, 1.0, numSpectra);

      // Go through all the histograms and set the data
      PARALLEL_FOR_IF(Kernel::threadSafe(*inputEventWS, *outputWS))
      for (int wkspIndex = 0; wkspIndex < numSpectra; ++wkspIndex) {
        PARALLEL_START_INTERUPT_REGION

        // Set the X axis for each output histogram
        MantidVec xValues;
        const double delta =
            this->determineBinning(xValues, xmins[wkspIndex], xmaxs[wkspIndex]);
        g_log.debug() << "delta[wkspindex=" << wkspIndex << "] = " << delta
                      << "\n";
        outputWS->setBinEdges(wkspIndex, xValues);

        // Get a const event list reference. inputEventWS->dataY() doesn't work.
        const EventList &el = inputEventWS->getSpectrum(wkspIndex);
        MantidVec y_data, e_data;
        // The EventList takes care of histogramming.
        el.generateHistogram(xValues, y_data, e_data);

        // Copy the data over.
        outputWS->mutableY(wkspIndex) = std::move(y_data);
        outputWS->mutableE(wkspIndex) = std::move(e_data);

        // Report progress
        prog.report(name());
        PARALLEL_END_INTERUPT_REGION
      }
      PARALLEL_CHECK_INTERUPT_REGION

      // Copy all the axes
      for (int i = 1; i < inputWS->axes(); i++) {
        outputWS->replaceAxis(i, inputWS->getAxis(i)->clone(outputWS.get()));
        outputWS->getAxis(i)->unit() = inputWS->getAxis(i)->unit();
      }

      // Copy the units over too.
      for (int i = 0; i < outputWS->axes(); ++i) {
        outputWS->getAxis(i)->unit() = inputWS->getAxis(i)->unit();
      }
      outputWS->setYUnit(inputEventWS->YUnit());
      outputWS->setYUnitLabel(inputEventWS->YUnitLabel());
    }
    // Assign it to the output workspace property
    setProperty("OutputWorkspace", outputWS);
    return;
  } else // (inputeventWS != NULL)