Open 213cy opened 9 years ago
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% 准备图片 第一种方法 生成 C ,D %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% A=imread('xi.jpg','jpg'); B=rgb2gray(A); C=B; %imshow(B) %imshow(b) %% n=6; bb=sort(B(:)); N=length(bb); bind=linspace(1,N,n); tick=bb(ceil(bind)); %% val=[3 5 4 2 0]; %val=0:4; for k=1:n-1 C( tick(k)<=B & B<tick(k+1) )=val(k); end C( B==tick(n) )=val(k); imshow(C,[]) %% D=rot90(C,3); imshow(D,[])
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% 准备图片 第二种方法 生成 D %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% sqrt((7692-69)/7) sqrt((116556-69)/7) %% A=imread('00.jpg','jpg'); A=imresize(A,[129,129]); B=rgb2gray(A); %% C=double(B)/255; bb=sort(C(:)); bind=linspace(0,1,7); N=length(bb); %% % for k=2:7 % bb(ceil(N_bind(k))) % C(C<=bb(ceil(N_bind(k))))=9-k; % end %D=rot90(C-2,3); %% C=double(B)/255; C(C<=0)=5; C(C<=127/256)=4; C(C<=255/256)=2; C(C<=1)=0; D=rot90(C,3); %% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % imshow(D,[]) % imshow(B,[]) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
示例图片 xi.jpg 00.jpg 0.jpg
用地形装饰物构成简笔画
A=imread('y4','jpg');
B=rgb2gray(A);
% imshow(B)
%%
% imcontrast
% graythresh(B)
% BW = imbinarize(B);
% C = imbinarize(B,100/255);
C = imbinarize(B, 'adaptive','Sensitivity',0.4,'ForegroundPolarity','dark');
% imshow(C)
D = ~bwareafilt(~C, 7);
% imshow(D)
% D3 = ~bwareaopen(~C,20);
% imshowpair(C,D,'diff')
SE = strel('diamond',2);
% A= imdilate(D,SE);
A= imerode(D,SE);
imshow(A)
J = imresize(A,0.1);
imshow(J)
%%
[r,c] = find(J==0);
fileID = fopen('war3map.doo','r+');
fseek(fileID, 32, -1);
fwrite(fileID,16*[c';-r'],'2*float',42,'l')
fclose(fileID);
%%
fileID = fopen('war3map.doo','r');
% ftell(fileID)
fseek(fileID, 24, -1);
t_beg=fread(fileID,[2,4],'2*float',42,'l');
% num2hex(single(t_beg))