对于图像由彩色图转化为灰度图有三种方法分别为 加权法 均值法 最大值法!加权法就是 GRAY==0.3*R+0.59*G+0.11*B均值法就是 GRAY==(R+G+B)/3最大值发就是 max(R,G,B)A=imread('D:\lena.BMP');r=double(A(:,:,1));g=double(A(:,:,2));b=double(A(:,:,3));[m,n]=size(r);bw=zeros(m,n);bw=0.3.*r+0.59.*g+0.11.*b;subplot(2,2,1)imshow(mat2gray(bw));title('加权法,其实我们的rgb2gray就是默认的加权法')bw1=zeros(m,n);bw1=(r+g+b)./3;subplot(2,2,2)imshow(mat2gray(bw1));title('均值法')bw2=zeros(m,n);for i=1:m for j=1:n bw2(i,j)=max(max(r(i,j),g(i,j)),b(i,j)); endendsubplot(2,2,3)imshow(mat2gray(bw2));title('最大值法')
转载于:https://www.cnblogs.com/natalie/p/4568609.html
相关资源:MATLAB实现彩色图像转化为灰度图像
转载请注明原文地址: https://win8.8miu.com/read-1499701.html