foosballraw matlab,Angle between two RGB vectors

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)

ec3729d6dc9cd2c242199247bcf5e5b1.png

The image contains an X-Rite® 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值