matlab 求亮度 程序,看不懂,function B=Brightness(Y)[m,n,d]=size(Y);b=0;if d==1B=sum(Y(:))/(m*n);endif d==3B(1)=sum(sum(Y(:,:,1)))/(m*n);B(2)=sum(sum(Y(:,:,2)))/(m*n);B(3)=sum(sum(Y(:,:,3)))/(m*n);end

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/22 02:35:36
matlab求亮度程序,看不懂,functionB=Brightness(Y)[m,n,d]=size(Y);b=0;ifd==1B=sum(Y(:))/(m*n);endifd==3B(1)=sum

matlab 求亮度 程序,看不懂,function B=Brightness(Y)[m,n,d]=size(Y);b=0;if d==1B=sum(Y(:))/(m*n);endif d==3B(1)=sum(sum(Y(:,:,1)))/(m*n);B(2)=sum(sum(Y(:,:,2)))/(m*n);B(3)=sum(sum(Y(:,:,3)))/(m*n);end
matlab 求亮度 程序,看不懂,
function B=Brightness(Y)
[m,n,d]=size(Y);
b=0;
if d==1
B=sum(Y(:))/(m*n);
end
if d==3
B(1)=sum(sum(Y(:,:,1)))/(m*n);
B(2)=sum(sum(Y(:,:,2)))/(m*n);
B(3)=sum(sum(Y(:,:,3)))/(m*n);
end

matlab 求亮度 程序,看不懂,function B=Brightness(Y)[m,n,d]=size(Y);b=0;if d==1B=sum(Y(:))/(m*n);endif d==3B(1)=sum(sum(Y(:,:,1)))/(m*n);B(2)=sum(sum(Y(:,:,2)))/(m*n);B(3)=sum(sum(Y(:,:,3)))/(m*n);end
很简单啊,根据传入的数据计算平均亮度,
如果数据是二维矩阵,计算出平均值
如果是三维矩阵计算出红绿蓝三种颜色各自的平均值