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

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.
0 x

User avatar
Zonder
Ogre Magi
Posts: 1131
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 22

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

Post by Zonder » Thu Mar 12, 2015 10:34 am

0 x
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

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

Post by areay » Fri Mar 13, 2015 1:30 am

Yeah, there's an Ogre SampleBrowser Sample that shows compositor that does exactly this.
0 x

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

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?
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4066
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 228
Contact:

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

Post by dark_sylinc » Fri Mar 13, 2015 4:13 am

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.
0 x

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

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
0 x

User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ

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

Post by areay » Tue Mar 17, 2015 4:29 am

>> 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.
0 x

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 » Wed Mar 18, 2015 4:29 am

Dear all,

My problem resolved in Compositors sample.

Than you very much,
0 x

Post Reply