예제 #1
0
//-----------------------------------------------------------------------------
// Description:
//   This example shows how to scale the value channel of an image.  This is
//   a potential way to implement an auto-contrast/auto-levels operation
//-----------------------------------------------------------------------------
void LevelScalingWithClipping()
{
  CHistLib Histogram;

  // Open the image
  Mat ImageLowContrast = imread("images/fiveShadesLowContrast.png");

  assert(!ImageLowContrast.empty());

  Mat ImageLowContrastClipped;

  // Perform the normalized clipping procedure
  double clipPercent = 50;
  Histogram.NormalizeClipImageBGR(ImageLowContrast, ImageLowContrastClipped, clipPercent);

  Mat HistImageLowContrastClipped;
  Histogram.ComputeAndDrawHistogramValue(ImageLowContrastClipped, HistImageLowContrastClipped);

  // Save the modified image
  string ImageLowContrastClippedName("fiveShadesLowContrastClipped.value.png");

  if (imwrite(ImageLowContrastClippedName, ImageLowContrastClipped))
  {
    cout << "Created clipped image: " << ImageLowContrastClippedName << endl;
  }

  // Save the histogram image
  string HistImageLowContrastClippedName("fiveShadesLowContrastClipped.value.hist.png");

  if (imwrite(HistImageLowContrastClippedName, HistImageLowContrastClipped))
  {
    cout << "Created value histogram: " << HistImageLowContrastClippedName << endl;
  }
}
예제 #2
0
//-----------------------------------------------------------------------------
// Description:
//   This example shows how to scale the value channel of an image.  This is
//   a potential way to implement an auto-contrast/auto-levels operation
//-----------------------------------------------------------------------------
void LevelScalingLowContrast()
{
  CHistLib Histogram;

  // Open the image
  Mat ImageLowContrast = imread("images/fiveShadesLowContrast.png");

  assert(!ImageLowContrast.empty());

  Mat ImageOriginalNorm;
  Mat ImageLowContrastNorm;

  // Generate color histogram for the current image
  Mat HistImageGray;

  Histogram.NormalizeImageBGR(ImageLowContrast, ImageLowContrastNorm);

  Mat HistImageLowContrast;
  Mat HistImageLowContrastNorm;

  Histogram.ComputeAndDrawHistogramValue(ImageLowContrast, HistImageLowContrast);
  Histogram.ComputeAndDrawHistogramValue(ImageLowContrastNorm, HistImageLowContrastNorm);

  // Save the histogram images
  string HistImageLowContrastName("fiveShadesLowContrast.value.hist.png");
  string HistImageLowContrastNormName("fiveShadesLowContrastNorm.value.hist.png");
  string ImageLowContrastNormName("fiveShadesLowContrastNorm.png");

  if (imwrite(HistImageLowContrastName, HistImageLowContrast))
  {
    cout << "Created value histogram: " << HistImageLowContrastName << endl;
  }

  if (imwrite(HistImageLowContrastNormName, HistImageLowContrastNorm))
  {
    cout << "Created value histogram: " << HistImageLowContrastNormName << endl;
  }

  if (imwrite(ImageLowContrastNormName, ImageLowContrastNorm))
  {
    cout << "Created normalized image: " << ImageLowContrastNormName << endl;
  }
}
예제 #3
0
//-----------------------------------------------------------------------------
// Description:
//   This example shows how to scale the value channel of an image.  This is
//   a potential way to implement an auto-contrast/auto-levels operation
//-----------------------------------------------------------------------------
void LevelScalingNoEffect()
{
  CHistLib Histogram;

  // Open the image
  Mat ImageOriginal = imread("images/fiveShades.png");

  assert(!ImageOriginal.empty());

  Mat ImageOriginalNorm;

  // Generate color histogram for the current image
  Mat HistImageGray;

  // Used to verify that this operation does not modify the original image
  Histogram.NormalizeImageBGR(ImageOriginal, ImageOriginalNorm);

  Mat HistImageOriginal;
  Mat HistImageOriginalNorm;

  Histogram.ComputeAndDrawHistogramValue(ImageOriginal, HistImageOriginal);
  Histogram.ComputeAndDrawHistogramValue(ImageOriginalNorm, HistImageOriginalNorm);

  // Save the histogram images
  string HistImageOriginalName("fiveShades.value.hist.png");
  string HistImageOriginalNormName("fiveShadesNorm.value.hist.png");

  if (imwrite(HistImageOriginalName, HistImageOriginal))
  {
    cout << "Created value histogram: " << HistImageOriginalName << endl;
  }

  if (imwrite(HistImageOriginalNormName, HistImageOriginalNorm))
  {
    cout << "Created value histogram: " << HistImageOriginalNormName << endl;
  }
}
예제 #4
0
//-----------------------------------------------------------------------------
// Description:
//   This example draws a value histogram from a test image.
//-----------------------------------------------------------------------------
void DrawSimpleValueHistogram()
{
  CHistLib Histogram;

  // Open the image
  Mat ImageBGR = imread("images/bars.png");
  assert(!ImageBGR.empty());

  // Generate color histogram for the current image
  Mat HistImageGray;
  Histogram.ComputeAndDrawHistogramValue(ImageBGR, HistImageGray);

  // Save the histogram image
  string ImageName("bars.value.hist.png");

  if (imwrite(ImageName, HistImageGray))
  {
    cout << "Created value histogram: " << ImageName << endl;
  }
}