![]() |
Better sepia wanted
Hi. I'm looking for better method for sepialize image. Currently I'm using "open source" (similar implementation available everywhere in many languages) method:
Delphi-Quellcode:
I thought, that result is good till I saw sepialized image from PSP.
Bits.R := (Bits.R + Bits.G + Bits.B) div 3;
Bits.G := Bits.R; Bits.B := Bits.R; Inc(Bits.R, AFactor * 2); Inc(Bits.G, AFactor); if Bits.R < (AFactor * 2) then Bits.R := 255; if Bits.G < (AFactor) then Bits.G := 255; Do you know better algorithm? |
Re: Better sepia wanted
try it out
Delphi-Quellcode:
type
TBGR = packed record B, G, R: Byte; end; procedure RenderColor(ABitmap: TBitmap; NewHue, NewSaturation: Word); var Hue, Luminance, Saturation: Word; p: ^TBGR; c: TColor; x, y: Integer; begin // NewHue := 36; // NewSaturation := 64; with ABitmap do begin PixelFormat := pf24Bit; for y := 0 to Height - 1 do begin p := ScanLine[y]; for x := 0 to Width - 1 do begin c := RGB(p^.R, p^.G, p^.B); ColorRGBToHLS(c, Hue, Luminance, Saturation); c := ColorHLSToRGB(NewHue, Luminance, NewSaturation); p^.B := GetBValue(c); p^.G := GetGValue(c); p^.R := GetRValue(c); Inc(p); end; end; end; end; |
Re: Better sepia wanted
Working quite good, thanks :)
Could you tell what to do to get more grey, like in version in post #1? PS: I early did't known about ColorRGBToHLS() and ColorHLSToRGB(). What are maximum values for HLS? The same as in Windows color dialog, mean 239, 240, 240? And yet another stupid question: Delphi HLS is the same like HSL (hue, saturation, lightness)? |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:00 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz