波形图
代码如下:
WaveForm_R=zeros(300,n,3);
WaveForm_G=zeros(300,n,3);
WaveForm_B=zeros(300,n,3);
for i=1:m
for j=1:n
WaveForm_R(uint8(R(i,j)+1)+50,j,1)=1;
WaveForm_G(uint8(G(i,j)+1)+50,j,2)=1;
WaveForm_B(uint8(B(i,j)+1)+50,j,3)=1;
end
end
subplot(2,2,1),imshow(imresize(src_img,[300,n]));title('原图');
subplot(2,2,2),imshow(WaveForm_R);title('WaveForm R');
subplot(2,2,3),imshow(WaveForm_G);title('WaveForm G');
subplot(2,2,4),imshow(WaveForm_B);title('WaveForm B');
效果如下:
直方图
代码如下:
CountR=zeros(256,1);
CountG=zeros(256,1);
CountB=zeros(256,1);
for i=1:m
for j=1:n
CountR(uint8(R(i,j)+1)) = CountR(uint8(R(i,j)+1))+1;
CountG(uint8(G(i,j)+1)) = CountG(uint8(G(i,j)+1))+1;
CountB(uint8(B(i,j)+1)) = CountB(uint8(B(i,j)+1))+1;
end
end
MaxCountR=max(CountR);
MaxCountG=max(CountG);
MaxCountB=max(CountB);
HistR=CountR./MaxCountR;
HistG=CountG./MaxCountG;
HistB=CountB./MaxCountB;
x=1:256;
subplot(2,2,1),imshow(src_img);title('原图');
subplot(2,2,2),stem(x,HistR,'R');title('红色分量');
subplot(2,2,3),stem(x,HistG,'G');title('绿色分量');
subplot(2,2,4),stem(x,HistB,'B');title('蓝色分量');
效果如下:
矢量图
代码如下:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%读取新的图像
src_img=imread('brightness-slider.png');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%取出RGB分量
[m n dim]=size(src_img);
R=src_img(:,:,1);
G=src_img(:,:,2);
B=src_img(:,:,3);
R=double(R);
G=double(G);
B=double(B);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RGB2YUV=[0.2990 0.5870 0.1140;
-0.1687 -0.3313 0.500;
0.5000 -0.4187 -0.0813];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%转换成YCbCr形式
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%读取向量图
bkg_img=imread('graticule.png');
[h w d]=size(bkg_img);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Y=zeros(m,n);
U=zeros(m,n);
V=zeros(m,n);
for i=1:m
for j=1:n
temp=RGB2YUV*[R(i,j) G(i,j) B(i,j)]';
Y(i,j)=temp(1);
U(i,j)=temp(2);
V(i,j)=temp(3);
bkg_img(uint8(w/2-V(i,j)),uint8(U(i,j)+h/2),1)=uint8(R(i,j));
bkg_img(uint8(w/2-V(i,j)),uint8(U(i,j)+h/2),2)=uint8(G(i,j));
bkg_img(uint8(w/2-V(i,j)),uint8(U(i,j)+h/2),3)=uint8(B(i,j));
end
end
subplot(1,2,1),imshow(src_img);
subplot(1,2,2),imshow(bkg_img);
效果如下:
欢迎点赞收藏