//提供相关算法或技术也可以,如果有源码最好另外高分相送!
//先谢!!!

解决方案 »

  1.   

    参考:
    256色转为16色
    Bitmap.PixelFormat :=pf8bit//pf16bit色彩的灰度转化
    function RgbToGray(RGBColor : TColor) : TColor; 
    var 
    Gray : byte; 
    begin 
    Gray := Round((0.30 * GetRValue(RGBColor)) + 
    (0.59 * GetGValue(RGBColor)) + 
    (0.11 * GetBValue(RGBColor ))); 
    Result := RGB(Gray, Gray, Gray);  改变图象的对比度、亮度、饱和度 
     宋体 // Bitmap.ScanLine[X] 可以获取图像象素的内存地址,24Bits的Bitmap的每一象 
    // 素是以三原色RGB的次序存放的,改变RGB的值就可调节Bitmap的色彩. 
    // R, G, B: -255~255 
    procedure RGB(var Bmp: TBitmap; R, G, B: Integer); 
    var 
    X, Y: Integer; 
    I: Byte; 
    ColorTable: array[0..255] of TRGBColor; 
    pRGB: PRGBColor; 
    begin 
    for I := 0 to 255 do 
    begin 
    ColorTable[I].R := Byte(I + R); 
    ColorTable[I].G := Byte(I + G); 
    ColorTable[I].B := Byte(I + B); 
    end; for Y := 0 to Bmp.Height - 1 do 
    begin 
    pRGB := Bmp.ScanLine[Y]; 
    for X := 0 to Bmp.Width - 1 do 
    begin 
    pRGB.R := ColorTable[pRGB.R].R; 
    pRGB.G := ColorTable[pRGB.G].G; 
    pRGB.B := ColorTable[pRGB.B].B; 
    end; 
    Inc(pRGB); 
    end; 
    end; // 改变图像的亮度,也只需调用RGB(Bmp, X, X, X)改变三原色. 
    // 调节Bitmap的对比度 
    // 应用公式: 新颜色值 = (旧颜色值 - 128) * 系数 + 128 
    procedure Contrast(var Bmp: TBitmap; Amount: Integer); 
    // Amount: -255~255 
    var 
    X, Y: Integer; 
    I: Byte; 
    ColorTable: array[0..255] of TRGBColor; 
    pRGB: PRGBColor; 
    begin 
    for I := 0 to 126 do 
    begin 
    Y := (Abs(128 - I) * Amount) div 256; 
    ColorTable[I].r := GetRValue(Byte(I - Y)); 
    ColorTable[I].g := GetGValue(Byte(I - Y)); 
    ColorTable[I].b := GetBValue(Byte(I - Y)); 
    end; 
    for I := 127 to 255 do 
    begin 
    Y := (Abs(128 - I) * Amount) div 256; 
    ColorTable[I].r := GetRValue(Byte(I + Y)); 
    ColorTable[I].g := GetGValue(Byte(I + Y)); 
    ColorTable[I].b := GetBValue(Byte(I + Y)); 
    end; 
    for Y := 0 to Bmp.Height - 1 do 
    begin 
    pRGB := Bmp.ScanLine[Y]; 
    for X := 0 to Bmp.Width - 1 do 
    begin 
    pRGB.R := ColorTable[pRGB.R].R; 
    pRGB.G := ColorTable[pRGB.G].G; 
    pRGB.B := ColorTable[pRGB.B].B; 
    Inc(pRGB); 
    end; 
    end; 
    end; // 改变饱和度 
    procedure Saturation(var Bmp: TBitmap; Amount: Integer); // Amount: 0~510 
    var 
    Grays: array[0..767] of Integer; 
    Alpha: array[0..255] of Word; 
    Gray, X, Y: Integer; 
    pRGB: PRGBColor; 
    I: Byte; 
    begin 
    for I := 0 to 255 do Alpha[I] := (I * Amount) shr 8; 
    x := 0; 
    for I := 0 to 255 do 
    begin 
    Gray := I - Alpha[I]; 
    Grays[X] := Gray; Inc(X); 
    Grays[X] := Gray; Inc(X); 
    Grays[X] := Gray; Inc(X); 
    end; 
    for Y := 0 to Bmp.Height - 1 do 
    begin 
    pRGB := Bmp.ScanLine[Y]; 
    for X := 0 to Bmp.Width - 1 do 
    begin 
    Gray := Grays[pRGB.R + pRGB.G + pRGB.B]; 
    pRGB.R := Byte(Gray + Alpha[pRGB.R]); 
    pRGB.G := Byte(Gray + Alpha[pRGB.G]); 
    pRGB.B := Byte(Gray + Alpha[pRGB.B]); 
    Inc(pRGB); 
    end; 
    end; 
    end; end; procedure TForm1.FormCreate(Sender: TObject); 
    begin 
    Shape1.Brush.Color := RGB(255, 64, 64); 
    Shape2.Brush.Color := RgbToGray(Shape1.Brush.Color); 
    end;
      

  2.   

    灰度到伪彩色的转换公式:
    f表示某一像素点的灰度
    if 0<=f<63 then
    begin
      r :=0; g :=254-4*f; b :=255;
    end;
    if 64<=f<127 then
    begin
      r :=0; g :=4*f-254; b :=510-4*f;
    end;
    if 128<=f<191 then
    begin
      r :=4*f-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] := 255;
          end;
          if (64 <= uG) and (uG < 127) then
          begin
            P[3 * i + 2] := 0;
            P[3 * i + 1] := 4 * uG - 254;
            P[3 * i] := 510 - 4 * uG;
          end;
          if (128 <= uG) and (uG < 191) then
          begin
            P[3 * i + 2] := 4 * uG - 510;
            P[3 * i + 1] := 255;
            P[3 * i] := 0;
          end;
          if (192 <= uG) and (uG <= 255) then
          begin
            P[3 * i + 2] := 255;
            P[3 * i + 1] := 1022 - 4 * uG;
            P[3 * i] := 0;
          end;
        end;
      end;
    end;
      

  3.   

    灰度转伪彩色用RGB不太合适,用CMYK或者YUV可能好理解些。
      

  4.   

    <<delphi5.0編程百例>>有個例子,現在書不在我身邊。。
    清華出版社
      

  5.   

    to  njbudong 
     什么是伪彩色????????????
      

  6.   

    好比彩超?
    那也考虑血液流速、方向,揣流等,以之映射RGB。
    总得有个对应关系,要么是做成photoshop中的duotone效果,伪彩?