function imaqmotionf(obj) %IMAQMOTIONF %Modifications to the original webcam detection code made %By Gautam Agarwal and Patrick(pcruce@gmail.com) %We added a GUI and designed it so that it will perform a %variety of interesting modifications on the webcam data %in real time. We mainly used it for a cool effect to have %at parties. It looks pretty awesome projected on a wall or %a sheet(or a screen if you have one) %Below is the disclaimer from the original image acquisition code % %IMAQMOTION Create an image acquisition motion detector. % % IMAQMOTION(OBJ) creates a live image acquisition motion detection % UI by acquiring data from video input object OBJ and displaying any % motion in the image stream. % % Note, OBJ is re-configured to continuously acquire data in order to % set it up for detecting motion. % % Example: % % Construct a video input object and a motion display. % obj = videoinput('winvideo', 1); % imaqmotion(obj) % % See also VIDEOINPUT. % CP 4-13-04 % Copyright 2004 The MathWorks, Inc. % Unique name for the UI. appTitle = 'Image Acquisition Motion Detector'; frame = getsnapshot(obj); size(frame) global monet; global bug; global state; global state2; global counter; global mode; global mirrors; global t; global mirror_state; global mem; global n; global aspect_major; aspect_major = max(max(max(size(frame))));; n = .5; mode = 'TryptoVision'; counter = 0; t = 0; mirror_state = 1; mem = 0; state = zeros(size(frame)); monet = get_linear_permutation(aspect_major,[cos(pi/8) -sin(pi/8);sin(pi/8) cos(pi/8)]); %perm = concmap(dim(1),dim(2)); for i = 1:256 monet = monet(monet); end tic; mirrors = []; %mirrors = cell(13); %perm = get_linear_permutation(aspect_major,[-1 1;1 -1]); bug = fractal_bug(aspect_major,[0 1;1 0]); % mirrors{1} = get_nonlinear_permutation(aspect_major,@sin_trans,4*pi/aspect_major,100); mirrors{1} = get_nonlinear_permutation(aspect_major,@sphere_trans,8/aspect_major,700); % mirrors{3} = get_nonlinear_permutation(aspect_major,@swirl_trans,2*pi/aspect_major,50); % mirrors{4} = get_nonlinear_permutation(aspect_major,@horseshoe_trans,2*pi/aspect_major,50); % mirrors{5} = get_nonlinear_permutation(aspect_major,@polar_trans,2*pi/aspect_major,70); % mirrors{6} = get_nonlinear_permutation(aspect_major,@handkerchief_trans,2*pi/aspect_major,50); % mirrors{7} = get_nonlinear_permutation(aspect_major,@heart_trans,2*pi/aspect_major,50); % mirrors{8} = get_nonlinear_permutation(aspect_major,@disc_trans,2*pi/aspect_major,275); %20 % mirrors{9} = get_nonlinear_permutation(aspect_major,@spiral_trans,1*pi/aspect_major,400); %30 % mirrors{10} = get_nonlinear_permutation(aspect_major,@hyperbolic_trans,2*pi/aspect_major,225); %50 % mirrors{11} = get_nonlinear_permutation(aspect_major,@diamond_trans,2*pi/aspect_major,100); % mirrors{12} = get_nonlinear_permutation(aspect_major,@ex_trans,2*pi/aspect_major,100); % mirrors{13} = get_nonlinear_permutation(aspect_major,@julia_trans,2*pi/aspect_major,75); state = frame_to_double2(frame); state2 = frame_to_double(frame); try % Make sure we've stopped so we can set up the acquisition. stop(obj); % Configure the video input object to continuously acquire data. triggerconfig(obj, 'manual'); % set(obj, 'Tag', appTitle, 'FramesAcquiredFcnCount', 1, ... % 'TimerFcn', @localFrameCallback, 'TimerPeriod', 0.1); set(obj, 'Tag', appTitle, 'FramesAcquiredFcnCount', 1, ... 'TimerFcn', @localFrameCallback, 'TimerPeriod', 0.01); % Check to see if this object already has an associated figure. % Otherwise create a new one. ud = get(obj, 'UserData'); if ~isempty(ud) && isstruct(ud) && isfield(ud, 'figureHandles') ... && ishandle(ud.figureHandles.hFigure) appdata.figureHandles = ud.figureHandles; figure(appdata.figureHandles.hFigure) else appdata.figureHandles = localCreateFigure(obj, appTitle); end % Store the application data the video input object needs. appdata.background = []; obj.UserData = appdata; % Start the acquisition. start(obj); % Avoid peekdata warnings in case it takes too long to return a frame. warning off imaq:peekdata:tooManyFramesRequested catch % Error gracefully. error('MATLAB:imaqmotion:error', ... sprintf('IMAQMOTION is unable to run properly.\n%s', lasterr)) end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function localFrameCallback(vid, event) % Executed by the videoinput object callback % to update the image display. % If the object has been deleted on us, % or we're no longer running, do nothing. if ~isvalid(vid) || ~isrunning(vid) return; end % Access our application data. appdata = get(vid, 'UserData'); background = appdata.background; % Peek into the video stream. Since we are only interested % in processing the current frame, not every single image % frame provided by the device, we can flush any frames in % the buffer. frame = peekdata(vid, 1); if isempty(frame), return; end flushdata(vid); % First time through, a background image will be needed. if isempty(background), background = getsnapshot(vid); end % Update the figure and our application data. localUpdateFig(vid, appdata.figureHandles, frame, background); appdata.background = frame; set(vid, 'UserData', appdata); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function localUpdateFig(vid, figData, frame, background) % Update the figure display with the latest data. global monet; global mode; global bug; global mem; global n; %tic % If the figure has been destroyed on us, stop the acquisition. if ~ishandle(figData.hFigure), stop(vid); return; end %pause(.5); % Plot the results. % The Original Diff Transformation background is the previous frame % I = imabsdiff(frame, background); % converts to doubles makes square %f = frame_to_double(frame); ta = toc; f = frame; %mode %tic switch mode case 'TryptoVision' f = frame_to_double2(f); f = color_map(f,mem*2*pi,n*pi); f = double_to_frame2(f); %f = normalize_colors(f); case 'Phantasm' f = frame_to_double2(f); b = frame_to_double2(background); f = double_to_frame2(diffsmear(f,b,mem)); case 'Mirrors' f = frame_to_double(f); f = mirrors(f,mem^(3/2)); %f = normalize_colors(f); f = double_to_frame(f,size(frame)); case 'Monet' %needs original frame_to_double f = frame_to_double(f); f = saturation(f,10*mem); f = permute_frame(f,monet); f = uint8(f*256); s = size(frame); f = f((s(2)-s(1))/2:(s(2)+s(1))/2,:,:); %f = double_to_frame(f,size(frame))*256; case 'Bumblebee' f = frame_to_double2(f); f = renewRand(f,mem); f = double_to_frame2(f); % case 'Termite' % f = f(bug); case 'Prof. Chaos' f = frame_to_double2(f); f = chuaChaos(f,(1-mem)^(5/2)); f = double_to_frame2(f); end %toc %state = state*n + abs((f-b))*(1-n); %stoc = sin(toc*2*pi)/2+.5; %state = state*stoc + f*(1-stoc); %state = diffsmear(state,f,b,n);%max(state*n,((f-b)));%*n + abs((f-b))*(1-n); %state = max(state*stoc, abs(f-b)*(1-stoc)); %renewblocky(f,n); %f = permute_frame(f,monet); %f = permute_frame(f,perm); %f = color_map(f,pi,1); %f = f(perm); %f = norm_map_cyclic(f, 1,8); % difference transform %f = frame_to_double(imabsdiff(frame,background)); %trig color mappings %f = (cos(2*pi*(f*1 + toc*1)-pi/2) + 1)/2; %f = logsig(f-1.0); %temp = toc; %convert back to uint8 on interval [0,256) %I = double_to_frame(f,size(frame)); I = f; % imshow(f); %tempa = toc; set(figData.hImage, 'CData', I); % Update the patch to the new level value. %graylevel = graythresh(I); %level = max(0, floor(100*graylevel)); %xpatch = [0 level level 0]; %set(figData.hPatch, 'XData', xpatch) drawnow; %[temp tempa toc] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = mirrors(f,n) global state2; global mirrors; global mirror_state; if toc>10 mirror_state=mod(mirror_state,length(mirrors))+1; mirror_state tic; end r_val = permute_frame(state2*n+(1-n)*f,mirrors{mirror_state}); %n % if toc > .5 state2 = r_val; % tic; % end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function s = chuaChaos(f,n) global state; stoc = sin(toc*2*pi*(n+.05))/2+.5; %stoc = 1; state = mod(f + stoc*state,1); s = state; %%%%%%%%%%%%%%%%%%%%%% function s = diffsmear(f,b,n) global state state = max(state*n,abs(f-b)); s = state; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function s = renewRand(f,amt) global state %indbool = rand(size(f)) > n; state = state*(amt+1)/2; %state = state*2*amt; indbool = state < .5; %narrower parameter space state(indbool) = f(indbool); s = state; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NAH % function renewblocky(f,n) % global state; % global counter; % % counterbx = counterx; % % counterx = min(counterx + n, size(frame,2)/2); % % counterby = countery; % % countery = min(countery + n, size(frame,1)/2); % counterb = counter; % counter = counter +n ; % indx = mod(counterb:counter,size(f,2)/2); % indy = mod(counterb:counter,size(f,1)/2); % state([(size(f,1)/2-indy) (size(f,1)/2+indy)],[(size(f,2)/2-indx) (size(f,2)/2+indx)] ,:) = ... % f([(size(f,1)/2-indy) (size(f,1)/2+indy)],[(size(f,2)/2-indx) (size(f,2)/2+indx)] ,:); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function rad = concmap(x,y) for i = 1:x for j= 1:y rad(i,j) = floor(sqrt((i-x/2)^2 + (j-y/2)^2)); end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = color_map(f,space,time) r_val = (cos(2*pi*(f*space + toc*time)-pi/2) + 1)/2; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = egdes(f) %edges bw=edge(max(f,[],3)); r_val=min(cat(3,bw,bw,bw)+f,1); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = saturation(f,s) %saturation rwgt=0.3086; gwgt=0.6094; bwgt=0.0820; cmat=[[rwgt rwgt rwgt] [gwgt gwgt gwgt] [bwgt bwgt bwgt]]; for i=1:3 lum(:,:,i)=f(:,:,1)*cmat(1,i)+f(:,:,2)*cmat(2,i)+f(:,:,3)*cmat(3,i); end r_val=(1-s)*lum+s*f; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = luminosity(f,c) %contrast rwgt=0.3086; gwgt=0.6094; bwgt=0.0820; c=1.5; cmat=[[rwgt rwgt rwgt] [gwgt gwgt gwgt] [bwgt bwgt bwgt]]; for i=1:3 lum(:,:,i)=f(:,:,1)*cmat(1,i)+f(:,:,2)*cmat(2,i)+f(:,:,3)*cmat(3,i); end lum(:,:,:)=mean(mean(mean(lum))); r_val=(1-c)*lum+c*f; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %slow implementation function [r_val] = intensity(f,space,time) %intensity shift intensity=max(f,[],3); intensitya=intensity; %eliminate div/0 intensitya(find(intensity==0))=1e-90; intensity3 = cat(3,intensitya,intensitya,intensitya); f=f./intensity3; intensity = (cos(2*pi*(intensity*space + toc*time)-pi/2) + 1)/2; intensity = cat(3,intensity,intensity,intensity); r_val=(f.*intensity); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = normalize_colors(f) maxstate=max(max(f)); minstate=min(min(f)); range=maxstate-minstate; for i=1:3 if range(i)==0 range(i) = .00001; end f(:,:,i)=f(:,:,i)/range(i); f(:,:,i)=f(:,:,i)-minstate(i); end r_val = f; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = permute_frame(f,p) a = f(:,:,1); b = f(:,:,2); c = f(:,:,3); f(:,:,1) = a(p); f(:,:,2) = b(p); f(:,:,3) = c(p); r_val = f; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %normal distribution pass...needs more work but has potential as a pass %function, I think it needs to be tuned to match the lighting conditions %maybe with 2 sliders possibly with log scales %the normpdf has a range [0,.4] so the 5/2 just maps over [0,1) %sin(toc)s do interesting things to the scalings....we may be able to sync %inputs to music function [r_val] = norm_map_cyclic(f,a,b) %r_val(:,:,1) = 5/2 * normpdf(f(:,:,1),sin(toc + a*pi/3)+.5,abs(cos(toc/100))/6); % r_val(:,:,2) = 5/2 * normpdf(f(:,:,2),sin(toc + a*pi/4)+.5,abs(cos(toc/100))/6); % r_val(:,:,3) = 5/2 * normpdf(f(:,:,3),sin(toc + a*pi/5) + .5,abs(cos(toc/100))/6); r_val(:,:,1) = 5/2 * normpdf(f(:,:,1),sin(toc + a*pi/3)+.5,1/b); r_val(:,:,2) = 5/2 * normpdf(f(:,:,2),sin(toc + a*pi/4)+.5,1/b); r_val(:,:,3) = 5/2 * normpdf(f(:,:,3),sin(toc + a*pi/5) + .5,1/b); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = frame_to_double(f) s = size(f); spacer = zeros((s(2)-s(1))/2,s(2),3); r_val = [spacer ;double(f)/256; spacer]; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = double_to_frame(f,s) %f = uint8(f*256); r_val = f((s(2)-s(1))/2:(s(2)+s(1))/2,:,:); % [00 t1 toc] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = frame_to_double2(f) %s = size(f); %spacer = zeros((s(2)-s(1))/2,s(2),3); %r_val = [spacer ;double(f)/256; spacer]; r_val=double(f)/256; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = double_to_frame2(f) %f = uint8(f*256); %r_val = f((s(2)-s(1))/2:(s(2)+s(1))/2,:,:); %[00 t1 toc] r_val = f;%uint8(f*256); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = get_linear_permutation(m,t) % v = zeros(m,n,3); v = ones(m,m); for i = -m/2+1:m/2 for j = -m/2+1:m/2 c = t*[i;j]; c = clip1(c,[-m/2+1;m/2]); v(i+m/2,j+m/2) = m*(c(2)+m/2-1)+c(1)+m/2; %v(i,j) = (j-1)*m + i; %for k = 1:3 % v(i,j,k) = i*(clip(c(1),1,m)-1)+j*(clip(c(2),1,n)-1) + k; %end end end max(max(v)); min(min(v)); r_val=v; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = fractal_bug(m,t) % v = zeros(m,n,3); v = ones(m,m); for i = -m/2+1:m/2 for j = -m/2+1:m/2 c = t*[i;j]; c = clip2(c,[-m/2+1;m/2]); for k = 1:3 v(i+m/2,j+m/2,k) = (i+m/2)*(c(1)+m/2-1)+(j+m/2)*(c(2)+m/2-1) + k; end end end max(max(v)); min(min(v)); r_val=v; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = get_nonlinear_permutation(m,t,d,r) % v = zeros(m,n,3); v = ones(m,m); for i = -m/2+1:m/2 for j = -m/2+1:m/2 c = r*t(d*[i;j]); c = clip2(c,[-m/2+1;m/2]); v(i+m/2,j+m/2) = m*(c(2)+m/2-1)+c(1)+m/2; end end r_val=v; %%%%%%%%%%%%%%%%%%%%%% %doesn't work... function [r_val] = chaos_trans(v) r_val = clip2(2.0*v,[-1.0;1.0]); %%%%%%%%%%%%%%%%%%%%% %good values: %d: 4pi/aspect_major r:100 %as far as I can tell increasing the domain scales out & increases the %number of images, increasing the range zooms out without changing image %structure function [r_val] = sin_trans(v) r_val = [sin(v(1)) sin(v(2))]; %%%%%%%%%%%%%%%%%%%%% %good values: %d: 1/aspect_major r: 20 %both domain and range appear to zoom function [r_val] = sphere_trans(v) x = v(1); y = v(2); r = x*x+y*y; if r == 0 r = .000000001; end r_val = [(x/r);(y/r)]; %%%%%%%%%%%%%%%%%%%%%%% %good values %d: 2pi/aspect_major r:50 function [r_val] = swirl_trans(v) x = v(1); y = v(2); r = sqrt(x*x+y*y); t = theta(v); r_val = [r*cos(t+r) r*sin(t+r)]; %%%%%%%%%%%%%%%%%%%%%%% %good values %d: 2pi/aspect_major r:50 function [r_val] = horseshoe_trans(v) x = v(1); y = v(2); r = sqrt(x*x+y*y); t = theta(v); r_val = [r*cos(2*t) r*sin(2*t)]; %%%%%%%%%%%%%%%%%%%%%%% %good values %d: 2pi/aspect_major r:70 function [r_val] = polar_trans(v) x = v(1); y = v(2); r = sqrt(x*x+y*y); t = theta(v); r_val = [t/pi r-1]; %%%%%%%%%%%%%%%%%%%%%%% %good values %d: 2pi/aspect_major r:50 function [r_val] = handkerchief_trans(v) x = v(1); y = v(2); r = sqrt(x*x+y*y); t = theta(v); r_val = [r*sin(t+r) r*cos(t-r)]; %%%%%%%%%%%%%%%%%%%%%%% %good values %d: 2pi/aspect_major r:50 function [r_val] = heart_trans(v) x = v(1); y = v(2); r = sqrt(x*x+y*y); t = theta(v); r_val = [r*sin(t*r) -r*cos(t*r)]; %%%%%%%%%%%%%%%%%%%%%%% %good values %d: 2pi/aspect_major r:50 function [r_val] = disc_trans(v) x = v(1); y = v(2); r = sqrt(x*x+y*y); t = theta(v); r_val = [(t*sin(pi*r))/pi (t*cos(pi*r))/pi]; %%%%%%%%%%%%%%%%%%%%%%% %good values %d: 1.75pi/aspect_major r:30 function [r_val] = spiral_trans(v) x = v(1); y = v(2); r = sqrt(x*x+y*y); if r == 0 r = .000001; end t = theta(v); r_val = [(cos(t) + sin(r))/r (sin(t)-cos(r))/r]; %%%%%%%%%%%%%%%%%%%%%%% %good values %d: 2pi/aspect_major r:50 function [r_val] = hyperbolic_trans(v) x = v(1); y = v(2); r = sqrt(x*x+y*y); if r == 0 r = .000001; end t = theta(v); r_val = [sin(t)/r cos(t)/r]; %%%%%%%%%%%%%%%%%%%%%%% %good values(sort of) %d: 2pi/aspect_major r:50 function [r_val] = diamond_trans(v) x = v(1); y = v(2); r = sqrt(x*x+y*y); t = theta(v); r_val = [sin(t)*cos(r) cos(t)*sin(r)]; %%%%%%%%%%%%%%%%%%%%%%% %good values(sort of) %d: 2pi/aspect_major r:50 function [r_val] = ex_trans(v) x = v(1); y = v(2); r = sqrt(x*x+y*y); t = theta(v); r_val = [r*(sin(t+r)^3) r*(cos(t-r)^3)]; %%%%%%%%%%%%%%%%%%%%%%% %good values(sort of) %d: 2pi/aspect_major r:50 %looks cool may have a bug function [r_val] = julia_trans(v) x = v(1); y = v(2); if randn > 0 o = 0; else o = pi; end r = sqrt(x*x+y*y); t = theta(v); r_val = [sqrt(r)*cos((t/2)+o) sqrt(r)*sin((t/2)+o)]; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = theta(v) x = v(1); y = v(2); if x == 0 x = .000000001; end r_val = atan(y/x); if r_val<0 r_val=-r_val; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = clip2(c,m) c(1) = mod(floor(c(1))-m(1),m(2)-m(1))+1 + m(1); c(2) = mod(floor(c(2))-m(1),m(2)-m(1))+1 + m(1); %c(1) = floor(c(1)); %c(2) = floor(c(2)); %if(c(1) < m(1) || c(2) < m(1) || c(1) > m(2) || c(2) > m(2)) % c(1) = 1; % c(2) = 1; %end r_val = c; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [r_val] = clip1(c,m) c(1) = floor(c(1)); c(2) = floor(c(2)); if(c(1) < m(1) || c(2) < m(1) || c(1) > m(2) || c(2) > m(2)) c(1) = 1; c(2) = 1; end r_val = c; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function localDeleteFig(fig, event) % Reset peekdata warnings. warning on imaq:peekdata:tooManyFramesRequested %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function figData = localCreateFigure(vid, figTitle) global u7 global u8 % Creates and initializes the figure. % Create the figure and axes to plot into. fig = figure('NumberTitle', 'off', 'MenuBar', 'none', ... 'Name', figTitle, 'DeleteFcn', @localDeleteFig); %set(gcf,'Units','Normalized','Position',[0,0,1,1],'Color','k') %set up GUI h = uibuttongroup('visible','off','Position',[0 0 1 .05]); u0 = uicontrol('Style','Radio','String','TryptoVision',... 'pos',[0 0 80 20],'parent',h,'HandleVisibility','off'); u1 = uicontrol('Style','Radio','String','Phantasm',... 'pos',[80 0 80 20],'parent',h,'HandleVisibility','off'); u2 = uicontrol('Style','Radio','String','Mirrors',... 'pos',[160 0 80 20],'parent',h,'HandleVisibility','off'); u3 = uicontrol('Style','Radio','String','Monet',... 'pos',[240 0 80 20],'parent',h,'HandleVisibility','off'); u4 = uicontrol('Style','Radio','String','Bumblebee',... 'pos',[320 0 80 20],'parent',h,'HandleVisibility','off'); % u5 = uicontrol('Style','Radio','String','Termite',... % 'pos',[400 0 80 20],'parent',h,'HandleVisibility','off'); u6 = uicontrol('Style','Radio','String','Prof. Chaos',... 'pos',[400 0 80 20],'parent',h,'HandleVisibility','off'); set(h,'SelectionChangeFcn',@selcbk); %set(h,'SelectedObject',[]); % No selection set(h,'Visible','on'); u7 = uicontrol('Style','slider','String','SlideMe1',... 'Callback',@setMem,'Max',.99,'pos',[0 25 200 20]); u8 = uicontrol('Style','slider','String','SlideMe2',... 'Callback',@setN,'pos',[220 25 200 20]); %set(u7,'Visible','on'); %set(u8,'Visible','on'); % Create a spot for the image object display. nbands = get(vid, 'NumberOfBands'); res = get(vid, 'ROIPosition'); himage = imagesc(rand(res(4), res(3), nbands)); set(gca,'Units','Normalized','Position',[0 0 1 1],'Color','k'); % Clean up the axes. ax = get(himage, 'Parent'); set(ax, 'XTick', [], 'XTickLabel', [], 'YTick', [], 'YTickLabel', []); % Create the motion detection bar before hiding the figure. %[hPatch, hLine] = localCreateBar(ax); %set(fig, 'HandleVisibility', 'off'); % Store the figure data. figData.hFigure = fig; figData.hImage = himage; %figData.hPatch = hPatch; %figData.hLine = hLine; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function setMem(source,eventdata) global u7; global mem; mem = get(u7,'Value'); %mem = str2num(get(u7,'String')) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function setN(source,eventdata) global u8; global n; n = get(u8,'Value'); %mem = str2num(get(u7,'String')) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function selcbk( source,eventdata) global mode; global state; global u8; state = zeros(size(state)); mode = get(eventdata.NewValue,'String'); if strcmp(mode,'TryptoVision') set(u8,'Enable','on'); else set(u8,'Enable','off'); end