# How would a Linear Gray Level Transform affect an image? [closed]

There are three basic gray level transformation.

• Linear
• Logarithmic
• Power – law

The overall graph of these transitions has been shown below.

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.

• 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. – Marcus Müller Dec 9 '17 at 16:23
• @MarcusMüller Sorry, I'm a little bit confused. I'll edit my question. – 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)$

• 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)? – grrigore Dec 9 '17 at 23:36
• Yup, just to reiterate T(r,g,b) is linear only if it takes that form. – goldrik Dec 9 '17 at 23:39