Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- img00=im2double(imread('m.png'));
- img00 =1-img00;
- img0=padarray(img00(131:3664,98:3631),[6 6],0,'post');
- img1=img0.*0;
- tot=[];
- for rr=-4 %-8:3
- row=[];
- for cc=-4%-11:0
- xx=cc*size(img0,1)+rr;
- if (xx<0), xx=xx+numel(img0); end;
- img1=reshape(img0([1+xx:end 1:xx]),size(img0));
- %img0(1:end-1,1:end-1);
- img=imresize(img1,1/6,'bilinear');
- sz=354/6
- piece=@(r,c) img(sz*r+(1:sz),sz*c+(1:sz));
- %
- crops=cell(10,10,7);
- for r=0:9
- for c=0:9
- [r c]
- crops{r+1,c+1,1}=piece(r,c);
- for rot=(1:6)
- deg=rot*(180/7);
- crops{r+1,c+1,rot+1}=imrotate(crops{r+1,c+1,1},deg,'bilinear','crop');
- end
- end
- end
- row=[row cat(3,crops{1,1,1},crops{1,1,3},crops{1,1,5})];
- %imshow(imresize(cat(3,crops{1,1,1},crops{1,1,3},crops{1,1,5}),4,'nearest'));
- end
- tot=[tot;row];
- end
- % imshow(tot);
- imshow([tot, -.2-tot+cat(3,abs(tot(:,:,2)-tot(:,:,3)),abs(tot(:,:,3)-tot(:,:,1)),abs(tot(:,:,1)-tot(:,:,2)))])
- %%
- rows='0123456789';
- cols='ABCDEFGHIJ';
- % minD=1000000000; % 1 2
- minD=0; %3
- for r=0:9
- for c=0:9
- % [r c]
- for r1=0:9
- for c1=0:9
- for rot=(1:7)
- if (r1==r && c1==c) continue; end
- X=crops{r+1,c+1,1}; %match 1, 3
- % X=fliplr(crops{r+1,c+1,1}); %match 2
- D=sum(max(0,reshape(-.5+abs(X-crops{r1+1,c1+1,rot}),[],1))>0);
- % if (D<minD) % < for 1,2 and > for 3
- if (D>minD) % < for 1,2 and > for 3
- [r+1 c+1 r1+1 c1+1 rot D]
- minr=r+1;minc=c+1;minr1=r1+1;minc1=c1+1;
- minD=D;
- end
- end
- end
- end
- end
- end
- [cols(minc) rows(minr) ' ' cols(minc1) rows(minr1)]
- imshow(img00)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement