1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| function generate_markers(class_map,nb_mark,N,i,nb_map,Imshort)
dim=size(class_map);
marker_map=zeros(dim);
%c%Pour quoi faire un while plutôt qu'un FOR ?
%c%Je ne pense pas que ça change beaucoup de chose au niveau timing mais c'est plus propre
%c%k=0;
for k = 1:nb_mark
%c%note : le paramètre k ne sert pas vraiment donc de 1 à nb_mark est pareil que de 0 à nb_mark-1
%c%while k<nb_mark
x=floor(dim(1)*rand+1);
y=floor(dim(2)*rand+1);
%with this little test, it is sure that the correct number of markers
%is computed -> impossible to have the same marker twice
if marker_map(x,y)==0
marker_map(x,y)=class_map(x,y);
%c%k=k+1;
end
end
%% filling the file in a compatible format for the MSF software
%c%Pour l'écriture du fichier voir les faq données à la suite
%c%fid=fopen(['../results/' Imshort '/' Imshort '_' int2str(nb_map) '_MSF_' int2str(nb_mark) '/marker_map_' int2str(nb_mark) '_' int2str(i) '.marker'],'wt');
fichier = fullfile('..','results',Imshort,sprintf('%s_%d_MSF_%d',Imshort,nb_map,nb_mark),sprintf('Marker_map_%d_%d.marker',nb_mark,i));
fir = fopen(fichier,'wt');
fprintf(fid,'%d\n',nb_class);
for i=1:dim(1)
fprintf(fid,'%d ',marker_map(i,:));
fprintf(fid,'\n');
end
vect_class = 1:nb_class;
fprintf(fid,'\n');
%c%drôle d'écriture
%c%fprintf(fid,'%d ',vect_class(:,:));
fprintf(fid,'%d ',vect_class');
fprintf(fid,'\n');
fclose(fid);
end |
Partager