Convolutions in OpenGL

Convolutions in OpenGL

Post by delta_force_m.. » Wed, 03 Nov 1999 04:00:00



I am trying to use the 2D convolution extensions on a 540 Visual PC,
but I can't seem to use negative values in the kernel.  Elsewhere in
this newsgroup, someone had posted an example where they had passed a
kernel that looked like:

-1  -1  -1
-1   9  -1
-1  -1  -1

When I pass in a similar kernel (using floats), the negatives get set
to zero (I am using RGBA values, but I have only shown one channel for
simplicity...):

-1.0f  -1.0f  -1.0f
-1.0f   9.0f  -1.0f
-1.0f  -1.0f  -1.0f

becomes:

0.0f  0.0f  0.0f
0.0f  1.0f  0.0f
0.0f  0.0f  0.0f

I can't seem to find any way around this.  Can anyone tell me how to
set negative values in the kernel?

Thanks,
kel

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Convolutions in OpenGL

Post by Samuel Pai » Wed, 03 Nov 1999 04:00:00



> I am trying to use the 2D convolution extensions on a 540 Visual PC,
> but I can't seem to use negative values in the kernel.

Well, basic answer: you can't.

OpenGL treats the filter kernel as an image.  Images can't
have negative values.  Indeed, image components are eventually
clamped to [0,1].  (If you use a fixed data type like GLint, the
values are conceptually treated as if they were the numerator
of a fraction).

See sections

  3.6.3 Pixel Transfer Modes
  3.6.4 Rasterization of Pixel Rectangles

in the OpenGL specification, version 1.2.1.

Sam
--
Samuel S. Paik | http://www.webnexus.com/users/paik/
3D and multimedia, architecture and implementation
Solyent Green is kitniyos!

 
 
 

Convolutions in OpenGL

Post by delta_force_m.. » Wed, 03 Nov 1999 04:00:00





> > I am trying to use the 2D convolution extensions on a 540 Visual PC,
> > but I can't seem to use negative values in the kernel.

> Well, basic answer: you can't.

> OpenGL treats the filter kernel as an image.  Images can't
> have negative values.  Indeed, image components are eventually
> clamped to [0,1].  (If you use a fixed data type like GLint, the
> values are conceptually treated as if they were the numerator
> of a fraction).

That's what I was beginning to think (references talk about the kernel
as "the image").  But this seems really constrained - there are alot of
kernels that use negative values (edge detection, etc.).  Is there any
way to implement these using the imaging extensions?

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Convolutions in OpenGL

Post by Chris Walke » Wed, 03 Nov 1999 04:00:00




> > I am trying to use the 2D convolution extensions on a 540 Visual PC,
> > but I can't seem to use negative values in the kernel.

> Well, basic answer: you can't.

> OpenGL treats the filter kernel as an image.  Images can't
> have negative values.  Indeed, image components are eventually
> clamped to [0,1].  (If you use a fixed data type like GLint, the
> values are conceptually treated as if they were the numerator
> of a fraction).

> See sections

>   3.6.3 Pixel Transfer Modes
>   3.6.4 Rasterization of Pixel Rectangles

> in the OpenGL specification, version 1.2.1.

You can definitely do signed convolutions on InfiniteReality and RealityEngine
systems (I know because we use this feature in SGI's image processing library).
I haven't investigated the 540/320 so I don't know what's supported there.
It was certainly the intent of the convolution extension to support sharpening
kernels, so if the spec really says you can't then the spec needs to be fixed.
BTW, images can have negative values too, you're right that they are eventually
clamped before they get to the framebuffer, but that doesn't stop interesting
things from being done with signed images in the pipeline.
 
 
 

Convolutions in OpenGL

Post by Jon Lee » Thu, 04 Nov 1999 04:00:00





>> I am trying to use the 2D convolution extensions on a 540 Visual PC,
>> but I can't seem to use negative values in the kernel.

>Well, basic answer: you can't.

>OpenGL treats the filter kernel as an image.  Images can't
>have negative values.       Indeed, image components are eventually
>clamped to [0,1].  (If you use a fixed data type like GLint, the
>values are conceptually treated as if they were the numerator
>of a fraction).

    This isn't quite right. The kernel is treated as an image up to
final expansion to RGBA. Then the CONVOLUTION_FILTER_{SCALE,BIAS}
parameters are applied, and the result is *defined* to be stored as-if
floating point, not integer. It's possible to get negative values - in
fact the OpenGL 1.2 conformance tests *require* that you be able to
represent them - but you have to do some fancy footwork to get there.
    Jon Leech
    SGI
 
 
 

Convolutions in OpenGL

Post by delta_force_m.. » Thu, 04 Nov 1999 04:00:00







> >> I am trying to use the 2D convolution extensions on a 540 Visual
PC,
> >> but I can't seem to use negative values in the kernel.

> >Well, basic answer: you can't.

> >OpenGL treats the filter kernel as an image.  Images can't
> >have negative values.  Indeed, image components are eventually
> >clamped to [0,1].  (If you use a fixed data type like GLint, the
> >values are conceptually treated as if they were the numerator
> >of a fraction).

>     This isn't quite right. The kernel is treated as an image up to
> final expansion to RGBA. Then the CONVOLUTION_FILTER_{SCALE,BIAS}
> parameters are applied, and the result is *defined* to be stored as-if
> floating point, not integer. It's possible to get negative values - in
> fact the OpenGL 1.2 conformance tests *require* that you be able to
> represent them - but you have to do some fancy footwork to get there.
>     Jon Leech
>     SGI

OK, so...  I still don't understand...

Here's what I am doing:

Starting with the convolution example in the extension samples of the
OpenGL SDK, I am going from the example's 7x7 kernel to a 3x3 kernel of
RGBA values.  (so, 3x3x4 floats).  I then set the kernel and retrieve
it again to check to see if everything is the same.  Sadly, its not -
my negatives have changed to zeros...  I have left nearly everything
else from the example intact, so I'm assuming things are enabled, etc.
I'm basically just changing the size and values of the kernel.

Do scale and/or bias affect my situation?  If I'm dealing with RGBA to
begin with, what fancy footwork do I need to do to set my negative
values?

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

1. Convolution in OpenGL

I need some help.  I'm attempting to use the
convolution in OpenGL and am having a wonderful
time.  Doe someone have a sample of a working
invocation of the OpenGl convolution.

Thanks in advance

2. bones and gaol obj.

3. Example of convolution in OpenGL?

4. PRMan SMP and Netrender?

5. PING Puni the Gimp

6. OpenGL Convolution performance on O2 (or lack therof)

7. Dancing Baby Object for LW?

8. OpenGL Convolution & Histograms question

9. convolution limits in OpenGL imaging

10. OpenGL Convolution & Histograms question

11. LIC - Line Integral Convolution