當前位置:編程學習大全網 - 源碼下載 - 比如直接源代碼的原則

比如直接源代碼的原則

其實學習數字圖像處理的關鍵不在於源代碼(這和壹般編程還是有區別的。這是壹種體驗。其實壹般的博士生導師不壹定會編程,但是妳跟他講妳的方法,他壹般都會說到點子上),而是說妳能理解概念和適用的地方。

基於顏色、紋理、形狀屬於低級特征,妳懂這些就夠了。關鍵是妳的題目適合用哪種方法映射到高層語義,比如識別壹個物體的輪廓,然後形狀可能更適合。

之所以寫上面那段,主要是覺得妳們對代碼的要求沒有明確具體要求,就是方向不明確。

目前有許多顏色特征提取算法,如顏色直方圖、顏色矩、顏色集、顏色聚合向量、顏色相關圖等。既然妳沒提,我就給妳壹篇IEEE CSVT 2001的顏色直方圖方法的論文(源代碼版權歸作者所有):

函數colorhist = colorhist(rgb)

% CBIR _顏色直方圖計算

%輸入:MxNx3圖像數據,RGB格式

% output:1x 256 color histogram = =(HxSxV = 16x4x 4)

%作為MPEG-7通用顏色直方圖描述符

Manjunath,學士;歐姆,j .-r;瓦蘇代萬;山田,“顏色和紋理描述符”

% IEEE Trans。CSVT,卷:11期:6,頁:703 -715,2006年6月5438+0(第三節。b)

%檢查輸入

如果size(rgb,3)~=3

錯誤(“直方圖需要3個分量”);

結束

%全局

h _ BITS = 4;s _ BITS = 2;v _ BITS = 2;

%rgb2hsv可以換成rgb2hsi,看妳之前的問題。

HSV = uint 8(255 * RGB 2 HSV(RGB));

img size = size(HSV);

%擺脫不相關的界限

i0 = round(0.05 * img size(1));I 1 = round(0.95 * img size(1));

j0 = round(0.05 * img size(2));j 1 = round(0.95 * img size(2));

hsv = hsv(i0:i1,j0:j1,);

%直方圖

對於i = 1 : 2^H_BITS

對於j = 1 : 2^S_BITS

對於k = 1 : 2^V_BITS

colorhist(i,j,k) = sum(sum(...

bitshift(hsv(:,:,1),-(8-H _ BITS))= = I-1 & amp;...

bitshift(hsv(:,:,2),-(8-S _ BITS))= = j-1 & amp;...

bitshift(hsv(:,:,3),-(8-V _ BITS))= = k-1);

結束

結束

結束

color hist = shape(color hist,1,2^(h_bits+s_bits+v_bits));

%正常化

color hist = color hist/sum(color hist);

%基於紋理特征,提取灰度* * *生成矩陣進行紋理判斷。

%計算共生矩陣

%對於給定的方向和距離

%

% out = cooccurrence(輸入,方向,距離,對稱);

%

輸入百分比:

輸入百分比:任意大小的輸入矩陣

%

% dir:評估方向

%“方向”值角度

% 0 0

% 1 -45

% 2 -90

% 3 -135

% 4 -180

% 5 +135

% 6 +90

% 7 +45

%

% dist:像素之間的距離

%

%對稱:對稱版本為1

非對稱版本為% 0

%

% eg: out = cooccurrence (input,0,1,1);

%作者:巴蘭·艾多根(15.07.2006)

% RGI,坦佩雷技術大學

% baran.aydogan@tut.fi

函數out = cooccurrence (input,dir,dist,symmetric);

input = round(輸入);

[r c] =大小(輸入);

min_intensity = min(min(輸入));

max _ intensity = max(max(input));

out =零(max _ intensity-min _ intensity+1);

if (dir == 0)

dir _ x = 0;dir _ y = 1;

結束

if (dir == 1)

dir _ x = 1;dir _ y = 1;

結束

if (dir == 2)

dir _ x = 1;dir _ y = 0;

結束

if (dir == 3)

dir _ x = 1;dir _ y =-1;

結束

if (dir == 4)

dir _ x = 0;dir _ y =-1;

結束

if (dir == 5)

dir _ x =-1;dir _ y =-1;

結束

if (dir == 6)

dir _ x =-1;dir _ y = 0;

結束

if (dir == 7)

dir _ x =-1;dir _ y = 1;

結束

dir _ x = dir _ x * dist

dir _ y = dir _ y * dist

out _ ind _ x = 0;

out _ ind _ y = 0;

對於強度1 =最小強度:最大強度

out _ ind _ x = out _ index+1;

out _ ind _ y = 0;

[ind _ x 1 ind _ y 1]= find(input = = intensity 1);

ind _ x 1 = ind _ x 1+dir _ x;

ind _ y 1 = ind _ y 1+dir _ y;

對於強度2 =最小強度:最大強度

out _ ind _ y = out _ ind _ y+1;

[ind _ x2 ind _ y2]= find(input = = intensity 2);

count = 0;

對於i = 1:size(ind_x1,1)

對於j = 1:size(ind_x2,1)

if((ind _ x 1(I)= = ind _ x2(j))& amp;& amp(ind_y1(i) == ind_y2(j)))

count = count+1;

結束

結束

結束

out(out_ind_x,out _ ind _ y)= count;

結束

結束

if(對稱)

if(dir & lt;4)

dir = dir+4;

其他

dir = mod(dir,4);

結束

out = out + cooccurrence (input,dir,dist,0);

結束

  • 上一篇:辨認照片真假最好用什麽軟件
  • 下一篇:幼兒園專業設計必須要註意到的四個要點
  • copyright 2024編程學習大全網