我在版本6.5中得到不同的結果7.5。下面是6.5結果值在matlab 6.5和7.5中編譯時發生變化
corr_a1=[10 49 1 25 6 3 47 4475 20 2017 14 23 3 29 9 47 4 5 21 2019 53 6280 23 26 0 23 8 17 907 13 13 19 5 18 14 10 ];
的結果,這裏的7.5
corr_a1=[6 17 0 14 3 7 18 5242 3 1271 3 7 1 4 3 14 0 0 13 1289 15 7353 17 11 2 14 1 8 893 0 7 8 0 8 2 2 ];
我的代碼,結果如下:
img1=imread(fn);%reading image
img=imresize(img1,[128 128]);
img=double(img);
img_red=img(:,:,1);
img1_red=repmat(img_red,[1 1 3]);
img_green=img(:,:,2);
img1_green=repmat(img_green,[1 1 3]);
img_blue=img(:,:,3);
img1_blue=repmat(img_blue,[1 1 3]);
siz=size(img);
%initialising color categories for image
r_maxb_min=zeros(siz);
r_maxg_min=zeros(siz);
g_maxr_min=zeros(siz);
g_maxb_min=zeros(siz);
b_maxr_min=zeros(siz);
b_maxg_min=zeros(siz);
%1=RmaxGmin
%2=RmaxBmin
%3=GmaxGmin
%4=GmaxBmin
%5=BmaxRmin
%6=BmaxGmin
%representation of image with color categories
for row=1:siz(1)
for col=1:siz(2)
r=img_red(row,col);
g=img_green(row,col);
b=img_blue(row,col);
a1=[r,g,b];
if (max(a1)==r) & (min(a1)==g)
r_maxg_min(row,col)=r_maxg_min(row,col)+img(row,col);
img(row,col)=1;
elseif (max(a1)==r) & (min(a1)==b)
r_maxb_min(row,col)=r_maxb_min(row,col)+img(row,col);
img(row,col)=2;
end
end
end
for row1=1:siz(1)
for col1=1:siz(2)
r1=img_red(row1,col1);
g1=img_green(row1,col1);
b1=img_blue(row1,col1);
a2=[r1,g1,b1];
if (max(a2)==g1) & (min(a2)==r1)
g_maxr_min(row1,col1)=g_maxr_min(row1,col1)+img(row1,col1);
img(row1,col1)=3;
elseif (max(a2)==g1) & (min(a2)==b1)
g_maxb_min(row1,col1)=g_maxb_min(row1,col1)+img(row1,col1);
img(row1,col1)=4;
end
end
end
for row2=1:siz(1)
for col2=1:siz(2)
r2=img_red(row2,col2);
g2=img_green(row2,col2);
b2=img_blue(row2,col2);
a3=[r2,g2,b2];
if (max(a3)==b2) & (min(a3)==r2)
b_maxr_min(row2,col2)=b_maxr_min(row2,col2)+img(row2,col2);
img(row2,col2)=5;
elseif (max(a3)==b2) & (min(a3)==g2)
b_maxg_min(row2,col2)=b_maxg_min(row2,col2)+img(row2,col2);
img(row2,col2)=6;
end
end
end
b_maxr_min;
b_maxg_min;
g_maxr_min;
g_maxb_min;
r_maxg_min;
r_maxb_min;
set1=[r_maxg_min r_maxg_min g_maxr_min g_maxb_min b_maxr_min b_maxg_min];
result=img(:,:,1);
siz_res=size(result);
img1;
result;
%constructing color corellogram
max_res=max(max(result));
corr=zeros(max_res,max_res);
dy=1;
dx=0;
for row=1:siz_res(1)-dx
for col=1:siz_res(2)-dy
i=result(row,col);
j=result(row+dx,col+dy);
corr(i,j)=corr(i,j)+1;
end
end
corr;
corr_a1=corr(:)';
請不要發表任何代碼。我們沒有時間閱讀它。如果您有一個能夠再現您的錯誤的最小示例,請將其發佈。 – abcd 2011-04-30 06:31:00