How to close a specified MATLAB image -


after working basic image processing in matlab while now, feel little embarrassed having ask simple question... why last statement of following code fail close specified image? proper way close specified image in matlab?

clear; clc; close all;  %   %% identify available webcams.   % matlab webcam supoort package must installed first.   mywebcams = webcamlist      % identifies available webcams. cam = webcam(mywebcams{1})  % identifies current webcam. %   %% acquire webcam images.  preview(cam)                                % preview of img.   img = snapshot(cam); img = rgb2gray(img);   % single webcam img.   imgh = imshow(img);                         % display img. [imgheight, imgwidth] = size(img) close(imgh) 

using

close(imgh) 

i following error:

>> close(imgh) error using close (line 116) invalid figure handle. 

here imgh not figure handle. handle image object, inside axes object, inside figure. close figure use

>> close(imgh.parent.parent); 

or, if have older version of matlab use

>> close(get(get(h, 'parent'), 'parent')); 

or, more simply, use

>> close 

Comments