Currently I got a thermal image mapping program which converts grayscale pictures to RGB. Now, what I need to do is to convert those 3 RGB colors into other three colours. The choice of colours are white, black, red, green and blue.
To explain more, for the thermal mapping using grayscale converted to RGB, red denotes hot areas, green-zero, and blue-cold. What I want to do is to make a program that enables you to choose the colours from the five I mentioned above to represent the hot, zero and cold areas. This is the program, using Microsoft visual Studio C++ .
This program reads from the text file map24 and puts it in the RGB variable. -
int readmappingFile()
-
{
-
FILE *fp;
-
int i;
-
-
fp = fopen("C:\\map24.txt", "r");
-
-
if(fp != NULL)
-
{
-
for(i=0; i<256; i++)
-
{
-
fscanf(fp, "%d %d %d", &R[i], &G[i], &B[i]);
-
}
-
}
-
-
return OK;
-
}
This one deals with the RGB conversion. - int temperatureMappingCore()
-
{
-
byte index;
-
int w, h;
-
int gWStep, cWStep;
-
-
gWStep = inImg->widthStep;
-
cWStep = outImg->widthStep;
-
-
for(h=0; h<inImg->height; h++)
-
{
-
for(w=0; w<inImg->width; w++)
-
{
-
index = (byte)inImg->imageData[h*gWStep + w];
-
outImg->imageData[h*cWStep + w*3] = B[index];
-
outImg->imageData[h*cWStep + w*3 + 1] = G[index];
-
outImg->imageData[h*cWStep + w*3 + 2] = R[index];
-
}
-
}
-
-
return OK;
-
}
Can anyone help?
2 10428
If I understood you, given three colors ( c1, c2, c3 ) you want to map grayscale to RGB so that for grayscale pixel with value (g) in range [0..127] resulting rgb value is between (color1) and (color2) for each component, where r1 is red component of color c1:
R = r1+ (r2-r1)*g/128 and the same for G and B components, and for g in range [128..255]: R = r2+(r3-r2)*(g-128)/128. Then you can either generate the mapping file for 256 values of grayscale or convert in on the fly.
Uh, not really. But I've solved that one already so thanks.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Chad |
last post by:
I have a one dimensional byte array that stores the pixel information
of my image. The image is 8-bit grayscale so each byte in the array
holds a value from 0(black) to 255(white) for a single pixel. I need
a way to save this this byte array as a gif. Does anyone have any
suggestions???
|
by: Krista Bailie |
last post by:
I'm sure this is so easy that it will hurt for anyone to read it, but I
really need some direction. I'm trying to create a color chart (RGB) that
shows steps between two different colors as entered by the user. I know the
web script must convert the values into integers, store them as variables
and then output them, but I cannot seem to establish the calculation for
this. I'm attaching the html I've got, that works when the page is...
|
by: QuasiChameleon |
last post by:
Hi,
I'm trying to create a grayscale image class that reads and writes
grayscale Targa format. This works well with smaller images, but
corrupts larger images and creates a "Segmentation fault (core dumped)"
error. I am at a loss as to why this works only part of the time.
I hope it's proper etiquette to post the code below (3 files).
Can someone please show me what's wrong with the following code? I
|
by: RicercatoreSbadato |
last post by:
I'm using bmp.Save() and the bmp is in PixelFormat.Format8bppIndexed.
But when I open the image with Gimp, it tells me that the image is RGB
and not grayscale.
|
by: Henry Wu |
last post by:
Hi I was at the search for making e.Graphics.DrawImage turn any image
to Grayscale, and I found two similar solutions but different
ColorMatrix values, what is the difference between the two? Is there
an industry standard for the GrayScale ColorMatrix values?
Thanks,
Henry
Solution #1, Jacob Grass:
| |
by: Sirin Azazi |
last post by:
i am trying to convert an image into grayscale format. but i have a problem
saving the bmp file after the process.here the code;
for (int y = 0; y < Height; y++)
{
for (int x = 0; x < Width; x++)
{
|
by: platinumhimani |
last post by:
-How to convert any image(8,16,24,32 or 64-bit) to 8-bit grayscale
-i have tried to convert a 24-bit image to grayscale using setpixel
and getpixel functions, in vb.net
but i am unable to save that image in grayscale format.How do i do
that.It still saves in true color format.
-i used picturebox1.image.save() method
-i tried to convert an 8-bit image into grayscale but was unable to
do it.
|
by: IanH1982 |
last post by:
Hi, I am building a quiz in Flash, the quiz will display a question and a set of three possible answers. Im just wondering if its possible once an incorrect answer has been selected (which is a button) the button can be converted to grayScale???
Any help would be much appreciated.
Ian
|
by: srsaravanan |
last post by:
i need coding for converting block and white image into RGB image
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |