There are three basic gray level transformation.

  • Linear
  • Logarithmic
  • Power – law

The overall graph of these transitions has been shown below. enter image description here

I am assuming a Linear Gray Level Transform is somehow related to the Identity line from the graph.

Identity transition is shown by a straight line. In this transition, each value of the input image is directly mapped to each other value of output image. That results in the same input image and output image. And hence is called identity transformation.

From this statement I understand that in order to convert a colored image to a gray scale one (which I think Linear Gray Level Transform should do - converting to gray scale) I have to take each value of the input image and make a function that does a kind of conversion for each value.

I surfed the internet, but didn't managed to find a Linear Gray Level Transform example.

My question is if this is the right way (some kind of a small algorithm, if these are the steps) for a Linear Gray Level Transformation or if there is an example of images or an explanation of how does this Linear Gray Level Transform works.


closed as unclear what you're asking by Marcus Müller, lennon310, Peter K. Dec 11 '17 at 14:23

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Hi! Welcome to signals.SE. Sadly, I don't understand what your question is. You have two sentences which end in ?, but aren't actually questions. $\endgroup$ – Marcus Müller Dec 9 '17 at 16:23
  • 1
    $\begingroup$ @MarcusMüller Sorry, I'm a little bit confused. I'll edit my question. $\endgroup$ – grrigore Dec 9 '17 at 16:27

The graph you've shown above describes a pixel-wise operator, basically a function which maps input pixel values $r$ to a new value $s$ in the output image. i.e. each of the functions in the figure you provided describes a transformation $s = T(r)$.

These transformations are typically used to improve image contrast through histogram equalization, basically spreading out the pixel values to make it easier for us to distinguish objects in the image.

To implement something like this, you have to iterate through every pixel, get its grey level $r$, and replace this value with the output $s$ of the function $T(r)$.

For converting color to greyscale, it's the same idea, although this time your function $s = T(r, g, b)$ has three inputs (r = red, g = green, b = blue), since each pixel in a color image will return these three values. Implementation is the same, just iterate through every pixel and replace these three values with just one value $s$ based on the function.

While the identity transform above (given by $s = T(r) = r$) is linear, linear transformations do not necessarily mean identity.

An example of a linear rgb color to greyscale transformation (the one used by MATLAB) is $s = T(r, g, b) = 0.2989 * r + 0.5870 * g + 0.1140 * b$. However, as long as you keep the function in this form (and just change the coefficients to constant values), your transformation will remain linear; this does not guarantee that the transformation will produce good results, though.

EDIT: What I described is only a subset of linear transformations. A linear transformation is any function $T(r)$ where $T(A * r1 + B * r2) = A * T(r1) + B * T(r2)$

  • $\begingroup$ So Linear Gray Level Transformation involves transforming each pixel by modifying the RBG values using a formula like the one you gave s = T(r,g,b)? $\endgroup$ – grrigore Dec 9 '17 at 23:36
  • $\begingroup$ Yup, just to reiterate T(r,g,b) is linear only if it takes that form. $\endgroup$ – goldrik Dec 9 '17 at 23:39
  • $\begingroup$ Yes, I was talking about that. Thanks. What do you think about this article cse.unr.edu/~looney/cs674/unit2/unit2.pdf subchapter - Linear Transformations of Image Grayscales? $\endgroup$ – grrigore Dec 9 '17 at 23:40
  • $\begingroup$ This chapter goes into it in a lot more detail, but the general idea is exactly the same. However, their definition of a linear transformation is more general than mine (what I described is still linear, but all linear T(r) do necessarily take the form I described). I will edit my answer accordingly. $\endgroup$ – goldrik Dec 9 '17 at 23:57
  • $\begingroup$ What do you mean with the last edit? $\endgroup$ – grrigore Dec 10 '17 at 0:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.