❶ 求matlab彩色圖片的顏色特徵提取演算法的代碼,和紋理特徵提取的代碼。傳統方法即可。
其實學數字圖像處理,關鍵的不是源代碼(和一般編程還是有區別的,這個是經驗之談,其實一般博導未必會編程,但是你和他說說你的方法,他一般都能切中要害),而是你能理解基於概念及適用場所。
基於顏色、紋理、形狀都屬於低層特徵,這些你理解就夠了,關鍵是對你的課題適合哪種方法來映射到高層語義上面,例如:識別物體輪廓,那可能形狀就比較適合等。
我之所以寫上面那段話,主要是我感覺你索取代碼也不說明具體要求,也就是方向不明確。
如今顏色特徵提取演算法有很多,諸如顏色直方圖、顏色矩、顏色集、顏色聚合向量、顏色相關圖等,既然你沒說,我就給個IEEE CSVT 2001的一篇關於顏色直方圖法的論文(源碼版權歸作者所有):
function colorhist = colorhist(rgb)
% CBIR_colorhist() --- color histogram calculation
% input: MxNx3 image data, in RGB
% output: 1x256 colorhistogram == (HxSxV = 16x4x4)
% as the MPEG-7 generic color histogram descriptor
% [Ref] Manjunath, B.S.; Ohm, J.-R.; Vasudevan, V.V.; Yamada, A., "Color and texture descriptors"
% IEEE Trans. CSVT, Volume: 11 Issue: 6 , Page(s): 703 -715, June 2001 (section III.B)
% check input
if size(rgb,3)~=3
error('3 components is needed for histogram');
end
% globals
H_BITS = 4; S_BITS = 2; V_BITS = 2;
%rgb2hsv可用rgb2hsi代替,見你以前的提問。
hsv = uint8(255*rgb2hsv(rgb));
imgsize = size(hsv);
% get rid of irrelevant boundaries
i0=round(0.05*imgsize(1)); i1=round(0.95*imgsize(1));
j0=round(0.05*imgsize(2)); j1=round(0.95*imgsize(2));
hsv = hsv(i0:i1, j0:j1, :);
% histogram
for i = 1 : 2^H_BITS
for j = 1 : 2^S_BITS
for k = 1 : 2^V_BITS
colorhist(i,j,k) = sum(sum( ...
bitshift(hsv(:,:,1),-(8-H_BITS))==i-1 &...
bitshift(hsv(:,:,2),-(8-S_BITS))==j-1 &...
bitshift(hsv(:,:,3),-(8-V_BITS))==k-1 ));
end
end
end
colorhist = reshape(colorhist, 1, 2^(H_BITS+S_BITS+V_BITS));
% normalize
colorhist = colorhist/sum(colorhist);
%基於紋理特徵提取灰度共生矩陣用於紋理判斷
% Calculates cooccurrence matrix
% for a given direction and distance
%
% out = cooccurrence (input, dir, dist, symmetric);
%
% INPUT:
% input: input matrix of any size
%
% dir: direction of evaluation
% "dir" value Angle
% 0 0
% 1 -45
% 2 -90
% 3 -135
% 4 -180
% 5 +135
% 6 +90
% 7 +45
%
% dist: distance between pixels
%
% symmetric: 1 for symmetric version
% 0 for non-symmetric version
%
% eg: out = cooccurrence (input, 0, 1, 1);
% Author: Baran Aydogan (15.07.2006)
% RGI, Tampere University of Technology
% [email protected]
function out = cooccurrence (input, dir, dist, symmetric);
input = round(input);
[r c] = size(input);
min_intensity = min(min(input));
max_intensity = max(max(input));
out = zeros(max_intensity-min_intensity+1);
if (dir == 0)
dir_x = 0; dir_y = 1;
end
if (dir == 1)
dir_x = 1; dir_y = 1;
end
if (dir == 2)
dir_x = 1; dir_y = 0;
end
if (dir == 3)
dir_x = 1; dir_y = -1;
end
if (dir == 4)
dir_x = 0; dir_y = -1;
end
if (dir == 5)
dir_x = -1; dir_y = -1;
end
if (dir == 6)
dir_x = -1; dir_y = 0;
end
if (dir == 7)
dir_x = -1; dir_y = 1;
end
dir_x = dir_x*dist;
dir_y = dir_y*dist;
out_ind_x = 0;
out_ind_y = 0;
for intensity1 = min_intensity:max_intensity
out_ind_x = out_ind_x + 1;
out_ind_y = 0;
[ind_x1 ind_y1] = find (input == intensity1);
ind_x1 = ind_x1 + dir_x;
ind_y1 = ind_y1 + dir_y;
for intensity2 = min_intensity:max_intensity
out_ind_y = out_ind_y + 1;
[ind_x2 ind_y2] = find (input == intensity2);
count = 0;
for i = 1:size(ind_x1,1)
for j = 1:size(ind_x2,1)
if ( (ind_x1(i) == ind_x2(j)) && (ind_y1(i) == ind_y2(j)) )
count = count + 1;
end
end
end
out(out_ind_x, out_ind_y) = count;
end
end
if (symmetric)
if (dir < 4)
dir = dir + 4;
else
dir = mod(dir,4);
end
out = out + cooccurrence (input, dir, dist, 0);
end
❷ MATLAB 圖像分割的 分水嶺演算法 的源代碼,麻煩有的人發一份給我,謝謝
直方圖均衡化也是非線性量化的一種吧,網上找到的,作者寫的非常詳細。
% 數字圖像處理程序作業
% 本程序能將JPG格式的彩色圖像文件灰度化並進行直方圖均衡
%
% 輸入文件:PicSample.jpg 待處理圖像
% 輸出文件:PicSampleGray.bmp 灰度化後圖像
% PicEqual.bmp 均衡化後圖像
%
% 輸出圖形窗口說明
% figure NO 1 待處理彩色圖像
% figure NO 2 灰度化後圖像
% figure NO 3 直方圖
% figure NO 4 均衡化後直方圖
% figure NO 5 灰度變化曲線
% figure NO 6 均衡化後圖像
% 1, 處理的圖片名字要為 PicSample.jpg
% 2, 程序每次運行時會先清空workspace
% 作者;archiless lorder
clear all
%一,圖像的預處理,讀入彩色圖像將其灰度化
PS=imread('PicSample.jpg'); %讀入JPG彩色圖像文件
imshow(PS) %顯示出來 figure NO 1
title('輸入的彩色JPG圖像')
imwrite(rgb2gray(PS),'PicSampleGray.bmp'); %將彩色圖片灰度化並保存
PS=rgb2gray(PS); %灰度化後的數據存入數組
figure,imshow(PS) %顯示灰度化後的圖像,也是均衡化前的樣品 figure NO 2
title('灰度化後的圖像')
%二,繪制直方圖
[m,n]=size(PS); %測量圖像尺寸參數
GP=zeros(1,256); %預創建存放灰度出現概率的向量
for k=0:255
GP(k+1)=length(find(PS==k))/(m*n); %計算每級灰度出現的概率,將其存入GP中相應位置
end
figure,bar(0:255,GP,'g') %繪制直方圖 figure NO 3
title('原圖像直方圖')
xlabel('灰度值')
ylabel('出現概率')
%三,直方圖均衡化
S1=zeros(1,256);
for i=1:256
for j=1:i
S1(i)=GP(j)+S1(i); %計算Sk
end
end
S2=round(S1*256); %將Sk歸到相近級的灰度
for i=1:256
GPeq(i)=sum(GP(find(S2==i))); %計算現有每個灰度級出現的概率
end
figure,bar(0:255,GPeq,'b') %顯示均衡化後的直方圖 figure NO 4
title('均衡化後的直方圖')
xlabel('灰度值')
ylabel('出現概率')
figure,plot(0:255,S2,'r') %顯示灰度變化曲線 figure NO 5
legend('灰度變化曲線')
xlabel('原圖像灰度級')
ylabel('均衡化後灰度級')
%四,圖像均衡化
PA=PS;
for i=0:255
PA(find(PS==i))=S2(i+1); %將各個像素歸一化後的灰度值賦給這個像素
end
figure,imshow(PA) %顯示均衡化後的圖像 figure NO 6
title('均衡化後圖像')
imwrite(PA,'PicEqual.bmp');
❸ 如何將這段圖像處理演算法轉化為matlaB代碼
org=imread('37_3.bmp');
result=smoothedfilter(org);
subplot(2,2,1);imshow(org);title('原圖');
subplot(2,2,2);imshow(result);title('平滑過濾之後');
h=ones(3,3)./9;
y=filter2(h,org);
y=uint8(y);
subplot(2,2,3);imshow(y);title('filter2中值過濾之後');
y=imfilter(org,h);
subplot(2,2,4);imshow(y);title('imfilter中值過濾之後');
❹ 數字圖像處理 圖像縮放以及旋轉的演算法代碼
clearall;
I=imread('lena.bmp');
figure;imshow(I);title('原圖像');
[m,n]=size(I);
%%%縮小臨近法
M=0.5;%放大倍數
%新的圖像大小
m1=m*M;n1=n*M;
%****************************************************
fori=1:m1
forj=1:n1;
J(i,j)=I(round(i/M),round(j/M));
end
end
%*****************************************************
figure;imshow(J);title('縮小圖像');
%%%放大雙線性插值法
I2=double(I);
N=1.5;%放大倍數
%新的圖像大小
m2=m*N;n2=n*N;
J2=zeros(m2,n2);
fori=1:m2
forj=1:n2
x=i/N;
y=j/N;
u=floor(x);
v=floor(y);
a=x-u;
b=y-v;
ifu+2<=m&v+2<=n
J2(i,j)=I2(u+1,v+1)*(1-a)*(1-b)+I2(u+2,v+1)*a*(1-b)+I2(u+1,v+2)*(1-a)*b+I2(u+2,v+2)*a*b;
end
end
end
J2=uint8(J2);
figure;imshow(J2);title('放大圖像');
%%%%%旋轉
R=45*pi/180;%旋轉角度
I=double(I);
%新圖像大小
m2=ceil(m*cos(R)+n*sin(R));
n2=ceil(m*sin(R)+n*cos(R));
u0=m*sin(R);%平移量
%變換矩陣
T=[cos(R),sin(R);-sin(R),cos(R)];
L=zeros(m2,n2);
foru=1:n2
forv=1:m2
%新圖像坐標變換到原圖像坐標x和y中
temp=T*([u;v]-[u0;0]);
x=temp(1);
y=temp(2);
ifx>=1&x<=m&y>=1&y<=n%若變換出的x和y在原圖像范圍內
x_low=floor(x);
x_up=ceil(x);
y_low=floor(y);
y_up=ceil(y);
%雙線性插值,p1到p4是(x,y)周圍的四個點
p1=I(x_low,y_low);
p2=I(x_up,y_low);
p3=I(x_low,y_low);
p4=I(x_up,y_up);
s=x-x_low;
t=y-y_low;
L(u,v)=(1-s)*(1-t)*p1+(1-s)*t*p3+(1-t)*s*p2+s*t*p4;
end
end
end
L=uint8(L);
figure;imshow(L);
❺ C#數字圖像處理演算法典型實例的介紹
《C#數字圖像處理演算法典型實例(附光碟)》精選數字圖像處理領域中的一些應用實例,以理論和實踐相結合的方式,系統地介紹了如何使用C#進行數字圖像處理。 共11章,分別講述了圖像的點運算、幾何運算、數學形態學圖像處理方法、頻率變換、圖像平滑與去噪、邊緣檢測、圖像分割、圖像壓縮編碼和彩色圖像處理等相關技術。《C#數字圖像處理演算法典型實例(附光碟)》的光碟中附有相關章節的實現代碼,可供廣大的讀者參考、閱讀。
❻ 數字圖像處理clean演算法的MATLAB代碼
圖像去噪是數字圖像處理中的重要環節和步驟。去噪效果的好壞直接影響到後續的圖像處理工作如圖像分割、邊緣檢測等。圖像信號在產生、傳輸過程中都可能會受到雜訊的污染,一般數字圖像系統中的常見雜訊主要有:高斯雜訊(主要由阻性元器件內部產生)、椒鹽雜訊(主要是圖像切割引起的黑圖像上的白點雜訊或光電轉換過程中產生的泊松雜訊)等;
目前比較經典的圖像去噪演算法主要有以下三種:
均值濾波演算法:也稱線性濾波,主要思想為鄰域平均法,即用幾個像素灰度的平均值來代替每個像素的灰度。有效抑制加性雜訊,但容易引起圖像模糊,可以對其進行改進,主要避開對景物邊緣的平滑處理。
中值濾波:基於排序統計理論的一種能有效抑制雜訊的非線性平滑濾波信號處理技術。中值濾波的特點即是首先確定一個以某個像素為中心點的鄰域,一般為方形鄰域,也可以為圓形、十字形等等,然後將鄰域中各像素的灰度值排序,取其中間值作為中心像素灰度的新值,這里領域被稱為窗口,當窗口移動時,利用中值濾波可以對圖像進行平滑處理。其演算法簡單,時間復雜度低,但其對點、線和尖頂多的圖像不宜採用中值濾波。很容易自適應化。 Wiener維納濾波:使原始圖像和其恢復圖像之間的均方誤差最小的復原方法,是一種自適應濾波器,根據局部方差來調整濾波器效果。對於去除高斯雜訊效果明顯。
實驗一:均值濾波對高斯雜訊的效果
I=imread('C:\Documents and Settings\Administrator\桌面\1.gif');%讀取圖像
❼ C#數字圖像處理演算法典型實例的編輯推薦
48種典型演算法,涵蓋C#數字圖像處理的常用領域,50個典型實例,詳細講解其實現過程和實現效果,附贈本書全部源代碼,可直接用於工程實踐。
《C#數字圖像處理演算法典型實例》詳細講解了C#數字圖像處理的常用演算法。
❽ 去哪找圖像處理經典演算法的代碼matlab
有一本專門介紹matlab圖像處理的書,很厚,原價大概80多,你可以去書店看看。
如果你英文好的話,去官網下相關pdf文檔就行,很多中文書籍都是根據這個寫的,有些乾脆就是翻譯一下
❾ C#數字圖像處理演算法典型實例代碼
我有,巧了,買來還沒怎麼看過。當當買的。
發了。