分布在每个亮度级别的像素数目相等 [英] distributing equal number of pixels in each intensity level

查看:132
本文介绍了分布在每个亮度级别的像素数目相等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须做到以下几点 -

I have to do the following -

1)找到属于强度0级到强电平-255像素并将它们存储在256的阵列
2)重新分配从一个亮度级别的像素到另一个的强度级,使所有的256级具有相等的像素。

1) find pixels belonging to intensity-level-0 to intensity-level-255 and store them in 256 arrays 2) redistribute pixels from one intensity level to another intensity level so that all the 256 levels have equal pixels.

这是一个更大的问题,我试图解决的算法和我被困在这里,因为我不知道该怎么处理单元阵列元素。

This is the algorithm of a bigger problem I'm trying to solve and I'm stuck here as I don't know how to manipulate the cell array elements.

我将有256个单元的单元阵列中,我已经来比较和重新分配属于单个细胞的元素。 Matlab的高手请帮忙。

I'll be having 256 cells in the cell array and I've to compare and redistribute elements belonging to individual cell. Matlab experts please help.

推荐答案

该算法是很简单的。创建从2-D图象的矩阵数据的一维数组。该数组的每个元素有四个属性:

The algorithm is simple enough. Create a 1-D array of data from the 2-D image matrix. Each element of the array has four attributes:


  • x位置

  • y位置

  • 在强度值[0,255]

  • 优先级(它默认为零每个像素)

现在,生成从该数据在256个不同的分区中的一个的直方图,其值的基础上,强度值。这应该是很容易的。有一个完整的例子在这里:

Now, generate a histogram from this data, with values in one of the 256 unique bins, based on the intensity value. That should be easy enough. There is a complete example here:

http://www.giassa.net/?page_id=470

现在,只计算元素的平均数目应在每个容器(即:行*列/ 256),并且它舍入到最近的整数。有了这个价值你知道多少像素应该如何在每个直方图的bin。所以,在你的直方图,您可以:

Now, just calculate the average number of elements there should be in each bin (ie: rows * columns / 256), and round it to the nearest integer. With this value you know how many pixels should be in each histogram "bin". So, in your histogram, you:


  • 循环遍历256柱状图箱第255

    • 计算,如果值的bin的数目比一般更高或更低。

    • 如果在当前斌像素过多:

      • 将其优先的价值排序中的每个bin中的像素,以升序排列。(即:从0开始,优先级越高,就越有可能你会移动像素)

      • 以优先级最低的像素,然后移动像素到下一个纸槽(即:增加它的强度值),并增加它的优先级

      • 重复该步骤直至在当前二进制像素的数目等于所述预期值(即:行*列/ 256)

      现在,直方图均衡化,可以循环通过它的内容来重新创建原始2D图像。

      Now that the histogram is equalized, you can loop through it's contents to re-create the original 2D image.

      优先级的价值观是很重要的,所以你不小心在更多的移动垃圾箱像素超过需要,导致无论是高斯甚至冲动/椒盐噪声。
      总的算法应该是为O(n ^ 2),所以应该在性能方面的半体面。

      The "priority" values are important, so you don't accidentally shift a pixel across more bins than needed, resulting in either Gaussian or even impulse/salt-pepper noise. The overall algorithm should be O(n^2), so it should be half-decent in terms of performance.

      最后一件事:如果你使用的排序算法不是一个稳定的排序,它更多或更少的随机化其同等价值的像素分布在垃圾箱移动,这将有利于使得它prevents移动集群具有相等的强度值的相邻像素。

      One last thing: if the sorting algorithm you use is not a stable sort, it more-or-less randomizes which pixels of equal value are moved across bins, which is helpful such that it prevents moving a cluster of adjacent pixels that have equal intensity values.

      这篇关于分布在每个亮度级别的像素数目相等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆