OpencCV:从修改的直方图计算图像

时间:2022-03-06 19:11:01

I have an image

我有一个图像

cv::Mat image

of which I compute the histogram

其中我计算直方图

cv::MatND histogram_original

I then modify the histogram (remove unwanted image parts etc), which results in another histogram

然后我修改直方图(删除不需要的图像部分等),这导致另一个直方图

cv::MatND histogram_modified

Is it possible to compute the modified image from the modified histogram and the original image? I currently use masks and a for loop to modify the image parts, but there must be a more elegant way for sure?

是否可以从修改的直方图和原始图像计算修改后的图像?我目前使用蒙版和for循环来修改图像部分,但必须有一个更优雅的方式吗?

1 个解决方案

#1


0  

You can get histogram from any images which use finite number of colors. Histogram is a distribution of image pixels with given colors. If we exchange colors of any two points of the image that its histogram is not changed.

您可以从任何使用有限数量颜色的图像中获取直方图。直方图是具有给定颜色的图像像素的分布。如果我们交换图像任意两点的颜色,其直方图不会改变。

So we can't uniquely receive image from histogram. Analogously, if we know changing of histogram, we can't predict changing of original image.

所以我们不能从直方图中唯一地接收图像。类似地,如果我们知道直方图的变化,我们就无法预测原始图像的变化。

#1


0  

You can get histogram from any images which use finite number of colors. Histogram is a distribution of image pixels with given colors. If we exchange colors of any two points of the image that its histogram is not changed.

您可以从任何使用有限数量颜色的图像中获取直方图。直方图是具有给定颜色的图像像素的分布。如果我们交换图像任意两点的颜色,其直方图不会改变。

So we can't uniquely receive image from histogram. Analogously, if we know changing of histogram, we can't predict changing of original image.

所以我们不能从直方图中唯一地接收图像。类似地,如果我们知道直方图的变化,我们就无法预测原始图像的变化。