[SOLVED] How to convert screen's color image to grayscale

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
compvis
Gremlin
Posts: 165
Joined: Wed Sep 10, 2008 6:14 am

[SOLVED] How to convert screen's color image to grayscale

Post by compvis »

Hi,

In my project, i need to simulate an infrared-nigh camera image for aircraft so i want to convert color image on buffer to grayscale before it is rendered on screen.
Could you pls point me some hints?

Thank you in advance,
Last edited by compvis on Wed Mar 18, 2015 4:39 am, edited 1 time in total.
User avatar
Zonder
Ogre Magi
Posts: 1168
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 73

Re: How to convert screen's color image to grayscale

Post by Zonder »

There are 10 types of people in the world: Those who understand binary, and those who don't...
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: How to convert screen's color image to grayscale

Post by areay »

Yeah, there's an Ogre SampleBrowser Sample that shows compositor that does exactly this.
compvis
Gremlin
Posts: 165
Joined: Wed Sep 10, 2008 6:14 am

Re: How to convert screen's color image to grayscale

Post by compvis »

Thanks, these are great links. I learn it very much.
areay wrote:Yeah, there's an Ogre SampleBrowser Sample that shows compositor that does exactly this.
Thanks,

But is it possible to processing in real time by coding (not by scripts)? For example, image processing on buffer before it is rendered on screen? Which event i should inject my codes and how to handle image from buffer?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5299
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1280
Contact:

Re: How to convert screen's color image to grayscale

Post by dark_sylinc »

compvis wrote:But is it possible to processing in real time by coding (not by scripts)? For example, image processing on buffer before it is rendered on screen? Which event i should inject my codes and how to handle image from buffer?
What the Compositor sample does is to run pixel shaders, which is your own programmable code running on the GPU.
If what you're looking is to use a routine writen by you in C++ (instead of hlsl or glsl), even though it can be done, it will be extremely slow.
compvis
Gremlin
Posts: 165
Joined: Wed Sep 10, 2008 6:14 am

Re: How to convert screen's color image to grayscale

Post by compvis »

dark_sylinc wrote:
compvis wrote:But is it possible to processing in real time by coding (not by scripts)? For example, image processing on buffer before it is rendered on screen? Which event i should inject my codes and how to handle image from buffer?
What the Compositor sample does is to run pixel shaders, which is your own programmable code running on the GPU.
If what you're looking is to use a routine writen by you in C++ (instead of hlsl or glsl), even though it can be done, it will be extremely slow.
I don't want to dive into Hlsl or Glsl because I'm not familiar (not expert) with it and my application is small so i want to convert buffer data to work with opencv image (cv::Mat image) with C++ interface. Could you pls tell me some hints?

Or Could someone help me to create scripts (compositor) ?
Thanks
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: How to convert screen's color image to grayscale

Post by areay »

>> Or Could someone help me to create scripts (compositor) ?

We've told you where to find this, in the source (and material samples) for the SampleBrowser that comes as part of Ogre.

The other, slow, way to do it would be using a RTT and then doing your processing on the RenderTexture that it writes to. There is an example of how to use RTT in the Ogre tutorials. After you've done the tutorial you can change the RenderTexture to be read/write and then process that.
compvis
Gremlin
Posts: 165
Joined: Wed Sep 10, 2008 6:14 am

[SOLVED] How to convert screen's color image to grayscale

Post by compvis »

Dear all,

My problem resolved in Compositors sample.

Than you very much,
Post Reply