It is currently Mon Sep 21, 2026 12:33 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: mathematical coversion of color to grayscale & back?
PostPosted: Fri Apr 28, 2017 8:42 pm  (#1) 
Offline
New Member

Joined: Sep 22, 2016
Posts: 2
GIMP Version: 2.8.14
Operating System: Windows
OS Version: windows 10
GIMP Experience: New User



This is only for now for use with the standard calculator in windows 10 or other OS that has a calculator program. I figured how to mathematically convert a color to grayscale,but how to mathematically convert a grayscale value to the separate RGB channel values? I'm not asking for a script for the standard calculator program.
I wrote the following in W 10's Notepad:
mathematical conversion of color to grayscale followed by mathematical conversion of grayscale to color

0.2126 x red value,i.e. 0-255 =
0.7152 x green value,i.e. 0-255 =
0.0722 x blue value,i.e. 0-255 =
example 0.2126 x 255 = 54.213 for red
0.7152 x 93 = 66.5136 for green
0.0722 x 97 = 7.0034 for blue
54+66+7 = 127 for grayscale value

converting grayscale value to separate RGB values
example 127 ? = R:255,G:93, B:97 for example for red with ? as unknown math formula
other examples for green,blue,cyan,magenta or yellow

grayscale value of 127 or 128
i.e. 127 or 128 ? = R:5,G:178,B:0 for green
127 or 128 ? = R:118,G:118,B:255 for blue
127 or 128 ? = R:0,G:163,B:159 for cyan
127 or 128 ? = R;251,G:78,B:255 for magenta
127 or 128 ? = R:142,G:127,B:0 for yellow

can anyone figure out what the unknown math formula as indicated by ?
is to convert grayscale value to separate RGB values?


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: mathematical coversion of color to grayscale & back?
PostPosted: Sat Apr 29, 2017 1:39 am  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4812
There are plenty of ways tp convert color to grayscale, Color>Desaturate has 3 different formulas, all equally valid, just different purposes.

There are thousands of ways to convert grayscale to arbitrary colors. Since there are only 256 possibly values of gray, the simplest way is to make a table of the 256 RGB values

Now, this is Gimp, so if what you want to do is convert a grayscale image to a color image, the best way to do it is to define a gradient and use Color>Map>Gradient map. You can use the gradient editor but the gradient is just a text file and you can make up one by hand with a text editor. If have linear segment in your map, you don't need to define every point, just define the two ends and Gimp will interpolate.

_________________
Image


Top
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group