|
@@ -1,204 +0,0 @@
|
|
|
-clear all;
|
|
|
-
|
|
|
-images={'eiffel2';'carfront'}
|
|
|
-dc1=[1 1]
|
|
|
-dc2=[1 1];
|
|
|
-dim=131;
|
|
|
-smooth=1;
|
|
|
-
|
|
|
-
|
|
|
-th=linspace(-pi,pi,17); % angles
|
|
|
-th=fliplr(th);
|
|
|
-th=th(1:end-1);
|
|
|
-%degax=rad2deg([th th]); % for plots
|
|
|
-romat=zeros(dim,dim,length(th),length(images));
|
|
|
-
|
|
|
-
|
|
|
-for img=1:length(images)
|
|
|
-
|
|
|
- %get image
|
|
|
- A1 = imread([images{img} '.bmp']);
|
|
|
- A1 = mean(A1(:,:,:),3);
|
|
|
- %place it
|
|
|
- quafig=zeros(dim,dim);
|
|
|
- pl=round(([dim+1 dim+1]-size(A1))/2);
|
|
|
- quafig(pl(1):end-pl(1)+dc1(img),pl(2):end-pl(2)+dc2(img))=A1;
|
|
|
- % if img==1
|
|
|
- quafig(quafig>=230)=0;
|
|
|
- % end
|
|
|
- %figure; imagesc(quafig);
|
|
|
-
|
|
|
- %% display area / circle
|
|
|
- sz=floor(dim/2);
|
|
|
- [x y] = meshgrid(-sz:sz,-sz:sz);
|
|
|
- oc = NaN(size(x));
|
|
|
- oc((x.^2+y.^2)<(dim/2)^2)=1; % radius outrad, center at the origin
|
|
|
- %% Gaussian smoothing kernel
|
|
|
- f=exp(-x.^2/(2*smooth^2)-y.^2/(2*smooth^2));
|
|
|
- quafig=conv2(quafig,f,'same');
|
|
|
- quafig=quafig./max(max(quafig));
|
|
|
- %% rotate
|
|
|
- figure;
|
|
|
- mid=round(dim./2);
|
|
|
- for t=1:length(th)
|
|
|
- for i=1:size(quafig,1)
|
|
|
- for j=1:size(quafig,2)
|
|
|
-
|
|
|
- x= (i-mid)*cos(th(t))+(j-mid)*sin(th(t));
|
|
|
- y=-(i-mid)*sin(th(t))+(j-mid)*cos(th(t));
|
|
|
- x=round(x)+mid;
|
|
|
- y=round(y)+mid;
|
|
|
-
|
|
|
- if (x>=1 && y>=1 && x<=size(quafig,2) && y<=size(quafig,1))
|
|
|
- romat(i,j,t,img)=quafig(x,y); % k degrees rotated image
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
-% subplot(4,4,t);
|
|
|
-% imagesc(romat(:,:,t,img));
|
|
|
- end
|
|
|
-end
|
|
|
-
|
|
|
-combat=cat(3,romat(:,:,:,1),romat(:,:,:,2));
|
|
|
-tmpsizer=size(romat);
|
|
|
-combat=reshape(romat,[tmpsizer(1:2) tmpsizer(3)*tmpsizer(4)]);
|
|
|
-nth=[th th];
|
|
|
-%% distance (inner product)
|
|
|
-for i=1:length(nth)
|
|
|
- for j=1:length(nth)
|
|
|
- ith=reshape(combat(:,:,i).*oc,[dim*dim 1]);
|
|
|
- jth=reshape(combat(:,:,j).*oc,[dim*dim 1]);
|
|
|
- ith=ith(~isnan(ith));
|
|
|
- jth=jth(~isnan(jth));
|
|
|
- dist(i,j)=1-corr(ith,jth);
|
|
|
- if i==j
|
|
|
- dist(i,j)=0;
|
|
|
- acdist(i,j)=0;
|
|
|
- end
|
|
|
- acdist(i,j)=abs(angdiff(nth(i),nth(j)));
|
|
|
- if (i>length(th) & j<=length(th)) | (j>length(th) & i<=length(th))
|
|
|
- %acdist(i,j)=0 ; acdist(i,j);
|
|
|
- dist(i,j)=dist(i,j)+0.2;
|
|
|
- end
|
|
|
- %dist(i,j)=nansum(nansum(combat(:,:,i).*combat(:,:,j).*oc));
|
|
|
- end
|
|
|
-end
|
|
|
-figure;
|
|
|
-dotsize=50
|
|
|
-
|
|
|
-% concrete
|
|
|
-ax1=subplot(2,4,1)
|
|
|
-imagesc(dist);axis off; hold on; qlines(th)
|
|
|
-colormap(ax1,'parula')
|
|
|
-
|
|
|
-% ax3=subplot(2,4,6)
|
|
|
-% [Y,e] = cmdscale(dist,3);
|
|
|
-% Y1=Y(1:length(th),:);
|
|
|
-% c = linspace(1,64,length(Y1));
|
|
|
-% scatter3(Y1(:,1),Y1(:,2),Y1(:,3),dotsize,c); hold on
|
|
|
-% Y2=Y(length(th)+1:end,:);
|
|
|
-% scatter3(Y2(:,1),Y2(:,2),Y2(:,3),dotsize,c,'filled');
|
|
|
-% colormap(ax3,'hsv')
|
|
|
-
|
|
|
-% abstract continuous
|
|
|
-subplot(2,4,2)
|
|
|
-imagesc(acdist); axis off; hold on; qlines(th);
|
|
|
-% [Y,e] = cmdscale(acdist,3);
|
|
|
-% ax4=subplot(4,4,5)
|
|
|
-% Y1=Y(1:length(th),:);
|
|
|
-% scatter3(Y1(:,1),Y1(:,2),Y1(:,3),dotsize,c); hold on
|
|
|
-% Y2=Y(length(th)+1:end,:);
|
|
|
-% scatter3(Y2(:,1),Y2(:,2),Y2(:,3),dotsize,c,'filled');
|
|
|
-% colormap(ax4,'hsv');
|
|
|
-%xlim([-2 2]); ylim([-2 2]); zlim([-2 2]);
|
|
|
-
|
|
|
-% if length(th)==4
|
|
|
-% ax5=subplot(4,4,3); % abstract-idiosyncratic
|
|
|
-% %x=randn(1,xs); x=x-min(x); x=x./max(x);
|
|
|
-% xs=length(th);
|
|
|
-% x=[2 1.3 7 5]; x=x-min(x); x=x./max(x);
|
|
|
-% y=x+rand(1,xs).*0.3; y=y-min(y); y=y./max(y);
|
|
|
-% x=[x y];
|
|
|
-% rdm=NaN(length(x),length(x));
|
|
|
-% for i=1:length(x)
|
|
|
-% for j=1:length(x)
|
|
|
-% rdm(i,j)=abs(x(i)-x(j));
|
|
|
-% if abs(i-j)>xs
|
|
|
-% rdm(i,j)=rdm(i,j)+rand.*0.5;
|
|
|
-% end
|
|
|
-% end
|
|
|
-% end
|
|
|
-% tmp=squareform(rdm);
|
|
|
-% tmpreg=squareform(dist);
|
|
|
-% tmp=tmp-min(tmp); tmp=tmp./max(tmp);
|
|
|
-% [b,dev,stats]=glmfit(tmpreg,tmp);
|
|
|
-% tmp=stats.resid;
|
|
|
-% tmp=tmp-min(tmp); tmp=tmp./max(tmp);
|
|
|
-% rdm=squareform(tmp)
|
|
|
-% imagesc(rdm); axis off; hold on; qlines(th);
|
|
|
-%
|
|
|
-% ax6=subplot(4,4,6)
|
|
|
-% [Y,e] = cmdscale(rdm,3);
|
|
|
-% Y1=Y(1:length(th),:);
|
|
|
-% scatter3(Y1(:,1),Y1(:,2),Y1(:,3),dotsize,c); hold on
|
|
|
-% Y2=Y(length(th)+1:end,:);
|
|
|
-% scatter3(Y2(:,1),Y2(:,2),Y2(:,3),dotsize,c,'filled');
|
|
|
-% colormap(ax6,'hsv');
|
|
|
-% %xlim([-2 2]); ylim([-2 2]); zlim([-2 2]);
|
|
|
-% end
|
|
|
-
|
|
|
-
|
|
|
-tmpreg1=squareform(dist);
|
|
|
-tmpreg2=squareform(acdist);
|
|
|
-[Rho p]=corr(tmpreg1',tmpreg2');
|
|
|
-
|
|
|
-% abstract discrete (tbd)
|
|
|
-quadrlth=(length(th)^2-length(th))./2;
|
|
|
-rand(quadrlth,1);
|
|
|
-
|
|
|
-
|
|
|
-X=[]; Y=[]; noiser=0.1
|
|
|
-for i=1:length(th)
|
|
|
- a=rad2deg(th(i));
|
|
|
- X(i,1)=double(abs(a)<90)+randn*noiser; % left/right
|
|
|
- X(i,2)=double(a<0)+randn.*noiser; % upside-down
|
|
|
- % X(i,3)=abs(angdiff(th(i).*4,0))./pi+randn*noiser; % cardinal/diagonal
|
|
|
- X(i,3)=abs(angdiff(th(i).*2,0))./pi+randn*noiser; % standing (hanging) / lying on side
|
|
|
- Y(i,1)=double(abs(a)<90)+randn*noiser; % left/right
|
|
|
- Y(i,2)=double(a<0)+randn*noiser; % upside-down
|
|
|
- %Y(i,3)=abs(angdiff(th(i).*4,0))./pi+randn*noiser; % cardinal/diagonal
|
|
|
- Y(i,3)=abs(angdiff(th(i).*2,0))./pi+randn*noiser; % standing (hanging) / lying on side
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-end
|
|
|
-X=[X; Y];
|
|
|
-d=pdist(X);
|
|
|
-
|
|
|
-[b,dev,stats] = glmfit([tmpreg1' tmpreg2'],d');
|
|
|
-d=stats.resid;
|
|
|
-d=d-min(min(d));
|
|
|
-d=d./max(max(d));
|
|
|
-
|
|
|
-rdm=squareform(d);
|
|
|
-subplot(2,4,3); imagesc(rdm); axis off; hold on; qlines(th);
|
|
|
-% ax6=subplot(4,4,6)
|
|
|
-% [Y,e] = cmdscale(rdm,3);
|
|
|
-% Y1=Y(1:length(th),:);
|
|
|
-% scatter3(Y1(:,1),Y1(:,2),Y1(:,3),dotsize,c); hold on
|
|
|
-% Y2=Y(length(th)+1:end,:);
|
|
|
-% scatter3(Y2(:,1),Y2(:,2),Y2(:,3),dotsize,c,'filled');
|
|
|
-% colormap(ax6,'hsv');
|
|
|
-
|
|
|
-% subplot(2,4,9); imagesc(1); colorbar;
|
|
|
-
|
|
|
-
|
|
|
-% %%
|
|
|
-% % alltogether
|
|
|
-% allX=[X.*2+0.5 cmdscale(acdist).*2 cmdscale(dist)];
|
|
|
-% d=squareform(pdist(allX));
|
|
|
-% subplot(2,4,9);imagesc(d);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|