当图像为RGB三通道时,假设A为三通道图像,则sum(A,3)运算后的值为每个通道对应位置的值各自相加,比如在位置p三通道像素值分别为r,g,b,则在p位置运算后的值为r+g+b,具体看下面的代码:
<span style="font-size:18px;">>> A=[1 2 3;4 5 6;7 8 9] A = 1 2 3 4 5 6 7 8 9 >> bb=repmat(A,[1 1 3]) bb(:,:,1) = 1 2 3 4 5 6 7 8 9 bb(:,:,2) = 1 2 3 4 5 6 7 8 9 bb(:,:,3) = 1 2 3 4 5 6 7 8 9 >> cc=sum(bb,3) cc = 3 6 9 12 15 18 21 24 27</span>