How To Ideas | How To Articles | How To Tutorials


0

General Information On Image manipulations For Designers And Developers


In this article, I will be sharing all the information much needed specially for a Programmer/Developer to manipulate the Image colours. This article needs you to have some knowledge of Matrices from Mathematics. In short,what I will be writing in this article is if we have to manipulate colour of the whole image or transparency, then how theoretically we have to think it first before doing the same in coding to get the changes required on an image.

First of all, I want to talk about Images. Now if we consider it a simple image, then it is just a collection of coloured pixels defined in the manner which constituently creates a whole environment of any place, shape of any object, or any shape inside an environment. We too know that every colour is made of RGB values (R-Red, B-Blue, G-Green). So, every pixel of an image have some value of all the three which gives that pixel a unique colour. But for this article we too want to know how can we alter the opacity of an image, so here we will be talking about 4th parameter which is Alpha. For a normal image, alpha is always 1. So, here we have four parameters Red, Green, Blue, Alpha. But in C#, we have actually 5 parameters and the 5th parameter is always 1 which is used to alter all the other four parameter values.

Say if we want to add some colour value to Red parameter of every pixel, we can achieve this by just altering the value of Red parameter, but if we need to alter all the four parameter by same value, then we can achieve that using the 5th parameter.

Now if we just consider the 5 parameter of any image as a matrix of 1*5 order, then we have following kind of situation for a very flat image, which just have single value of Red, Blue, Green component for every pixel.
RGB and Alpha Values Of An Image

As clearly shown in figure, we don’t have any value for Blue colour, but some value for Red and Green part, so image created using these parameters will be having only Red and Gree colour. Now blue colour will be there, and here is the sample image created using these values.
Colour For RGB Values Given In Above Image

Now if we want to just add some value(say 0.1) to Red part of the image, just think of a 5*5 matrix with which we can multiply the upper matrix to get 1*5 matrix as result which will be having the desired values of all the 5 parameters. I have done it for you see the following image.
Colour manipulation By Multiplying Matrices Of Colour

So, the above multiplication of matrices will give us the required value that is, value of Red will be 0.7 without changing value of any other colour. And here is the resultant colour.
Colour For RGB Values Given In Above Image

Filed in: C#, Computer and Programming Tags: , , , ,

Leave a Reply

Submit Comment



© 4398 How To Ideas. All rights reserved.
Proudly designed by Theme Junkie.