本文整理汇总了C++中vpImage::performLut方法的典型用法代码示例。如果您正苦于以下问题:C++ vpImage::performLut方法的具体用法?C++ vpImage::performLut怎么用?C++ vpImage::performLut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vpImage
的用法示例。
在下文中一共展示了vpImage::performLut方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adjust
/*!
\ingroup group_imgproc_brightness
Adjust the brightness of a grayscale image such as the new intensity is alpha x old_intensity + beta.
\param I : The grayscale image to adjust the brightness.
\param alpha : Multiplication coefficient.
\param beta : Constant value added to the old intensity.
*/
void vp::adjust(vpImage<unsigned char> &I, const double alpha, const double beta) {
//Construct the look-up table
unsigned char lut[256];
for(unsigned int i = 0; i < 256; i++) {
lut[i] = vpMath::saturate<unsigned char>(alpha * i + beta);
}
//Apply the transformation using a LUT
I.performLut(lut);
}
示例2: equalizeHistogram
/*!
\ingroup group_imgproc_histogram
Adjust the contrast of a grayscale image by performing an histogram equalization.
The intensity distribution is redistributed over the full [0 - 255] range such as the cumulative histogram
distribution becomes linear.
\param I : The grayscale image to apply histogram equalization.
*/
void vp::equalizeHistogram(vpImage<unsigned char> &I) {
if(I.getWidth()*I.getHeight() == 0) {
return;
}
//Calculate the histogram
vpHistogram hist;
hist.calculate(I);
//Calculate the cumulative distribution function
unsigned int cdf[256];
unsigned int cdfMin = /*std::numeric_limits<unsigned int>::max()*/ UINT_MAX, cdfMax = 0;
unsigned int minValue = /*std::numeric_limits<unsigned int>::max()*/ UINT_MAX, maxValue = 0;
cdf[0] = hist[0];
if(cdf[0] < cdfMin && cdf[0] > 0) {
cdfMin = cdf[0];
minValue = 0;
}
for(unsigned int i = 1; i < 256; i++) {
cdf[i] = cdf[i-1] + hist[i];
if(cdf[i] < cdfMin && cdf[i] > 0) {
cdfMin = cdf[i];
minValue = i;
}
if(cdf[i] > cdfMax) {
cdfMax = cdf[i];
maxValue = i;
}
}
unsigned int nbPixels = I.getWidth()*I.getHeight();
if(nbPixels == cdfMin) {
//Only one brightness value in the image
return;
}
//Construct the look-up table
unsigned char lut[256];
for(unsigned int x = minValue; x <= maxValue; x++) {
lut[x] = vpMath::round( (cdf[x]-cdfMin) / (double) (nbPixels-cdfMin) * 255.0 );
}
I.performLut(lut);
}
示例3: gammaCorrection
/*!
\ingroup group_imgproc_gamma
Perform a gamma correction on a grayscale image.
\param I : The grayscale image to apply gamma correction.
\param gamma : Gamma value.
*/
void vp::gammaCorrection(vpImage<unsigned char> &I, const double gamma) {
double inverse_gamma = 1.0;
if(gamma > 0) {
inverse_gamma = 1.0 / gamma;
} else {
throw vpException(vpException::badValue, "The gamma value must be positive !");
}
//Construct the look-up table
unsigned char lut[256];
for(unsigned int i = 0; i < 256; i++) {
lut[i] = vpMath::saturate<unsigned char>( pow( (double) i / 255.0, inverse_gamma ) * 255.0 );
}
I.performLut(lut);
}
示例4: stretchContrast
/*!
\ingroup group_imgproc_contrast
Stretch the contrast of a grayscale image.
\param I : The grayscale image to stretch the contrast.
*/
void vp::stretchContrast(vpImage<unsigned char> &I) {
//Find min and max intensity values
unsigned char min = 255, max = 0;
I.getMinMaxValue(min, max);
unsigned char range = max - min;
//Construct the look-up table
unsigned char lut[256];
if(range > 0) {
for(unsigned int x = min; x <= max; x++) {
lut[x] = 255 * (x - min) / range;
}
} else {
lut[min] = min;
}
I.performLut(lut);
}