AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi [GR32] What's wrong with my Gamma()?
Thema durchsuchen
Ansicht
Themen-Optionen

[GR32] What's wrong with my Gamma()?

Ein Thema von WojTec · begonnen am 25. Jan 2010 · letzter Beitrag vom 25. Jan 2010
Antwort Antwort
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

[GR32] What's wrong with my Gamma()?

  Alt 25. Jan 2010, 15:22
This is my version of gamma:

Delphi-Quellcode:
procedure Gamma(ASource: TBitmap32; AFactor: Single);
var
  F: Single;
  I: Integer;
  LUT: TLUT8;
  B: TBitmap32;
begin
  AFactor := EnsureRange(AFactor, 0.1, 5);

  B := TBitmap32.Create;
  try
    B.Width := ASource.Width;
    B.Height := ASource.Height;

    for I := 0 to 255 do
    begin
      F := I / 255;
      F := Power(F, AFactor);

      LUT[I] := EnsureRange(Round(F * 255), 0, 255);
    end;

    ApplyLUT(B, ASource, LUT, True);

    ASource.Assign(B);
    ASource.Changed;
  finally
    B.free;
  end;
end;
Generally for values <0.1; 1.0) makes image lighter, for (1.0; 5.0> darker... What I did wrong?
  Mit Zitat antworten Zitat
Benutzerbild von jfheins
jfheins

Registriert seit: 10. Jun 2004
Ort: Garching (TUM)
4.579 Beiträge
 
#2

Re: [GR32] What's wrong with my Gamma()?

  Alt 25. Jan 2010, 15:50
Zitat von WojTec:
Generally for values <0.1; 1.0) makes image lighter, for (1.0; 5.0> darker... What I did wrong?
In my eyes: nothing. What do you expect?

Maybe the function is correct, but your expectations are not
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#3

Re: [GR32] What's wrong with my Gamma()?

  Alt 25. Jan 2010, 16:43
If you increase gamma, output should be lighter, aren't they? Please look on image.
Miniaturansicht angehängter Grafiken
bez_tytu__322_u_120.png  
  Mit Zitat antworten Zitat
Benutzerbild von jfheins
jfheins

Registriert seit: 10. Jun 2004
Ort: Garching (TUM)
4.579 Beiträge
 
#4

Re: [GR32] What's wrong with my Gamma()?

  Alt 25. Jan 2010, 17:04
Try to use the inverse of dthe factor:F := Power(F, 1/AFactor);
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#5

Re: [GR32] What's wrong with my Gamma()?

  Alt 25. Jan 2010, 17:20
Of course! I'm stupilo...

Ok, I have another question. To TBitmap32 I'm loading also PNGs. Why after function image lost alpha channel (last param in ApplyLUT() is True)?

-- Added --

I'm really stupid. In above procedure in B bitmap A channel is $FF for any pixel. To correctly apply LUT to this bitmap simply have to set alpha, for example by copying original bitmap. Sorry guys, next questions will be brainy.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:49 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz