Page 1 of 1

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

Posted: Thu Mar 12, 2015 9:57 am
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,

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

Posted: Thu Mar 12, 2015 10:34 am
by Zonder

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

Posted: Fri Mar 13, 2015 1:30 am
by areay
Yeah, there's an Ogre SampleBrowser Sample that shows compositor that does exactly this.

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

Posted: Fri Mar 13, 2015 2:56 am
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?

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

Posted: Fri Mar 13, 2015 4:13 am
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.

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

Posted: Fri Mar 13, 2015 4:23 am
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

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

Posted: Tue Mar 17, 2015 4:29 am
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.

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

Posted: Wed Mar 18, 2015 4:29 am
by compvis
Dear all,

My problem resolved in Compositors sample.

Than you very much,