灰度到伪彩色的转换公式:
f表示某一像素点的灰度
if 0<=f<63 then
begin
r :=0; g :=254-4f; b :=255;
end;
if 64<=f<127 then
begin
r :=0; g :=4f-254; b :=510-4f;
end;
if 128<=f<191 then
begin
r :=4f-510; g :=255; b :=0;
end;
if 192<=f<=255 then
begin
r :=255; g :=1022-4*f; b :=0;
end;
//灰度图像转成伪彩色实例:
procedure GrayToColor(Bmp: TBitmap);
var
i, j, uG: Integer;
P: PByteArray;
begin
Bmp.PixelFormat := pf24bit;
for j := 0 to Bmp.Height - 1 do
begin
P := Bmp.ScanLine[j];
for i := 0 to Bmp.Width - 1 do
begin
uG := P[3 * i];
if (0 <= uG) and (uG < 63) then //灰度------>伪彩色
begin
P[3 * i + 2] := 0;
P[3 * i + 1] := 254 - 4 * uG;
P[3 * i] :=