Advertisement
LarvitarYoung

圖片坎入至中,用imresize

Jan 7th, 2021
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 5.18 KB | None | 0 0
  1. function varargout = m0107_4(varargin)
  2. % M0107_4 MATLAB code for m0107_4.fig
  3. %      M0107_4, by itself, creates a new M0107_4 or raises the existing
  4. %      singleton*.
  5. %
  6. %      H = M0107_4 returns the handle to a new M0107_4 or the handle to
  7. %      the existing singleton*.
  8. %
  9. %      M0107_4('CALLBACK',hObject,eventData,handles,...) calls the local
  10. %      function named CALLBACK in M0107_4.M with the given input arguments.
  11. %
  12. %      M0107_4('Property','Value',...) creates a new M0107_4 or raises the
  13. %      existing singleton*.  Starting from the left, property value pairs are
  14. %      applied to the GUI before m0107_4_OpeningFcn gets called.  An
  15. %      unrecognized property name or invalid value makes property application
  16. %      stop.  All inputs are passed to m0107_4_OpeningFcn via varargin.
  17. %
  18. %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
  19. %      instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22.  
  23. % Edit the above text to modify the response to help m0107_4
  24.  
  25. % Last Modified by GUIDE v2.5 08-Jan-2021 00:42:09
  26.  
  27. % Begin initialization code - DO NOT EDIT
  28. gui_Singleton = 1;
  29. gui_State = struct('gui_Name',       mfilename, ...
  30.                    'gui_Singleton',  gui_Singleton, ...
  31.                    'gui_OpeningFcn', @m0107_4_OpeningFcn, ...
  32.                    'gui_OutputFcn',  @m0107_4_OutputFcn, ...
  33.                    'gui_LayoutFcn',  [] , ...
  34.                    'gui_Callback',   []);
  35. if nargin && ischar(varargin{1})
  36.     gui_State.gui_Callback = str2func(varargin{1});
  37. end
  38.  
  39. if nargout
  40.     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  41. else
  42.     gui_mainfcn(gui_State, varargin{:});
  43. end
  44. % End initialization code - DO NOT EDIT
  45.  
  46.  
  47. % --- Executes just before m0107_4 is made visible.
  48. function m0107_4_OpeningFcn(hObject, eventdata, handles, varargin)
  49. % This function has no output args, see OutputFcn.
  50. % hObject    handle to figure
  51. % eventdata  reserved - to be defined in a future version of MATLAB
  52. % handles    structure with handles and user data (see GUIDATA)
  53. % varargin   command line arguments to m0107_4 (see VARARGIN)
  54.  
  55. % Choose default command line output for m0107_4
  56. handles.output = hObject;
  57.  
  58. % Update handles structure
  59. guidata(hObject, handles);
  60.  
  61. % UIWAIT makes m0107_4 wait for user response (see UIRESUME)
  62. % uiwait(handles.figure1);
  63.  
  64.  
  65. % --- Outputs from this function are returned to the command line.
  66. function varargout = m0107_4_OutputFcn(hObject, eventdata, handles)
  67. % varargout  cell array for returning output args (see VARARGOUT);
  68. % hObject    handle to figure
  69. % eventdata  reserved - to be defined in a future version of MATLAB
  70. % handles    structure with handles and user data (see GUIDATA)
  71.  
  72. % Get default command line output from handles structure
  73. varargout{1} = handles.output;
  74.  
  75.  
  76. % --------------------------------------------------------------------
  77. function Untitled_1_Callback(hObject, eventdata, handles)
  78. % hObject    handle to Untitled_1 (see GCBO)
  79. % eventdata  reserved - to be defined in a future version of MATLAB
  80. % handles    structure with handles and user data (see GUIDATA)
  81.  
  82.  
  83. % --------------------------------------------------------------------
  84. function Untitled_2_Callback(hObject, eventdata, handles)
  85. % hObject    handle to Untitled_2 (see GCBO)
  86. % eventdata  reserved - to be defined in a future version of MATLAB
  87. % handles    structure with handles and user data (see GUIDATA)
  88. im1=handles.im1;
  89. im2=handles.im2;
  90. r2=handles.r2;
  91. c2=handles.c2;
  92. [r c p]=size(im1);
  93. im1((r-r2)/2:(r-r2)/2+r2-1,(c-c2)/2:(c-c2)/2-1+c2,:)=im1((r-r2)/2:(r-r2)/2+r2-1,(c-c2)/2:(c-c2)/2+c2-1,:)+im2;
  94. axes(handles.axes3);
  95. imshow(im1);
  96. handles.im3=im1;
  97. guidata(hObject,handles);
  98.  
  99. % --------------------------------------------------------------------
  100. function Untitled_3_Callback(hObject, eventdata, handles)
  101. % hObject    handle to Untitled_3 (see GCBO)
  102. % eventdata  reserved - to be defined in a future version of MATLAB
  103. % handles    structure with handles and user data (see GUIDATA)
  104. imo=handles.im1;
  105. ime=handles.im3;
  106. r2=handles.r2;
  107. c2=handles.c2;
  108. [r c p]=size(imo);
  109. im=ime((r-r2)/2:(r-r2)/2+r2-1,(c-c2)/2:(c-c2)/2+c2-1,:)-imo((r-r2)/2:(r-r2)/2+r2-1,(c-c2)/2:(c-c2)/2+c2-1,:);
  110. axes(handles.axes4);
  111. imshow(im);
  112.  
  113. % --------------------------------------------------------------------
  114. function Untitled_4_Callback(hObject, eventdata, handles)
  115. % hObject    handle to Untitled_4 (see GCBO)
  116. % eventdata  reserved - to be defined in a future version of MATLAB
  117. % handles    structure with handles and user data (see GUIDATA)
  118. [f p]=uigetfile('*.jpg');
  119. pf=[p f];
  120. im=imread(pf);
  121. axes(handles.axes1);
  122. imshow(im);
  123. handles.im1=im;
  124. guidata(hObject,handles);
  125.  
  126.  
  127. % --------------------------------------------------------------------
  128. function Untitled_5_Callback(hObject, eventdata, handles)
  129. % hObject    handle to Untitled_5 (see GCBO)
  130. % eventdata  reserved - to be defined in a future version of MATLAB
  131. % handles    structure with handles and user data (see GUIDATA)
  132. [f p]=uigetfile('*.jpg');
  133. pf=[p f];
  134. im=imread(pf);
  135. [r2 c2 p2]=size(im);
  136. im=imresize(im,[0.5*r2,0.5*r2]);
  137. axes(handles.axes2);
  138. imshow(im);
  139. handles.im2=im;
  140. handles.r2=r2*0.5;
  141. handles.c2=c2*0.5;
  142. guidata(hObject,handles);
  143.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement