Matlab 保存图片时怎么去掉周围的白边
我用matlab的GUI进行截图,并保存截下来的图片,但是保存下来的图片总有一圈白边,求教怎么除去这圈白边。下面是我写的程序段(是新手有点挫),要怎么改这是我截图按钮的程...
我用matlab的GUI进行截图,并保存截下来的图片,但是保存下来的图片总有一圈白边,求教怎么除去这圈白边。下面是我写的程序段(是新手有点挫),要怎么改
这是我截图按钮的程序
function CUT_Callback(hObject, eventdata, handles)
[x,y,c]=ginput(1);
x=x-100;
y=y-100;
global s
A=imread(s);
if c==1
BB=imcrop(A,[x,y,200,200]);
set(handles.axes1,'HandleVisibility','ON');
axes(handles.axes2);
imshow(BB);
handles.img=BB;
guidata(hObject,handles);
end
这是保存按钮的程序:
function SAVE_Callback(hObject, eventdata, handles)
new_f_handle=figure('visible','off');
new_axes=copyobj(handles.axes2,new_f_handle);
set(new_axes,'units','default','position','default');
[filename,pathname fileindex]=uiputfile({'*.jpg';'*.bmp'},'save picture as');
if ~filename
return
else
file=strcat(pathname,filename);
switch fileindex
case 1
print(new_f_handle,'-djpeg',file);
case 2
print(new_f_handle,'-dbmp',file);
end
end 展开
这是我截图按钮的程序
function CUT_Callback(hObject, eventdata, handles)
[x,y,c]=ginput(1);
x=x-100;
y=y-100;
global s
A=imread(s);
if c==1
BB=imcrop(A,[x,y,200,200]);
set(handles.axes1,'HandleVisibility','ON');
axes(handles.axes2);
imshow(BB);
handles.img=BB;
guidata(hObject,handles);
end
这是保存按钮的程序:
function SAVE_Callback(hObject, eventdata, handles)
new_f_handle=figure('visible','off');
new_axes=copyobj(handles.axes2,new_f_handle);
set(new_axes,'units','default','position','default');
[filename,pathname fileindex]=uiputfile({'*.jpg';'*.bmp'},'save picture as');
if ~filename
return
else
file=strcat(pathname,filename);
switch fileindex
case 1
print(new_f_handle,'-djpeg',file);
case 2
print(new_f_handle,'-dbmp',file);
end
end 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询