我正在做一个非常有趣的Computer Vision项目,该项目讨论了如何使用Matlab“手动创建”图像。
老师给了我三个矩阵:光源矩阵(称为E),相机感光度矩阵(称为R),最后是表面反射率矩阵(称为S)。矩阵尺寸如下:
S:31x512x512(反射率样本x x尺寸 x y尺寸))R:31x3E:31x1
老师还给了我以下关系:
P = transpose(C)* R = transpose(S)*对角线(E)* R
其中C是颜色矩阵。其中P是传感器响应矩阵。
目标是显示所有先前矩阵形成的图像。因此,我们必须计算P矩阵。
所有矩阵的类是double。
这是我所做的:
Diag_D=diag(D);% Diagonal matrix of D
S_reshaped= reshape(S,31,[512*512]);% Reshape the surface reflectance matrix
S_permute=permute(S_reshaped,[2 1]);% The output matrix is a 262144x31 matrix
Color_Signal_D65_buffer=S_permute*Diag_DD;
Color_Signal_D65=reshape(Color_Signal_D65_buffer,[512 512 31]);% This is the final color matrix
Image_D65_buffer= (reshape(Color_Signal_D65,[512*512],31))*R;% Apply the given formula
Image_D65= reshape(Image_D65_buffer,[512 512 3]);% image formation
Image_D65_norm=sqrt(sum(Image_D65.^2,3));% Compute the Image_D65 norm
Image_D65_Normalized=bsxfun(@rdivide, Image_D65, Image_D65_norm);% Divide each element of the matrix by the norm in order to normalize the matrix
figure
imshow(Image_D65_Normalized)% Display the image
但是,它根本没有用。输出是图像,但是颜色是完全错误的(图像上有太多蓝色)。我认为这可能是矩阵重塑问题,但我尝试了所有可能的组合,但无济于事。
非常感谢您的帮助
我终于找到了错误。这是规范化过程中的问题。我使用了错误的公式。