颜色直方图标准化

时间:2013-06-25 01:56:57

标签: opencv image-processing histogram

我昨天在这个问题上找到了这个问题: Histogram Normalization

但是,我尝试使用链接中的一些想法对图像执行标准化,并得到以下结果。在这里,我将所有像素标准化为50%,除了黑色和白色像素。 我使用的公式是:(pixel - min) / (max - min) * 127

pixel = (float)src.at<uchar>(j,i);


if (pixel == 255)
{
    img.at<uchar>(j,i) = pixel;
}

if (pixel == 0)
{
    img.at<uchar>(j,i) = pixel;
}

/*if (min == 0 || max == 0 || (max - min == 0))
{
    img.at<uchar>(j,i) = pixel;
}
else
{*/
    normal__ = ((pixel - min)/(max - min)) * ( 127);
    img.at<uchar>(j,i) = normal__;
//}

}

结果:

RED PIXEL: MIN = 0 MAX = 253
GREEN PIXEL: MIN = 0 MAX = 254
BLUE PIXEL: MIN = 0 MAX = 255

标准化之前的图像 enter image description here

使用上述公式进行标准化后: enter image description here

现在,我确认我的步骤是否正确。谢谢.. :))

1 个答案:

答案 0 :(得分:0)

自陈述以来

  normal__ = ((pixel - min)/(max - min)) * ( 127);
   img.at<uchar>(j,i) = normal__;

不在if-else语句中,它们也适用于黑白像素。那没关系吗?