2024-09-30 04:27:34 发布
网友
我是一个深入学习和张量流新手。在
我正在尝试修改cifar10tensorflow教程,以便将其用于面部输入图像。在
如何计算直方图均衡化?在
是否可以包装类似于:Histogram equalization of grayscale images with NumPy中的解决方案?在
对于灰度uint8图像,您可以使用如下方法:
uint8
def tf_equalize_histogram(image): values_range = tf.constant([0., 255.], dtype = tf.float32) histogram = tf.histogram_fixed_width(tf.to_float(image), values_range, 256) cdf = tf.cumsum(histogram) cdf_min = cdf[tf.reduce_min(tf.where(tf.greater(cdf, 0)))] img_shape = tf.shape(image) pix_cnt = img_shape[-3] * img_shape[-2] px_map = tf.round(tf.to_float(cdf - cdf_min) * 255. / tf.to_float(pix_cnt - 1)) px_map = tf.cast(px_map, tf.uint8) eq_hist = tf.expand_dims(tf.gather_nd(px_map, tf.cast(image, tf.int32)), 2) return eq_hist
试验用:
对于灰度
uint8
图像,您可以使用如下方法:试验用:
^{pr2}$相关问题 更多 >
编程相关推荐