False coloring

  • Follow


Hi!

I'm using OpenGL to render a big image (~3k x 4k px). I have to implement 
two functionalities: changing brightness and contrast, and false-coloring 
(replacing bitmap's pallette with another).

Changing brightness and contrast means simply shifting and multiplying color 
values, so I decided to use fragment shaders, which provide a fast way to 
achieve such an effect on-the-fly, without changing the texture itself. 
However, the false-coloring is a little bit more complicated, because the 
new pallette has to be applied to effects of brightness and contrast changes 
(after applying false-coloring: the replaced pallette remains unchanged).

Reloading the texture is not an option, because it would have had to be very 
fast (at least 15 operations per second) and the texture can be up to 36 Mb 
large (or maybe even more). The replacement pallettes can usually be 
generated on-the-fly, but there is a number of them and I'm not sure if 
implementing all of them as a big switch statement doesn't affect the 
performance of rendering process (apart from question, if such a large 
shader would even be compiled and linked properly).

How to solve this problem?

Best regards -- Spook. 


0
Reply Wojciech 6/29/2009 11:33:59 AM

"Wojciech "Spook" Sura" <wojciech.sura-no@spam-poczta.medi.com.pl> wrote in 
message news:h2a94k$a7t$1@inews.gazeta.pl...
> Hi!
>
> I'm using OpenGL to render a big image (~3k x 4k px). I have to implement 
> two functionalities: changing brightness and contrast, and false-coloring 
> (replacing bitmap's pallette with another).
>
> Changing brightness and contrast means simply shifting and multiplying 
> color values, so I decided to use fragment shaders, which provide a fast 
> way to achieve such an effect on-the-fly, without changing the texture 
> itself. However, the false-coloring is a little bit more complicated, 
> because the new pallette has to be applied to effects of brightness and 
> contrast changes (after applying false-coloring: the replaced pallette 
> remains unchanged).
>
> Reloading the texture is not an option, because it would have had to be 
> very fast (at least 15 operations per second) and the texture can be up to 
> 36 Mb large (or maybe even more). The replacement pallettes can usually be 
> generated on-the-fly, but there is a number of them and I'm not sure if 
> implementing all of them as a big switch statement doesn't affect the 
> performance of rendering process (apart from question, if such a large 
> shader would even be compiled and linked properly).
>
> How to solve this problem?
>
> Best regards -- Spook.
>

Do a dependent-texture lookup. Use a 2nd texture as the palette, which can 
be loaded on-demand since it's just a color table (small). Then do 
brightness/contrast as before on the paletted result.

In fact, if it's paletted color to begin with, using a dependent-texture 
lookup will yield better color interpolation when you zoom in (it will 
interpolate along the color palette, not in RGB space which results in 
non-palette colors)

jbw


0
Reply jbwest 6/29/2009 2:41:07 PM


jbwest wrote:
> Do a dependent-texture lookup. Use a 2nd texture as the palette,
> which can be loaded on-demand since it's just a color table (small).
> Then do brightness/contrast as before on the paletted result.

I expressed myself wrong a little: brightness/contrast should be done before 
applying pallette, not after :)

However, that doesn't change the solution. Thanks for your help!

> jbw

Best regards -- Spook. 


0
Reply Wojciech 6/30/2009 5:31:56 AM

"Wojciech "Spook" Sura" <wojciech.sura-no@spam-poczta.medi.com.pl> wrote in 
message news:h2c89l$hec$1@inews.gazeta.pl...
> jbwest wrote:
>> Do a dependent-texture lookup. Use a 2nd texture as the palette,
>> which can be loaded on-demand since it's just a color table (small).
>> Then do brightness/contrast as before on the paletted result.
>
> I expressed myself wrong a little: brightness/contrast should be done 
> before applying pallette, not after :)
>
> However, that doesn't change the solution. Thanks for your help!
>
>> jbw
>
> Best regards -- Spook.
>

That's not going to be possible, nor make any sense. You need to pass in the 
texture as index into color
palette. It's the color palette that needs to have contrast/brightness 
adjust -- the main texture never changes,
only the palette.

jbw


0
Reply jbwest 6/30/2009 1:31:35 PM

U�ytkownik "jbwest" <jbwest@acm.org> napisa� w wiadomo�ci 
news:4a4a13bb$0$29137$6e1ede2f@read.cnntp.org...
> That's not going to be possible, nor make any sense. You need to pass in 
> the texture as index into color palette.

Indeed. But what I didn't written is, that displayed photo is in grayscale, 
so the texture color in fact already is color index (in a way) :)

> It's the color palette that needs to have contrast/brightness adjust --  
> the main texture never changes,
> only the palette.

Well, not really. The images I display are viewed by doctors and false 
coloring is used to enchance details. Changing brightness and contrast gives 
doctor ability to "select" only part of spectrum and then scale it to fit 
full false-color pallette, so every small change in intensity is clearly 
visible.

> jbw

Best regards -- Spook.

-- 
! ._______. Warning: Lucida Console sig!    //)    !
! || spk ||    www.spook.freshsite.pl      / _ """*!
! ||_____||        spook at op.pl         / '  | ""!
! |  ___  |   tlen: spoko_ws gg:1290136  /. __/"\ '!
! |_|[]_|_|  May the SOURCE be with you! \/)     \ ! 

0
Reply Wojciech 6/30/2009 2:58:11 PM

"Wojciech "Spook" Sura" <spook.no@spamming.please.op.pl> wrote in message 
news:h2d95k$7re$1@inews.gazeta.pl...
> U�ytkownik "jbwest" <jbwest@acm.org> napisa� w wiadomo�ci 
> news:4a4a13bb$0$29137$6e1ede2f@read.cnntp.org...
>> That's not going to be possible, nor make any sense. You need to pass in 
>> the texture as index into color palette.
>
> Indeed. But what I didn't written is, that displayed photo is in 
> grayscale, so the texture color in fact already is color index (in a way) 
> :)
>
>> It's the color palette that needs to have contrast/brightness adjust --  
>> the main texture never changes,
>> only the palette.
>
> Well, not really. The images I display are viewed by doctors and false 
> coloring is used to enchance details. Changing brightness and contrast 
> gives doctor ability to "select" only part of spectrum and then scale it 
> to fit full false-color pallette, so every small change in intensity is 
> clearly visible.
>
>> jbw
>
> Best regards -- Spook.
>
> -- 
> ! ._______. Warning: Lucida Console sig!    //)    !
> ! || spk ||    www.spook.freshsite.pl      / _ """*!
> ! ||_____||        spook at op.pl         / '  | ""!
> ! |  ___  |   tlen: spoko_ws gg:1290136  /. __/"\ '!
> ! |_|[]_|_|  May the SOURCE be with you! \/)     \ !


What I'm trying to say is that image manipulations -- even grey scale in -> 
adjusted gray scale out, can all be accomplished with a paletted method and 
thus not require reloading the image. Load your raw image (16 bits if you 
have it) and then do all the color/brightness/contrast operations with 
palette manipulation. A 65k palette is perfectly do-able & instantly fast to 
adjust.

If you think about it, recomputing a new image for different 
contrast/brightness on the cpu & then loading the image,  versus doing it in 
a shader, are exactly the same thing (except the shader is much faster).

jbw 


0
Reply jbwest 6/30/2009 4:42:23 PM

5 Replies
88 Views

(page loaded in 0.124 seconds)

3/22/2013 8:16:57 PM


Reply: