I'm working to create a tool that would measure diameter of our fibers. We've decided to create a GUI for ease of use and to change parameters when needed.
I'm creating GUI with the help of GUIDE. I want to have image updated on the axes when slider is moved, but it doesn't seem to work. Disp line is executed when slider is moved, but I'm not sure why picture isn't displayed. How do I know if bwopen line is executed? Why do variable disappear from matlab workspace? Lastly, Am I using right technique to import and handle images?
I'm totally new to this. I'm referring books to learn about GUI. I'm struggling with slider for about two weeks.
I'm referring to this text: "Learning to Program with MATLAB - Building GUI Tools"
% --- Executes on button press in load_file. function load_file_Callback(hObject, eventdata, handles) % hObject handle to load_file (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global read_image [filename, user_canceled] = imgetfile(); %fmt = 'jpg'; %[path,user_cance]=imgetfile(); if user_canceled msgbox(sprintf('Error'),'Error','Error'); return end read_image = imread(filename); axes(handles.axes1); imshow(read_image); % --- Executes on button press in binarize. function binarize_Callback(hObject, eventdata, handles) % hObject handle to binarize (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global read_image colour_to_gray = rgb2gray(read_image); % Apply median filtering on grayscale image for smoothing filtered_image = medfilt2(colour_to_gray); %imtool(filtered_image) % Convert grayscale into Binary using Otsu Method level = graythresh(filtered_image); binary = im2bw(filtered_image, level); axes(handles.axes1); imshow(binary); % --- Executes on slider movement. function xSlider_Callback(hObject, eventdata, handles) % hObject handle to xSlider (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider global binary x=get(handles.xSlider, 'Value'); xs=num2str(x); set(handles.xText, 'String', xs); disp( ' Go, go, go, world! ' ); bw_open = imopen(binary, strel('disk', x)); axes(handles.axes1); imshow(bw_open)
Set a break point on the imopen line by clicking in the left margin - a red spot will appear. If it stops there then it will execute it when you type F10. You may or may not see an effect when you display bw_open depending on the image and the size of x. You can subtract to see if anything changed.
difference = abs(double(bw_open) - double(binary)); imshow(difference, []);
If it's all black then there is no difference.
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.