Write about histogram specification.

1 day ago

Histogram Matching (Specification):

Histogram equalization automatically determines a transformation function that seeks to produce an output image that has a uniform histogram.When automatic enhancement is desired, this is a good approach because the results from this technique are predictable and the method   is simple to implement. In particular, it is useful sometimes to be able to specify the shape of the histogram that we wish the processed image to have.The method used to generate a processed image that has a specified histogram is called histogram matching or histogram specification.

Development of the method:

Let us return for a moment to continuous gray levels r and z (considered continuous random variables), and let pr(r) and pz(z) denote their corresponding continuos probability density functions. In this notation, r and z denote the gray levels of the input and output (processed) images, respectively.We can estimate pr(r) from the given input image, while pz(z) is the specified probability density function that we wish the output image to have.

Let s be a random variable with the property

where w is a dummy variable of integration.We recognize this expression as the   continuos version of histogram equalization. Suppose next that we define a random variable z with the property

where t is a dummy variable of integration. It then follows from these two equations that G(z)=T(r) and, therefore, that z must satisfy the condition

The transformation T(r) can be obtained once pr(r) has been estimated from the input image. Similarly, the transformation function   G(z) can   be obtained because pz(z) is given. Assuming that G-1 exists and that it satisfies conditions (a) and (b) in the histogram equalization process, the above three equations show that an image with a specified probability density function can be obtained from an input image by using the following procedure:

  • Obtain the transformation function T(r).
  • To obtain the transformation function G(z).
  • Obtain the inverse transformation function G-1
  • Obtain the output image by applying above to all the pixels in the input image.

The result of this procedure will be an image whose gray levels, z, have the specified probability density function pz(z). Although the procedure just described is straightforward in principle, it is seldom possible in practice to obtain analytical expressions for T(r) and for G-1. Fortunately, this problem is simplified considerably in the case of discrete values.The price we pay is the same as in histogram equalization,where only an approximation to the desired histogram is achievable. In spite of this, however, some very useful results can be obtained even with crude approximations.

Where n is the total number of pixels in the image, nj is the number of pixels with gray level rj, and L is the number of discrete gray levels. Similarly, the discrete formulation is obtained from the given histogram pz (zi), i=0, 1, 2,……, L-1, and has the form

As in the continuos case, we are seeking values of z that satisfy this equation.The variable vk was added here for clarity in the discussion that follows. Finally, the discrete version of the above Eqn. is given by



We start by noting the following: (1) Each set of gray levels {rj} , {sj}, and {zj}, j=0, 1, 2, p , L- 1, is a one-dimensional array of dimension L X 1. (2) All mappings from r to s and from s to z are simple table lookups between a given pixel value and these arrays. (3) Each of the elements of these arrays, for example, sk, contains two important pieces of information: The subscript k denotes the location of the element in the array, and s denotes the value at that location. (4) We need to be concerned only with integer pixel values. For example, in the case of an 8-bit image, L=256 and the elements of each of the arrays just mentioned are integers between 0 and 255.This implies that we now work with gray level values in the interval [0, L-1] instead of the normalized interval [0, 1] that we used before to simplify the development of histogram processing techniques.

In order to see how histogram matching actually can be implemented, consider Fig. 5(a), ignoring for a moment the connection shown between   this figure and   Fig. 5(c). Figure 5(a) shows a hypothetical discrete transformation function s=T(r) obtained from a given image. The first gray level in the image, r1 , maps to s1 ; the second gray level, r2 , maps to s2 ; the kth level rk maps to sk; and so on (the important point here is the ordered correspondence between these values). Each value sj in the array is precomputed, so the process of mapping simply uses the actual value of a pixel as an index in an array to determine the corresponding value of s.This process is particularly easy because we are dealing with integers. For example, the s mapping for an 8-bit pixel with value 127 would be found in the 128th position in array {sj} (recall that we start at 0) out of the possible 256 positions. If we stopped here and mapped the value of each pixel of an input image by the

Fig.5. (a) Graphical interpretation of mapping from rk to sk via T(r). (b) Mapping of zq to its corresponding value vq via G(z) (c) Inverse mapping from sk to its corresponding value of zk.


method just described, the output would be a histogram-equalized image. In order to implement histogram matching we have to go one step further. Figure 5(b) is a hypothetical transformation function G obtained from a given histogram pz(z). For any zq , this transformation function yields a corresponding value vq. This mapping is shown by the arrows in Fig. 5(b). Conversely, given any value vq, we would find the corresponding value zq from G-1. In terms of the figure, all this means graphically is that we would reverse the direction of the arrows to map vq into its corresponding zq. However, we know from the definition that v=s for corresponding subscripts, so we can use exactly this process to find the zk corresponding to any value sk that we computed previously from the equation sk = T(rk) .This idea is shown in Fig.5(c).

Since we really do not have the z’s (recall that finding these values is precisely the objective of histogram matching),we must resort to some sort of iterative scheme to find z from s.The fact that we are dealing with integers makes this a particularly simple process. Basically, because vk = sk, we have that the z’s for which we are looking must satisfy the equation G(zk)=sk, or (G(zk)- sk)=0. Thus, all we have to do to find the value of zk corresponding to sk is to iterate on values of z such that this equation is satisfied for k=0,1,2,… , L-1. We do not have to find the inverse of

G because we are going to iterate on z. Since we are dealing with integers, the closest we can get to satisfying the equation (G(zk)-sk)=0 is to let zk=    for each value of k, where      is the smallest integer in the interval [0, L-1] such that

Given a value sk, all this means conceptually in terms of Fig. 5(c) is that we would start with and increase it in integer steps until Eq is satisfied, at which point we let repeating this process for all values of k would yield all the required mappings from s to z, which constitutes the implementation of Eq. In practice, we would not have to start with each time because the values

of sk are known to increase monotonically. Thus, for k=k+1, we would start with              and increment in integer values from there.

Raju Singhaniya
Oct 15, 2021
More related questions

Questions Bank

View all Questions