Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > How do you Colorize?
User Name
Password
REGISTER NOW! Mark Forums Read




Reply Bookmark and Share
1 20th November 10:00
shrub
External User
 
Posts: 1
Default How do you Colorize?



Hello All -

Anyone have any idea how to colorize or change areas on a bitmap while
preserving the lumination / Saturation of the bitmap.

Similar to what you see on "Virtual house / wall color scheme" programs that
allow you to change a color of a wall to see how a new color would look
like.

I have seen and messed around heaps with the idea - however detail
(lumination and saturation) always seems to get lost in the process.

cheers

Shrub
  Reply With Quote


 


2 20th November 10:00
francesco savastano
External User
 
Posts: 1
Default How do you Colorize?



One way, but slow, is to colorize in HSL or HSI colors spaces. Just keep the
original luminosity and then change hue and saturation of the pixels to
colorize, using the hue and saturation of the colorant.
There are several other ways to do it in RGB space like grayscaling original
pixels and blending a color with overlay blendmode...
For more information about color spaces search this newsgroup on google or
go to efg lab site,
Hope it helps,
Cheers, Francesco

"Shrub" <shrubxuereb@hotmail.com> ha scritto nel messaggio
news:3fa57899$1@newsgroups.borland.com...


that
  Reply With Quote
3 20th November 10:01
shrub
External User
 
Posts: 1
Default How do you Colorize?


Yes, I have extensively used HSL(or HSI) and HSV models but they do not show
accurate results when you approach low or high luminance. Colors wash out
and degrade - loosing details from your original pic and therefore not
generating a realistic result..

I believe that the HSL is used in the final calculation - however I am
convinced there is something else to the puzzle... likely something really
simple.
Thanks
  Reply With Quote
4 20th November 10:01
andrew jameson
External User
 
Posts: 1
Default How do you Colorize?


Hi Shrub,


Andrew )

--------------------------------------------

type
TRGBArray = array[Word] of TRGBTriple;
pRGBArray = ^TRGBArray;

procedure Colorize(Src : TBitmap; Color : TColor);
var
r, g, b : integer;
x, y : integer;
SrcLine : pRGBArray;
SrcGap : integer;
Max : integer; begin
if (Color <> clNone) then begin
r := GetRValue(Color);
g := GetGValue(Color);
b := GetBValue(Color);
Src.PixelFormat := pf24bit;
SrcLine := Src.ScanLine[0];
SrcGap := Integer(Src.ScanLine[1]) - Integer(SrcLine);
for y := 0 to pred(Src.Height) do begin
for x := 0 to pred(Src.Width) do begin Max := SrcLine[x].rgbtRed;
if (SrcLine[x].rgbtGreen > Max) then Max := SrcLine[x].rgbtGreen;
if (SrcLine[x].rgbtBlue > Max) then
Max := SrcLine[x].rgbtBlue;
SrcLine[x].rgbtRed := MulDiv(r, Max, 255);
SrcLine[x].rgbtGreen := MulDiv(g, Max, 255);
SrcLine[x].rgbtBlue := MulDiv(b, Max, 255);
end; {for}
SrcLine := pRGBArray(Integer(SrcLine) + SrcGap);
end; {for}
end; {if}
end; {Colorize}
  Reply With Quote
Reply


Thread Tools
Display Modes


Some other forums that might be of your interest : Development, Ada, Apple script, Assembler, Awk, Beos, Basic, C, C++, C#, C# .net, .net, .net frameworks, Asp .net, Clarion, Clipper, Clos, Clu, Cobol, Coldfusion, Delphi, Dylan, Eiffel, Forth, Fortran, Haskell, Hermes, Icon, Idl, Java, Java script, Jscript .net, Jcl, Linoleum, Lisp, Lotus, Limbo, Logo, Ml, Mumps, Oberon, Postscript, Pop, Pl1, Prolog, Python, Ruby, Pascal, Perl, Php, Rebol, Rexx, Sed, Sather, Scheme, Smalltalk, Tcl, Vhdl, Vrml, Visual basic, Visual basic .net, Yorick, Mysql, Omnis, Postgresql, Xbase, Access, Oracle, Adabas, Berkeley, Btrieve, Filemaker, Gupta, Db2, Informix, Ingres, Mssql server, Object, Olap, Paradox, Rdb, Revelation, Sybase, Theory, Dbase, Html, Java script, Css, Flash, Photoshop, Corel script, Xml, Tech, Beos, Gem, Hp48, Hpux, Linux, Mac, Ms-dos, Os2, Palm, Solaris, Ti99, Windows, Xenix, Aos, Chorus, Geos, Inferno, Lantastic, Lynx, Mach, Minix, Netware, Os9, Parix, Plan9, Psos, Qnx, Xinu, Sco, Unix, Aix, Aux, 386bsd, Bsdi, Freebsd, Netbsd, Openbsd, Ultrix, Amd, Intel, Aptiva, Buz, Deals, Homebuilt, Overclocking, Programming, Extra forums


Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666