LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-17-2005, 05:49 PM   #1
qanopus
Senior Member
 
Registered: Jul 2002
Location: New York
Distribution: Slackware
Posts: 1,358

Rep: Reputation: 45
converting a floating point matrix in an grayvalue Image; how?


Hi,

I think the title says it all. I'm programing in c++ and I have and double array of floatingpoint values, like so;
Code:
float Image[IM_SIZE_X][IM_SIZE_Y];
What is the best way of convering this in to an grayvalue Image? Any help will be appreciated
 
Old 04-17-2005, 05:54 PM   #2
ahwkong
Member
 
Registered: Aug 2004
Location: Australia
Distribution: Fedora
Posts: 282

Rep: Reputation: 30
How the float values is used in this case? A single value cannot probably cannot capture a RGB model or a HSV model, right?
 
Old 04-17-2005, 06:00 PM   #3
qanopus
Senior Member
 
Registered: Jul 2002
Location: New York
Distribution: Slackware
Posts: 1,358

Original Poster
Rep: Reputation: 45
Well like I said, it's gray value, so every element represents a certain amount of "grayness". I could transform this matrix so that the highest value is a 1 an lowest is a zero. The values in between can be streched accordingly. The zero could be completly black and one white. And the values in between shades of gray.

Last edited by qanopus; 04-17-2005 at 06:02 PM.
 
Old 04-17-2005, 06:07 PM   #4
ahwkong
Member
 
Registered: Aug 2004
Location: Australia
Distribution: Fedora
Posts: 282

Rep: Reputation: 30
You did not said it is already in gray value. You said you want to convert the array into a gray value image.

So, is it actually a question about an image format ? You want to know what structure to represent a gary value image?
 
Old 04-17-2005, 06:20 PM   #5
qanopus
Senior Member
 
Registered: Jul 2002
Location: New York
Distribution: Slackware
Posts: 1,358

Original Poster
Rep: Reputation: 45
No the thing is I have never done any thing like this, so I bearly know what I'm talking about
Anyway, to put it very simply, I have a matrix with floating point values. I want to generate an image in which the element with the highest value is an white in the corresponding pixel in the image. In the same way, I want the element with the lowest value to be an black in the image.
Knowing how to represent a grayvalue image would be a good place to start. How for example to I make an grayvalue bitmap with such an floatingpoint array?
 
Old 04-17-2005, 06:30 PM   #6
ahwkong
Member
 
Registered: Aug 2004
Location: Australia
Distribution: Fedora
Posts: 282

Rep: Reputation: 30
So, I guess we can break down the issue in two part:
1) how to normalise the float value into gary value in integer
2) how to use this values in a particular image format

The first one is not too hard.
Set a scale of gary value says 0 - 255
then find the lowest and highest float value in the array and then

res = (float value - lowest)/(highest - lowest) * (255)

Then you have to know about the target image format. Since I use Qt, so QImage can be used as an example. (http://doc.trolltech.com/3.3/qimage.html) But afterall you must choose which format you wanna use.

Unfortunately I have to step out now, so let's see how far you got when I'm back.
 
Old 04-17-2005, 06:56 PM   #7
qanopus
Senior Member
 
Registered: Jul 2002
Location: New York
Distribution: Slackware
Posts: 1,358

Original Poster
Rep: Reputation: 45
Thanks dude!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Floating Point in kernel 2.4.28 lucs Slackware 1 10-19-2005 08:33 AM
Floating point exception hemk76 Linux - Software 1 05-06-2005 11:49 PM
floating point multiplication irfanhab Programming 0 12-23-2004 10:13 PM
managing floating point vince_2x Linux - General 2 09-21-2004 09:05 PM
floating point numbers in java spyghost Programming 8 09-06-2003 06:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration