1. 程式人生 > 實用技巧 >機器視覺與影象處理

機器視覺與影象處理

第一章:
1)數字影象
簡單地說,數字影象就是能夠在計算機上顯示和處理的影象,根據其特性可分為兩大類一點陣圖和向量圖。
2)數字影象的儲存格式
BMP,TIFF,GIF,JPG(JPEG)
3) 彩色編碼
RGB(紅綠藍),CMYK(青色,品紅色,黃色,黑色),HSV也稱HSI(色調,飽和度,亮度值)

第二章:
1)命令列操作
如果在每行命令的結尾輸入半形分號(;),則命令窗 口不會立即顯示命令執行的結果,而會將結果儲存在工作區中,再次提示符下輸入變數名稱res,得到結果
2) 跨行語句
Matlab允許在同一行中輸入多條語句,之間用分號隔開。同時,Matlab還允許將同一條 語句分割在多行中書寫以方便閱讀較長的語句,方法是在行末使用三個半形圓點

在這裡插入圖片描述
3)MATLAB的百分比符號(%)是用於表示一個註釋行
4)建立向量
在這裡插入圖片描述
5)常見命令
在這裡插入圖片描述
6)if…else,switch…case語句
//if …else
%This is a if
arg=input(‘Please input a argument:’);
if(arg>5)
disp(‘The is a more 5’);
elseif(arg<5)
disp(‘The is a less 5’);
else
disp(‘The is equal 5’);
end

//switch case
This is swith testW
yjl = input(‘please input a argument’);

switch (yjl)
case 0
disp(‘yjl = 0!’);
case 1
disp(‘yjl = 1’);
case 2
disp(‘yjl = 2’);
otherwise
disp(‘yjl unkonwn’);
end
7)函式
function maxyjl = mymax(in1,in2,in3,in4,in5)
%This is my function
%這是我定義的函式
maxyjl = in1;
if(in2>maxyjl)
maxyjl = in2;
end
if(in3>maxyjl)
maxyjl = in3;
end
if(in4>maxyjl)
maxyjl = in4;
end
if(in5>maxyjl)
maxyjl = in5;
end
end
8)資料匯入、圖片匯入
//資料匯入
A = importdata(‘autumn.tif’)
//圖片匯入
A = imread(‘autumn.tif’)
//寫入到圖片(將圖片資料寫入到檔案中)
A = importdata(‘autumn.tif’)
imwrite(A,‘yjl.tif’)
//圖片顯示
imshow(A)
//在不同的視窗顯示
figure //新建一個視窗
imshow(A)
//在相同的視窗顯示
figure
subplot(m,n,p) //開啟一個m行n列影象位置的視窗,焦點與第p個位置 p值越大越精準
imshow(A)
//調整圖片亮度
A = A.*0.25 //圖片變暗
A = A.*100 //圖片變亮
//畫素值檢視工具
impixelinfo

第三章
1)4-鄰域,對角鄰域,8-鄰域
在這裡插入圖片描述
在這裡插入圖片描述
第四章
直方圖處理
在這裡插入圖片描述
歸一化直方圖在這裡插入圖片描述
在這裡插入圖片描述
在這裡插入圖片描述