我正在做一个非常有趣的计算机视觉项目,其中谈到如何“手工创建”图像与Matlab。
老师给了我三个矩阵:光源矩阵(称为E),摄像机灵敏度矩阵(称为R),最后是表面反射矩阵(称为S)。矩阵尺寸如下:
y-dimension) S: 31x512x512 (反射率样品x x维 x R: 31x3E: 31x1 )
老师也给了我以下的关系:
P=transpose(C)*R=transpose(S)*diagonal(E)*R
其中C是颜色矩阵。其中P是传感器响应矩阵。
目标是显示由所有以前的矩阵形成的图像。因此,我们必须计算P矩阵。
所有矩阵的类为双。
这就是我所做的:
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然而,它根本不起作用。输出是图像,但是颜色是完全错误的(图像上有太多的蓝色)。我认为这可能是一个矩阵重塑问题,但我已经尝试了所有可能的组合,但什么也没有做。
非常感谢你的帮助
发布于 2020-05-05 12:10:06
我终于发现了错误。这是正常化进程中的一个问题。我用错了配方。
https://stackoverflow.com/questions/32915732
复制相似问题