单片机的U盘读写模块的设计(7)

2019-04-09 12:21

唐 山 学 院 毕 业 设 计

% Get default command line output from handles structure % varargout{1} = handles.output; varargout{1} = handles;

% delete(handles.figure1)%%%%%%%%%%

% --- Executes during object creation, after setting all properties. function listbox1_CreateFcn(hObject, eventdata, handles) % hObject handle to listbox1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

% --- Executes on selection change in listbox1. function listbox1_Callback(hObject, eventdata, handles) % hObject handle to listbox1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % get(handles.figure1,'SelectionType'); index_selected = get(handles.listbox1,'Value'); % file_list = get(handles.listbox1,'String'); filename = handles.ss.sorted_names{index_selected}; handles.ss.filename=[pwd,'\\',filename];

handles.ss.names_disp=handles.ss.sorted_names_disp{index_selected}; handles.ss.imsize=handles.ss.imsize_disp{index_selected}; if index_selected<=handles.ss.cnPiont cd(handles.ss.filename) ss=load_listbox(pwd,handles); handles.ss=ss; handles.ss.IsImage=0;

% filename = handles.ss.sorted_names{index_selected};

26

唐 山 学 院 毕 业 设 计

% handles.ss.filename=[pwd,'\\',filename];

% handles.ss.names_disp=handles.ss.sorted_names_disp{index_selected}; % handles.ss.imsize=handles.ss.imsize_disp{index_selected}; else

handles.ss.IsImage=1; end

guidata(handles.figure1, handles); uiresume(handles.figure1);

function ss=load_listbox(dir_path,handles) cd (dir_path)

dir_struct = dir(dir_path);

[sorted_names1,sorted_index1] = sortrows({dir_struct.name}'); k=max(sorted_index1); if k==2

sorted_names{1}='.'; sorted_names{2}='..'; sorted_names_disp{1}='.'; sorted_names_disp{2}='..'; imsize_disp{1}='null'; imsize_disp{2}='null'; cnPiont=2; else

sorted_names{1}='.'; sorted_names{2}='..'; sorted_names_disp{1}='.'; sorted_names_disp{2}='..'; imsize_disp{1}='null'; imsize_disp{2}='null'; cn=2; for i=1:k

[path,name,ext,ver] = fileparts(sorted_names1{i}); switch ext case '' cn=cn+1;

27

唐 山 学 院 毕 业 设 计

cnarray(cn)=cn;

%sorted_names(cn)=name; sorted_names{cn}=name; sorted_names_disp{cn}=name; %name

imsize_disp{cn}='null'; end end cnPiont=cn; for i=1:k

[path,name,ext,ver] = fileparts(sorted_names1{i}); switch ext

case {'.bmp','.jpg','.jpeg','.tif'} cn=cn+1; cnarray(cn)=cn; name=[name,ext]; sorted_names{cn}=name; temp=imread(name); [m,n]=size(temp); m=num2str(m); n=num2str(n);

imsize=[' ',m,'*',n,' (size)']; name_disp=[name,imsize];

sorted_names_disp{cn}=name_disp; imsize_disp{cn}=imsize; end end end

ss.sorted_names=sorted_names; ss.sorted_names_disp=sorted_names_disp; ss.imsize_disp=imsize_disp; ss.cnPiont=cnPiont;

% handles.file_names = sorted_names; % handles.file_names =sorted_names_disp;

28

唐 山 学 院 毕 业 设 计

% handles.is_dir = [dir_struct.isdir]; % %handles.sorted_index = [sorted_index]; % handles.sorted_index = [cnarray];

set(handles.listbox1,'String',sorted_names_disp,... 'Value',1)

set(handles.text1,'String',pwd)

%检测图像重合

function Q=restore(structure) handles=structure; I=handles.I; J=handles.J; x=handles.out(1); y=handles.out(2); ang=handles.out(3); se = translate(strel(1),[x y]); J = imdilate(J,se);

J = imrotate(J,ang,'nearest','crop'); [m,n]=size(I); I=edge(I,'canny')*255; J=edge(J,'canny')*255; QI=zeros(m,n,3); QJ=zeros(m,n,3); QI(:,:,1)=I; QJ(:,:,2)=J; Q=QI+QJ; Q=uint8(Q);

%计算互信息值 function[mi]=PV(x,y,ang) a=imread('CTcankao1.jpg'); a=double(a);

b=imread('MRfudong2.jpg'); b=double(b);

29

唐 山 学 院 毕 业 设 计

[m,n]=size(a); hab=zeros(256,256); ha=zeros(1,256); hb=zeros(1,256);

if max(max(a))~=min(min(a))

a=(a-min(min(a)))/(max(max(a))-min(min(a))); else

a=zeros(m,n); end

if max(max(b))-min(min(b))

b=(b-min(min(b)))/(max(max(b))-min(min(b))); else

b=zeros(m,n); end

a=double(int16(a*255))+1; b=double(int16(b*255))+1; [width,height]=size(b); u=(width-1)/2; v=(height-1)/2; rad=pi/180*20; t1=[1 0 0;0 1 0;1 1 1]; t2=[1 0 0;0 1 0;-u -v 1];

t3=[cos(rad) -sin(rad) 0;sin(rad) -cos(rad) 0;0 0 1]; t4=[1 0 0;0 1 0;u v 1]; t=t2*t3*t4*t1;

tform=maketform('affine',t); coordinate_x=zeros(width,height); coordinate_y=zeros(width,height); for i=1:width for j=1:height; coordinate_x(i,j)=i; end end for i=1:width

30


单片机的U盘读写模块的设计(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:7-发扬百年公学优良传统,创办一流精品特色小学

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: