summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMi Zhang <mzhang@email.wm.edu>2012-09-13 14:51:15 -0400
committerMi Zhang <mzhang@email.wm.edu>2012-09-13 14:51:15 -0400
commit81ab7d82a19f66b4d2c315b871cb1abeeaebdfeb (patch)
tree827f384205f2676223a3f5c66381fb3575d296b0
parent7fedb64c474fc8cb3bab62c84801a015fcf275fe (diff)
downloadbeam_profiler-81ab7d82a19f66b4d2c315b871cb1abeeaebdfeb.tar.gz
beam_profiler-81ab7d82a19f66b4d2c315b871cb1abeeaebdfeb.zip
cross drawn separately, minor bugs fixed
-rw-r--r--gui_win.figbin19156 -> 19434 bytes
-rw-r--r--gui_win.m166
2 files changed, 106 insertions, 60 deletions
diff --git a/gui_win.fig b/gui_win.fig
index ca441ac..e27a05e 100644
--- a/gui_win.fig
+++ b/gui_win.fig
Binary files differ
diff --git a/gui_win.m b/gui_win.m
index 580cda0..7f99f0e 100644
--- a/gui_win.m
+++ b/gui_win.m
@@ -22,7 +22,7 @@ function varargout = gui_win(varargin)
% Edit the above text to modify the response to help gui_win
-% Last Modified by GUIDE v2.5 11-Sep-2012 17:00:46
+% Last Modified by GUIDE v2.5 12-Sep-2012 18:53:14
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
@@ -70,7 +70,7 @@ set(handles.togglebutton1,'BackgroundColor','Green');
global background_m;
global image_name;
global isworking;
-global image_m;
+global image_display;
global image_original;
global image_cleaned;
global image_fitted;
@@ -78,7 +78,7 @@ global image_cross;
% Initial values
background_m = 0;
-image_m = 0;
+image_display = 0;
image_original = 0;
image_cleaned = 0;
image_fitted = 0;
@@ -113,29 +113,29 @@ varargout{1} = handles.output;
% We call it with parameters read from the GUI fields
function grabimage(handles)
global image_name;
-global image_m;
+global image_display;
global image_original;
run_string = horzcat('grabNimages_1394cam.exe -s ',num2str(get(handles.edit2,'String')),' -n ',num2str(get(handles.edit3,'String')));
system(run_string);
img=imread(image_name);
-image_m=double(img);
-image_original=image_m;
+image_display=double(img);
+image_original=image_display;
function display_stuff(handles)
-global image_m;
+global image_display;
global background_m;
% If we need to substract the background, we do it
% background_m is a global variable
if get(handles.togglebutton2,'Value') > 0
- m = image_m - background_m;
+ m = image_display - background_m;
else
- m = image_m;
+ m = image_display;
end;
% Read the tolerance value from the GUI
@@ -163,7 +163,16 @@ function togglebutton1_Callback(hObject, eventdata, handles)
% Hint: get(hObject,'Value') returns toggle state of togglebutton1
global isworking;
-global image_m;
+global image_display;
+global image_cleaned;
+global image_fitted;
+image_cleaned = 0;
+image_fitted = 0;
+set(handles.radiobutton7,'Value',1);
+if image_display > 0
+image_display = image_original;
+display_stuff(handles);
+end;
isworking =1;
% Paint the button and change text
set(handles.togglebutton1,'BackgroundColor','Red');
@@ -189,17 +198,11 @@ end;
% This executes when we do the continious run
% Same as the single fit exept that we have a while cycle
-if get(handles.radiobutton3,'Value')
-
- while get(handles.togglebutton1,'Value') > 0
-
+if get(handles.radiobutton3,'Value')
+ while get(handles.togglebutton1,'Value') > 0
grabimage(handles);
- display_stuff(handles);
-
-
-
- end;
-
+ display_stuff(handles);
+ end;
end;
@@ -229,10 +232,19 @@ function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)
set(handles.togglebutton1,'Value',0);
global isworking;
-global image_m;
+global image_display;
global image_original;
global pathname;
+global image_cleaned;
+global image_fitted;
+image_cleaned = 0;
+image_fitted = 0;
isworking =1;
+set(handles.radiobutton7,'Value',1);
+if image_display > 0
+image_display = image_original;
+display_stuff(handles);
+end;
% This calls a file-open dialog and runs the beam profiler on the choosen
% file
@@ -252,8 +264,8 @@ if get(handles.radiobutton4,'Value')
if isequal(filename,0)
else
img=imread(fullfile(pathname,filename));
- image_m=double(img);
- image_original=image_m;
+ image_display=double(img);
+ image_original=image_display;
display_stuff(handles);
end;
@@ -275,7 +287,7 @@ function pushbutton10_Callback(hObject, eventdata, handles)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global isworking;
-global image_m;
+global image_display;
global image_cleaned;
if (isworking == 1)
@@ -288,9 +300,9 @@ else
radius = str2num(get(handles.edit5,'String'));
%clean the image with the stripe eraser
- [image_cleaned,~]=stripeeraser(image_m,radius,filter);
+ [image_cleaned,~]=stripeeraser(image_display,radius,filter);
image_cleaned=abs(image_cleaned);
- image_m=image_cleaned;
+ image_display=image_cleaned;
display_stuff(handles);
set(handles.pushbutton10,'String','Clean');
@@ -309,7 +321,7 @@ function pushbutton8_Callback(hObject, eventdata, handles)
% handles structure with handles and user data (see GUIDATA)
global isworking;
-global image_m;
+global image_display;
global background_m;
global image_fitted;
global image_cross;
@@ -328,9 +340,9 @@ cy = y(1);
% If we need to substract the background, we do it
% background_m is a global variable
if get(handles.togglebutton2,'Value') > 0
- m = image_m - background_m;
+ m = image_display - background_m;
else
- m = image_m;
+ m = image_display;
end;
@@ -411,25 +423,14 @@ set(h,'Color','blue','LineWidth',2);
hold off;
%To display the intersection
-max1=max(image_m(:));
-image_cross=image_m;
-
-for y=1:480
- image_cross(y,tcx) = max1;
-end;
-
-for x=1:640
- image_cross(tcy,x) = max1;
-end;
-image_m=image_cross;
-
-display_stuff(handles);
+max1=max(image_display(:));
+image_cross=zeros(sizey,sizex);
+image_cross(:,tcx) = max1;
+image_cross(tcy,:) = max1;
%Here we plot the ideal fitted image
-
-
for x=1:sizex
for y=1:sizey
Xn = (x-cx)*cos(theta) - (y-cy)*sin(theta);
@@ -480,12 +481,12 @@ function pushbutton3_Callback(hObject, eventdata, handles)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global image_name;
-global image_m;
+global image_display;
%fname_to_save = horzcat(pwd,filesep,'saved_images',filesep,datestr(now, 'yyyy_mm_dd_HHMMSS'),'.png');
fname_to_save = horzcat('Z:\beam_profier images',filesep,datestr(now, 'yyyy_mm_dd_HHMMSS'),'.png');
set(handles.text12,'String',horzcat('Image saved to: ',fname_to_save));
-image_to_save=uint16(image_m);
+image_to_save=uint16(image_display);
imwrite(image_to_save,fname_to_save,'png','bitdepth',16);
@@ -502,11 +503,11 @@ function pushbutton4_Callback(hObject, eventdata, handles)
% handles structure with handles and user data (see GUIDATA)
global background_m;
-global image_m;
+global image_display;
global isworking;
isworking =1;
grabimage(handles);
-background_m = image_m;
+background_m = image_display;
axes(handles.axes6);
imagesc(background_m);
@@ -748,6 +749,7 @@ function uipanel4_CreateFcn(hObject, eventdata, handles)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
+%Choose imgae to display
% --- Executes when selected object is changed in uipanel4.
function uipanel4_SelectionChangeFcn(hObject, eventdata, handles)
@@ -757,40 +759,84 @@ function uipanel4_SelectionChangeFcn(hObject, eventdata, handles)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
-global image_m;
+global image_display;
global image_original;
global image_cleaned;
global image_fitted;
-global image_cross;
+set(handles.checkbox2,'Value',0);
if get(handles.radiobutton7,'Value')
- image_m=image_original;
+ image_display=image_original;
display_stuff(handles);
else
if get(handles.radiobutton8,'Value')
if image_cleaned == 0
set(handles.radiobutton7,'Value',1);
else
- if image_cross == 0;
- image_m=image_cleaned;
+ image_display=image_cleaned;
display_stuff(handles);
- else
- image_m = image_cross;
- display_stuff(handles);
- end;
end;
else
if get(handles.radiobutton9,'Value')
if image_fitted == 0
set(handles.radiobutton7,'Value',1);
- if image_m == 0
+ if image_display == 0
else
- image_m = image_original;
+ image_display = image_original;
display_stuff(handles);
end;
else
- image_m=image_fitted;
+ image_display=image_fitted;
display_stuff(handles);
end;
end;
end;
end;
+
+
+%To show the cross on the screen
+
+% --- Executes on button press in checkbox2.
+function checkbox2_Callback(hObject, eventdata, handles)
+% hObject handle to checkbox2 (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)
+global image_display;
+global image_cross;
+global image_negative;
+[sizey sizex] = size(image_display);
+image_cross=image_display;
+if get(handles.checkbox2,'Value')
+ if image_display == 0
+ set(handles.checkbox2,'Value',0)
+ else
+ [x0,y0]=ginput(1);
+ x0=round(x0);
+ y0=round(y0);
+ max2 = max(image_display(:));
+
+ %draw cross on the image
+ for y=1:sizey
+ image_cross(y,x0) = max(max2,image_display(y,x0));
+ end;
+ for x=1:sizex
+ image_cross(y0,x) = max(max2,image_display(y0,x));
+ end;
+
+ image_negative = image_display-image_cross;
+ image_display = image_cross;
+ display_stuff(handles);
+ end;
+else
+ image_display=image_display+image_negative;
+ display_stuff(handles);
+end;
+
+% Hint: get(hObject,'Value') returns toggle state of checkbox2
+
+
+% --- If Enable == 'on', executes on mouse press in 5 pixel border.
+% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton8.
+function pushbutton8_ButtonDownFcn(hObject, eventdata, handles)
+% hObject handle to pushbutton8 (see GCBO)
+% eventdata reserved - to be defined in a future version of MATLAB
+% handles structure with handles and user data (see GUIDATA)