colorangle
Angle between two RGB vectors
Description
Examples
Compare Accuracy of Illuminant Estimation Algorithms
Read a test image. The image is the raw data captured with a Canon EOS 30D digital camera after correcting the black level and scaling the intensities to 16 bits per pixel. No demosaicing, white balancing, color enhancement, noise filtering, or gamma correction has been applied.
RAW = imread("foosballraw.tiff");
Interpolate using the demosaic
function to obtain a color image. The color filter array pattern is RGGB.
A = demosaic(RAW,"rggb");
Display the image. Because the image is in linear RGB color space, apply gamma correction so the image appears correctly on the screen.
A_sRGB = lin2rgb(A); imshow(A_sRGB)
The image contains a ColorChecker® chart. Specify the ground truth illuminant, which was calculated in advance using the neutral patches of the chart.
illuminant_groundtruth = [0.0717 0.1472 0.0975];
To avoid skewing the estimation of the illuminant, exclude the ColorChecker chart by creating a mask.
mask = true(size(A,1), size(A,2)); mask(920:1330,1360:1900) = false;
Run three different illuminant estimation algorithms: illumwhite
, illumgray
, and illumpca
.
illuminant_whitepatch = illumwhite(A,"Mask",mask); illuminant_grayworld = illumgray(A,"Mask",mask); illuminant_pca = illumpca(A,"Mask",mask);
Compare each estimation against the ground truth by calculating the angle between each estimated illuminant and the ground truth using the colorangle
function. The smaller the angle, the better the estimation. The magnitude of the estimation does not matter because only the direction of the illuminant is used to white-balance an image with chromatic adaptation.
angle_whitepatch = colorangle(illuminant_whitepatch,illuminant_groundtruth)
angle_whitepatch = 5.0921
angle_grayworld = colorangle(illuminant_grayworld,illuminant_groundtruth)
angle_grayworld = 5.1036
angle_pca = colorangle(illuminant_pca,illuminant_groundtruth)
angle_pca = 5.0134
The value of angle_pca
is smallest, indicating that the PCA illuminant estimation algorithm is closest to the ground truth illumination for this image.
Input Arguments
rgb1
— First RGB vector
3-element numeric vector
First RGB vector, specified as a 3-element numeric vector.
Data Types: single
| double
| uint8
| uint16
rgb2
— Second RGB vector
3-element numeric vector
Second RGB vector, specified as a 3-element numeric vector.
Data Types: single
| double
| uint8
| uint16
Output Arguments
angle
— Angle between RGB vectors
numeric scalar
Angle between RGB vectors, returned as a numeric scalar.
Data Types: double
More About
Angular Error
Angular error is a useful metric to evaluate the estimation of an illuminant against the ground truth. The smaller the angle between the ground truth illuminant and the estimated illuminant, the better the estimate.
Version History
Introduced in R2017b
See Also
whitepoint
| chromadapt
| illumgray
| illumpca
| illumwhite
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)