請問Lab->RGB, RGB->LAB的顏色轉化方法,以及代碼,或者有什麼參考書籍,謝謝

來源:互聯網
上載者:User
請問Lab->RGB, RGB->LAB的顏色轉化方法,以及代碼,或者有什麼參考書籍,謝謝 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiMultimedia/html/delphi_2006121620555555.html
請問Lab->RGB,   RGB->LAB的顏色轉化方法,以及代碼,或者有什麼參考書籍,謝謝

請參考:  
   
  http://delphicikk.atw.hu/listaz.php?id=1452&oldal=22  
   
 

謝謝!  
  但編譯時間發生錯誤,在  
   
  [Error]   uLabRgb.pas(175):   Left   side   cannot   be   assigned   to  
  [Fatal   Error]   ColorConvert.dpr(6):   Could   not   compile   used   unit   'uLabRgb.pas'  
   
  在最後一節  
      for   I   :=   1   to   3   do  
          for   J   :=   1   to   3   do  
              RgbXyz[I,   J]:=CToXyz[I,   J]   *   C[J];  
      XyzRgb   :=   InvertMatrix3(RgbXyz)

我這裡測試沒有任何問題的。  
   
  uses   uLabRgb;  
   
  {$R   *.dfm}  
   
  procedure   TForm1.Button1Click(Sender:   TObject);  
  var  
      RGB:   TVector3;  
      LAB:   TVector3;  
  begin  
      RGB[1]   :=   255;  
      RGB[2]   :=   125;  
      RGB[3]   :=   233;  
      LAB   :=   RGBTOLAB(RGB);  
      Caption   :=   FloatToStr(LAB[1])+':'+FloatToStr(LAB[2])+':'+FloatToStr(LAB[3]);  
  end;

const  
      RgbXyz:   TMatrix3   =   ((1,   0,   0),   (0,   1,   0),   (0,   0,   1));  
      XyzRgb:   TMatrix3   =   ((1,   0,   0),   (0,   1,   0),   (0,   0,   1));  
   
  ....  
   
  procedure   InitTransformationMatrices;  
  var  
      I:   Integer;  
      J:   Integer;  
      PhosphorZ:   TVector3;  
      C:   TVector3;  
      CToXyz:   TMatrix3;  
      XyzToC:   TMatrix3;  
  begin  
      for   I   :=   1   to   3   do  
      begin  
          CToXyz[1,   I]   :=   PhosphorX[I];  
          CToXyz[2,   I]   :=   PhosphorY[I];  
          CToXyz[3,   I]   :=   1   -   PhosphorX[I]   -   PhosphorY[I]  
      end;  
      XyzToC   :=   InvertMatrix3(CToXyz);  
      C   :=   MultiplyMatrix3ByVector3(XyzToC,   WhitePoint);  
      for   I   :=   1   to   3   do  
          for   J   :=   1   to   3   do  
              RgbXyz[I,   J]:=CToXyz[I,   J]   *   C[J];       //發生編譯錯誤  
      XyzRgb   :=   InvertMatrix3(RgbXyz)       //發生編譯錯誤  
  end;

我這裡沒有任何編譯錯誤啊。

[Error]   uLabRgb.pas(175):   Left   side   cannot   be   assigned   to  
   
  ------------------  
   
  這個錯誤一般是指左邊被賦值的變數的讀寫屬性為唯讀,   但這裡應該沒有這種情況。

const  
      RgbXyz:   TMatrix3   =   ((1,   0,   0),   (0,   1,   0),   (0,   0,   1));  
      XyzRgb:   TMatrix3   =   ((1,   0,   0),   (0,   1,   0),   (0,   0,   1));  
   
  並不是真正意義上的const,   所以對它們賦值是沒有問題的。

發了三次,不能再發只好要馬甲頂一下

假一個編譯指標  
   
  unit   uLabRgb;  
   
  interface  
   
  type  
      TVector3   =   array[1..3]   of   Double;  
   
  function   LabToRgb(Lab:   TVector3):   TVector3;  
  function   RgbToLab(Rgb:   TVector3):   TVector3;  
   
  implementation  
   
  {$J+}   //注意  
   
  ................

搞定了,感謝!

LabToRGB後的值都是很小的,顯示出來的都是黑色嗎

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.