显示RGB三通道的图像
I = imread('..\data\player2.jpg');
figure(1),clf
ax(1)=subplot(2,4,1);imshow(I);
ax(2)=subplot(2,4,2);imshow(I(:,:,1));
ax(3)=subplot(2,4,3);imshow(I(:,:,2));
ax(4)=subplot(2,4,4);imshow(I(:,:,3));
linkaxes(ax);
图像基本处理函数
write
imwrite(f,'filename');
不同通道
im2bw(image)
rgb2hsv(rgbimage)
rgb2ycbcr(rgbimage)
rgb2gray(rgbimage)
直方图
imhist(I); %I为gray图
过滤器
imfilter(I,h);
kernel
h=fspecial('average',hsize)
h=fspecial('gaussian',hsize,sigma)
medfilt2 %good for salt and pepper noise;
Spatial transformation
imrotate(I,angle) %rotation
imcrop(img,[xmin,ymin,width,height]) %region of interest
Arithmetic operation
sum J=imadd(I,50)
subtractions z=imsubtract(x,y)
multiplication z=immultiply(x,y)
z=imdivide(x,y) %division
Edge(边缘)
BW=edge(I,'sobel')%image,method
BW=edge(I,'sobel',Theresh,Direction)
Communication with Camera on windows
(Windows下与摄像头连接)
video input object
vid=videoinput('winvideo',1); %视频输入设备
preview(vid) %查看视频
stoppreview(vid) %暂停
closepreview(vid)
delete(vid); %release memory,at the end
Acquiring Images(camera)
frame=getsnapshot(vid); %Acquiring a frame
pixel=frame(2,3) % Accessing pixel information 1 channel
pixel=frame(2,3,2) 3 chennels
size(frame) %size of the image
imtool(frame) %Display Images
imshow(frame(:,:,2));
“`