1. What color conversion is and why we need it
1. การแปลงค่าสีคืออะไรและทำไมต้องแปลง
Measuring instruments such as a camera and a spectrophotometer give different signals, depending on how the device is made and how it is set up. A camera gives an RGB value for each pixel, while a spectrophotometer gives a light spectrum for each measured spot. The meaning and the amount of data are very different, so readings from the two instruments cannot be compared directly.
เครื่องมือวัด เช่น กล้องถ่ายภาพและสเปกโตรโฟโตมิเตอร์ ให้สัญญาณที่แตกต่างกัน ขึ้นอยู่กับการผลิตอุปกรณ์และการตั้งค่าเครื่องมือนั้น กล้องถ่ายภาพให้ค่า RGB ของแต่ละพิกเซล ส่วนสเปกโตรโฟโตมิเตอร์ให้ค่าสเปกตรัมแสงของแต่ละจุดที่วัด ข้อมูลที่ได้มีความหมายและจำนวนข้อมูลต่างกันมาก จึงเทียบค่าจากสองเครื่องมือนี้ตรง ๆ ไม่ได้
To compare color measured by a camera with color measured by a spectrophotometer, or one camera with another, the recorded data must be put on one standard. The CIE (International Commission on Illumination) defines how measured data are converted into the color values CIE xy and CIE L*a*b*. CIE xy tells which color the sample is (its chromaticity). CIE L*a*b* adds lightness and describes color differences, and it shows them more evenly than CIE xy. This page explains the conversion in short steps and shows, in the sub-topics that follow, how to plot the converted values on CIE xy and CIE L*a*b* graphs.
เพื่อเทียบค่าสีที่วัดด้วยกล้องกับสเปกโตรโฟโตมิเตอร์ หรือเทียบกล้องตัวหนึ่งกับอีกตัวหนึ่ง จำเป็นต้องทำให้ข้อมูลที่บันทึกได้อยู่ในมาตรฐานเดียวกัน CIE (International Commission on Illumination) ได้กำหนดมาตรฐานการแปลงข้อมูลที่วัดได้เป็นค่าสี CIE xy และ CIE L*a*b* โดย CIE xy บอกว่าสิ่งที่วัดเป็นสีอะไร (chromaticity) ส่วน CIE L*a*b* บอกความสว่างและความต่างของสี และบอกความแตกต่างของสีได้สม่ำเสมอกว่า CIE xy หน้านี้อธิบายวิธีแปลงค่าที่เครื่องมือวัดได้เป็นค่าสีอย่างสั้น ๆ และในหัวข้อย่อยถัดไปจะแสดงตัวอย่างการแปลงค่าสีไปแสดงบนกราฟ CIE xy และ CIE L*a*b*
2. Standard observer and illuminant
2. สิ่งที่ต้องรู้: standard observer และ illuminant
Converting a spectrum to color needs two choices, the standard observer and the illuminant. The same sample gives different numbers if either one changes, so always state both conditions with the converted result, so that it can be compared with values from other measuring instruments.
การแปลงสเปกตรัมเป็นสีต้องกำหนด 2 อย่างคือ standard observer และ illuminant ถ้าเปลี่ยนอย่างใดอย่างหนึ่ง ตัวอย่างเดิมจะให้ตัวเลขต่างกัน จึงต้องระบุเงื่อนไขทั้งสองไว้ในผลการแปลงเป็นค่าสีเสมอ เพื่อใช้ในการเปรียบเทียบกับค่าที่ได้จากเครื่องมือวัดอื่น ๆ ได้
Standard observer
Standard observer
The standard observer is the angle of the observer, the person looking at the color. It is not the angle of the measurement. The CIE defines two standard sets of eye-response data, the 2° observer and the 10° observer, which stand for the average human eye looking at a colored area of different sizes [1].
Standard observer คือมุมของผู้สังเกต (ผู้ที่มองสีนั้น) ไม่ใช่มุมของการวัด CIE กำหนดชุดข้อมูลการตอบสนองของดวงตามาตรฐานไว้ 2 ชุด คือ observer 2° และ observer 10° ซึ่งเป็นตัวแทนของดวงตาคนโดยเฉลี่ยเมื่อมองพื้นที่สีที่มีขนาดต่างกัน [1]
- What decides the choice is how large the colored area appears to the viewer, as an angle at the viewer's eye. It does not depend on the angle at which the detector is placed or the angle at which the camera shoots.
- Use the 2° observer when the area the viewer sees covers an angle of 4° or less [1], such as a small color patch, an indicator spot or an LED seen from a distance [2].
- Use the 10° observer when it covers more than 4°, such as paint on a wall, fabric, plastic parts or a large liquid surface [3].
- สิ่งที่ใช้เลือกคือพื้นที่สีนั้นกินมุมกี่องศาในสายตาของผู้ดู ไม่ใช่มุมที่วาง detector หรือมุมที่กล้องถ่าย
- observer 2° ใช้เมื่อพื้นที่สีที่ผู้ดูเห็นกินมุมไม่เกิน 4° [1] เช่น จุดสีเล็ก ๆ จุดแสดงสถานะ หรือ LED ที่มองจากระยะไกล [2]
- observer 10° ใช้เมื่อกินมุมมากกว่า 4° เช่น สีทาผนัง ผ้า ชิ้นงานพลาสติก หรือผิวของเหลวขนาดใหญ่ [3]
Illuminant
Illuminant
The illuminant is the light under which the color is judged [4]. Choose it to match the conditions in which the viewer will actually see the product, or the standard the product must be compared with. It does not have to be the same as the light source used for the measurement. For example, a sample measured with the lamp inside the instrument can be calculated for D65, because the reflectance R(λ) is a property of the sample and is not tied to the instrument's lamp.
Illuminant คือแสงที่ใช้ตัดสินสี [4] เลือกให้ตรงกับสภาพที่ผู้ดูจะเห็นชิ้นงานจริง หรือตรงกับมาตรฐานที่ต้องเทียบ ไม่จำเป็นต้องเป็นแสงเดียวกับ light source ที่ใช้ตอนวัด เช่น วัดด้วยหลอดไฟของเครื่องวัดแล้วคำนวณเป็น D65 ได้ เพราะค่าการสะท้อนแสง R(λ) เป็นสมบัติของตัวอย่าง ไม่ผูกกับหลอดของเครื่อง
- D65 (daylight, about 6500 K): daylight and most screens. It is the general default and the standard light for inspecting and comparing color (ISO 3664 [5]) [6].
- D50 (about 5000 K): printing and graphic arts [7].
- A (about 2856 K): incandescent and halogen lamps [8].
- F series (F2, F11 and others): fluorescent lamps [9].
- D65 (แสงกลางวัน อุณหภูมิสี 6500 K): แสงกลางวันและหน้าจอส่วนใหญ่ เป็นค่าตั้งต้นทั่วไปและเป็นแสงมาตรฐานสากล (ISO 3664 [5]) สำหรับตรวจและเทียบสี [6]
- D50 (อุณหภูมิสี 5000 K): งานพิมพ์และกราฟิก [7]
- A (อุณหภูมิสี 2856 K): หลอดไส้และหลอดฮาโลเจน [8]
- F (F2, F11 และอื่น ๆ): หลอดฟลูออเรสเซนต์ [9]
Examples: which values can be compared
ตัวอย่าง: แบบไหนเทียบกันได้
- Comparable data: checking a small color patch on a package with a spectrophotometer and with a camera (photographed together with a gray reference card). The camera value is sRGB, which is tied to the 2° observer and D65, so the spectrum must also be calculated with the 2° observer and D65. Then the two values can be compared.
- Comparable data: checking a box on a shelf under fluorescent tubes. Use the 10° observer and F2 for both the product and the reference standard supplied by the customer. Even if they were measured on different days or with different instruments, they can be compared because they were calculated under the same conditions.
- Not comparable data: the same sample, with one value calculated with the 2° observer and the other with the 10° observer (same illuminant). The xy and L*a*b* values differ. Recalculate both under the same conditions first.
- Not comparable data: one value calculated under D65 and the other under F11, or the same sample photographed under different light sources without white balance. The colors obtained differ because the difference seen is a difference in the light, not in the color of the object.
- ข้อมูลที่เทียบกันได้: ตรวจจุดสีเล็ก ๆ บนบรรจุภัณฑ์ด้วยสเปกโตรโฟโตมิเตอร์และด้วยกล้อง (ถ่ายพร้อมแผ่นอ้างอิงสีเทา) ค่าจากกล้องเป็น sRGB ซึ่งผูกกับ observer 2° และ D65 จึงต้องคำนวณค่าจากสเปกตรัมที่ observer 2° และ D65 ด้วย ทั้งสองค่าจึงเทียบกันได้
- ข้อมูลที่เทียบกันได้: ตรวจกล่องที่วางบนชั้นใต้หลอดฟลูออเรสเซนต์ ใช้ observer 10° กับ F2 ทั้งชิ้นงานและค่ามาตรฐานอ้างอิงที่ลูกค้าส่งมา แม้วัดกันคนละวันหรือคนละเครื่อง ก็เทียบกันได้ เพราะคำนวณภายใต้เงื่อนไขเดียวกัน
- ข้อมูลที่เทียบกันไม่ได้: ตัวอย่างเดียวกัน ค่าหนึ่งคำนวณที่ observer 2° อีกค่าหนึ่งที่ observer 10° (illuminant เดียวกัน) ค่า xy และ L*a*b* จะต่างกัน ต้องคำนวณใหม่ที่เงื่อนไขเดียวกันก่อน
- ข้อมูลที่เทียบกันไม่ได้: ค่าหนึ่งคำนวณที่ D65 อีกค่าหนึ่งที่ F11 หรือตัวอย่างเดียวกันถ่ายภาพที่แหล่งกำเนิดแสงต่างกัน แล้วไม่ทำ white balance ค่าสีที่ได้จะต่างกันเพราะความต่างที่เห็นเป็นความต่างของแสง ไม่ใช่ความต่างของสีวัตถุ
Note: values can be compared only when they were converted under the same observer, the same illuminant and, for a camera, the same white-balance procedure.
หมายเหตุ: ค่าที่จะเทียบกันได้ต้องแปลงภายใต้ observer และ illuminant เดียวกัน และกรณีกล้องต้องมีวิธีทำ white balance เดียวกันเท่านั้น
3. Conversion steps
3. ขั้นตอนการแปลงแบบสั้น ๆ
Path 1: from a spectrum to CIE color values
ทางที่ 1: จากสเปกตรัมไปสู่ค่าสี CIE
- Measure the reflectance R(λ) of the sample over 380 to 780 nm.
- Choose the standard observer (2° or 10°) and the illuminant (for example D65) to match the conditions in which the color will be seen or the standard it will be compared with. Do not choose them from the angle or the light source of the measuring instrument.
- Prepare the color-matching function files x̄(λ), ȳ(λ), z̄(λ) of the chosen observer and the power I(λ) of the chosen illuminant from the CIE tables.
- Convert R(λ) to X, Y and Z.
- Convert X, Y and Z to CIE xy. The pair (x, y) is the point on the CIE xy diagram.
- Convert X, Y and Z to CIE L*a*b*.
- วัดค่าการสะท้อนแสง R(λ) ของตัวอย่างในช่วง 380 ถึง 780 nm
- เลือก standard observer (2° หรือ 10°) และ illuminant (เช่น D65) ให้ตรงกับสภาพที่จะมองสีนั้นหรือมาตรฐานที่ต้องเทียบ ไม่ได้เลือกจากมุมหรือแหล่งกำเนิดแสงของเครื่องมือที่ใช้วัด
- เตรียมไฟล์ color-matching function x̄(λ), ȳ(λ), z̄(λ) ของ observer ที่เลือก และกำลังแสง I(λ) ของ illuminant ที่เลือกจากตาราง CIE
- แปลง R(λ) เป็น X, Y และ Z
- แปลง X, Y และ Z เป็น CIE xy คู่ (x, y) คือจุดบนกราฟ CIE xy
- แปลง X, Y และ Z เป็น CIE L*a*b*
Path 2: from RGB to CIE color values
ทางที่ 2: จาก RGB ไปสู่ค่าสี CIE
The RGB a camera records already contains the color of the light source at the time of shooting: the same object photographed under an incandescent lamp looks yellow, and under daylight it looks a neutral, slightly bluish color. We want the color of the object, not of the light, so the effect of the light at the time of shooting must be removed first, by white balance. Do it before converting to XYZ; otherwise a difference in the light will be counted as a difference in the color of the object.
ค่า RGB ที่กล้องบันทึกมีสีของแหล่งกำเนิดแสงตอนถ่ายภาพปนเข้ามาอยู่แล้ว วัตถุเดียวกันถ่ายภาพภายใต้หลอดไส้จะออกเหลือง ภายใต้แสงกลางวันจะออกฟ้ากลาง ๆ สิ่งที่ต้องการคือสีของวัตถุ ไม่ใช่สีของแสง จึงต้องตัดผลของแสงตอนถ่ายออกก่อนด้วย white balance ซึ่งต้องทำก่อนแปลงเป็น XYZ ถ้าข้ามขั้นนี้ ความต่างของแสงจะถูกนับเป็นความต่างของสีวัตถุ
- Check which color space the RGB values are in. Most cameras give sRGB. The signal size is 2ⁿ, where n is the number of bits.
- White balance: measure a white or gray reference card under the same light as the object, then adjust the gain of the R, G and B channels until the card is neutral (R = G = B). This removes the effect of the light at the time of shooting. (In this step a reference card must be photographed together with the object, to check whether the sRGB is correct.)
- Normalize the signal by dividing by 2ⁿ − 1.
- Convert sRGB to linear RGB (remove the gamma curve).
- Multiply the linear RGB by the sRGB matrix to get X, Y and Z. The standard observer (2°) and the illuminant (D65) are already fixed by sRGB, so there is nothing to choose in this step.
- If the color is to be judged under an illuminant other than D65, apply a chromatic adaptation to X, Y, Z. The result is an estimate, because three RGB numbers cannot give back the spectrum R(λ).
- Convert X, Y and Z to CIE xy.
- Convert X, Y and Z to CIE L*a*b*.
- ตรวจสอบก่อนว่าค่า RGB ที่วัดได้เป็น color space ใด กล้องส่วนใหญ่ได้เป็น sRGB ขนาดสัญญาณเป็น 2ⁿ เมื่อ n คือ จำนวน bits
- ทำ white balance: วัดแผ่นอ้างอิงสีขาวหรือเทาที่อยู่ภายใต้แสงเดียวกับวัตถุ แล้วปรับ gain ของช่อง R, G, B ให้แผ่นนั้นเป็นกลาง (R = G = B) ขั้นนี้ตัดผลของแสงตอนถ่ายออก (ขั้นตอนนี้จำเป็นต้องถ่ายแผ่นอ้างอิงติดไปด้วยเพื่อใช้ตรวจสอบว่าได้ sRGB ถูกต้องหรือไม่)
- normalize สัญญาณด้วยการหาร 2ⁿ − 1
- แปลง sRGB เป็น linear RGB (เอา gamma ออก)
- คูณ linear RGB ด้วย matrix ของ sRGB เพื่อได้ X, Y และ Z ขั้นนี้ standard observer (2°) และ illuminant (D65) ถูกกำหนดโดย sRGB อยู่แล้ว ไม่ต้องเลือก
- ถ้าต้องการดูสีภายใต้ illuminant อื่นที่ไม่ใช่ D65 ให้ทำ chromatic adaptation กับ X, Y, Z ผลที่ได้เป็นค่าประมาณ เพราะค่า RGB เพียง 3 ค่าไม่สามารถคืนสเปกตรัม R(λ) ได้
- แปลง X, Y และ Z เป็น CIE xy
- แปลง X, Y และ Z เป็น CIE L*a*b*
Once X, Y and Z are obtained, both paths are the same. A spectrum is the more reliable starting point than the values converted from a camera. The RGB path is nevertheless popular for color inspection because the equipment is cheaper, while the accuracy depends on the camera, the white balance and the exposure setting.
เมื่อได้ X, Y และ Z แล้ว ทั้งสองเส้นทางใช้ขั้นตอนต่อจากนั้นเหมือนกัน การวัดสีด้วยสเปกตรัมเป็นจุดเริ่มที่เชื่อถือได้มากกว่าการแปลงจากค่าที่ได้จากกล้อง อย่างไรก็ตามการแปลงค่า RGB เป็นที่นิยมใช้ในการตรวจสอบสีมากกว่า เพราะอุปกรณ์ที่ใช้ราคาถูกกว่า ส่วนความแม่นยำขึ้นกับกล้อง การทำ white balance และการตั้งค่า exposure
4. Where it is used
4. การประยุกต์ใช้งานการตรวจสอบค่าสี
- Water quality: judging the color of water, for example tea-brown from dissolved organic matter or green from algae, by comparing its CIE xy or L*a*b* with a reference sample.
- Production lines: checking the color of filters, coatings and tinted lenses against a target.
- Batch consistency: plotting many batches on one CIE xy diagram to see whether one has drifted.
- Food and drinks: monitoring the color of juice, beer or cooking oil, or the ripeness of fruit, from camera images.
- Paint, textile and printing: matching a new batch to a customer's color standard.
- งานวัดคุณภาพน้ำ: เช่น สีน้ำตาลชาจากสารอินทรีย์ที่ละลายอยู่ หรือสีเขียวจากสาหร่าย โดยเทียบค่า CIE xy หรือ L*a*b* กับตัวอย่างอ้างอิง
- งานสายการผลิต: ตรวจสีของฟิลเตอร์ ฟิล์มเคลือบ และเลนส์แต่งสีเทียบกับค่าเป้าหมาย
- ความสม่ำเสมอระหว่างล็อต: พล็อตสีของหลายล็อตบนกราฟ CIE xy เดียวกัน เพื่อดูว่ามีล็อตใดเบี่ยงเบนไปหรือไม่
- กลุ่มอาหารและเครื่องดื่ม: ติดตามสีของน้ำผลไม้ เบียร์ หรือน้ำมันทอด และความสุกของผลไม้ จากภาพถ่าย
- กลุ่มสี สิ่งทอ และงานพิมพ์: จับคู่สีให้ตรงกับมาตรฐานสีของลูกค้า
References
เอกสารอ้างอิง
- International Organization for Standardization and International Commission on Illumination (CIE), "Colorimetry — Part 1: CIE standard colorimetric observers," ISO/CIE 11664-1:2019, Jun. 2019. Accessed: Oct. 4, 2026. [Online]. Available: https://www.iso.org/standard/74164.html
- International Commission on Illumination (CIE), "CIE 1931 colour-matching functions, 2 degree observer," CIE datatable, DOI: 10.25039/CIE.DS.xvudnb9b. Accessed: Oct. 4, 2026. [Online]. Available: https://cie.co.at/datatable/cie-1931-colour-matching-functions-2-degree-observer
- International Commission on Illumination (CIE), "CIE 1964 colour-matching functions, 10 degree observer," CIE datatable, DOI: 10.25039/CIE.DS.sqksu2n5. Accessed: Oct. 4, 2026. [Online]. Available: https://cie.co.at/datatable/cie-1964-colour-matching-functions-10-degree-observer
- International Organization for Standardization and International Commission on Illumination (CIE), "Colorimetry — Part 2: CIE standard illuminants," ISO/CIE 11664-2:2022. Accessed: Oct. 4, 2026. [Online]. Available: https://cie.co.at/publications/colorimetry-part-2-cie-standard-illuminants-0
- International Organization for Standardization, "Graphic technology and photography — Viewing conditions," ISO 3664.
- International Commission on Illumination (CIE), "CIE standard illuminant D65," CIE datatable, DOI: 10.25039/CIE.DS.hjfjmt59. Accessed: Oct. 4, 2026. [Online]. Available: https://cie.co.at/datatable/cie-standard-illuminant-d65
- International Commission on Illumination (CIE), "CIE standard illuminant D50," CIE datatable, DOI: 10.25039/CIE.DS.etgmuqt5. Accessed: Oct. 4, 2026. [Online]. Available: https://cie.co.at/datatable/cie-standard-illuminant-d50
- International Commission on Illumination (CIE), "CIE standard illuminant A - 1 nm," CIE datatable, DOI: 10.25039/CIE.DS.8jsxjrsn. Accessed: Oct. 4, 2026. [Online]. Available: https://cie.co.at/datatable/cie-standard-illuminant-1-nm
- International Commission on Illumination (CIE), "Relative spectral power distributions of illuminants representing typical fluorescent lamps, 1nm wavelength steps," CIE datatable (illuminants F1–F12), DOI: 10.25039/CIE.DS.54hy6srn. Accessed: Oct. 4, 2026. [Online]. Available: https://cie.co.at/datatable/relative-spectral-power-distributions-illuminants-representing-typical-fluorescent-lamps-0