1

I'm trying to get the cutting points which were used for creating histogram equalization (by histeq or in another way), i.e. to get the original pixel values which were used to determine every bin edges.

In order to simplify the following example, I will use 1D matrix:

If the original image is: [ 0.2 , 0.25 , 0.34 , 0.4 , 0.4 , 0.4 , 0.6 , 0.6 , 0.6 ]

and the image after histogram equalization (to 3 bins) is: [ 0.2 , 0.2 , 0.2 , 0.4 , 0.4 , 0.4 , 0.6 , 0.6 , 0.6 ]

how do I get the edges of the 3 bins?

i.e. how do I get the following vector (which represent the cutting points): [0.37 0.5] ?

Thanks a lot !!!

P.S. getting the vector [0.34 0.4] or [0.4 0.6] (Respectively, minimum and maximum values to be included in a specific bin after histeq) is also satisfying.

4

2 回答 2

0

(如果我的问题是正确的)我可以想象做如下的事情:

dVec = diff(eqdata);
fVec = find(dVec);
cuttingPoints = eqdata(fVec) + dVec(fVec)/2;

例子:

eqdata =  [ 0.2 , 0.2 , 0.2 , 0.4 , 0.4 , 0.4 , 0.6 , 0.6 , 0.6 ];

输出:

0.3000    0.5000

编辑:如果是未排序的数据:

dVec = diff(sort(unique(eqdata)));
fVec = find(dVec);
cuttingPoints = eqdata(fVec) + dVec(fVec)/2;
于 2013-08-15T11:44:52.467 回答
0

这是一个适用于向量和矩阵(已排序或未排序)的解决方案。它使用uniquemedian函数。

您将median在 bin 值之间获得中间值(此处使用 )。您还将拥有分配给每个图像元素的 bin 索引。

以下代码

%data
A = [ 0.2 , 0.25 , 0.34 , 0.4 , 0.4 , 0.4 , 0.6 , 0.6 , 0.6 ]; % vector
%A = rand(5,5); % matrix (other possible input)
bin_number = 3;    

%histogram
J = histeq(A,bin_number); %histogram equalization
[Ju, ia, ic] = unique(J(:)); %uniquing

%values of in-between bins (here using median)
cutting_index = median([Ju(1:end-1) Ju(2:end)]');

%get the assignment
assign_index = reshape(ic,size(A));

会产生

cutting_index = [0.2500    0.7500]
assign_index = [1     1     1     2     2     2     3     3     3]'
于 2013-08-15T12:19:41.557 回答