上个月我们学校工作室老师给我们布置了一个用matlab实现基于内容的图像检索的任务,我用了半个月的时间完成了,总结一下这半个月以来的所学。
1.创建GUI页面 并对其进行布局。
2.利用GUI选择要进行检索的图片,并将其灰度及计算直方图。
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.axes2,'visible','off');
[filename,pathname]=uigetfile({
'*.jpg';'*.bmp';'*.tif';'*.*'},'载入图像');
if isequal(filename,0)|isequal(pathname,0)
errordlg('没有选中文件','出错');
return;
else
file=[pathname,filename];
end
pic =imread(file); %导入图片
x=rgb2gray(pic) ; %将图片灰度
a=imhist(x); %计算图像的颜色直方图
axes(handles.axes9);
imshow(pic)