dr.fresch03 asked . 2020-03-16

How to use slider for image processing?

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"

Is there any other tutorial or text you'd recommend?
Sincerely, Kev
Here is the code for GUI:
 % --- 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)

image processing

Expert Answer

Prashant Kumar answered . 2024-12-20 19:15:29

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.


Not satisfied with the answer ?? ASK NOW

Frequently Asked Questions

MATLAB offers tools for real-time AI applications, including Simulink for modeling and simulation. It can be used for developing algorithms and control systems for autonomous vehicles, robots, and other real-time AI systems.

MATLAB Online™ provides access to MATLAB® from your web browser. With MATLAB Online, your files are stored on MATLAB Drive™ and are available wherever you go. MATLAB Drive Connector synchronizes your files between your computers and MATLAB Online, providing offline access and eliminating the need to manually upload or download files. You can also run your files from the convenience of your smartphone or tablet by connecting to MathWorks® Cloud through the MATLAB Mobile™ app.

Yes, MATLAB provides tools and frameworks for deep learning, including the Deep Learning Toolbox. You can use MATLAB for tasks like building and training neural networks, image classification, and natural language processing.

MATLAB and Python are both popular choices for AI development. MATLAB is known for its ease of use in mathematical computations and its extensive toolbox for AI and machine learning. Python, on the other hand, has a vast ecosystem of libraries like TensorFlow and PyTorch. The choice depends on your preferences and project requirements.

You can find support, discussion forums, and a community of MATLAB users on the MATLAB website, Matlansolutions forums, and other AI-related online communities. Remember that MATLAB's capabilities in AI and machine learning continue to evolve, so staying updated with the latest features and resources is essential for effective AI development using MATLAB.

Without any hesitation the answer to this question is NO. The service we offer is 100% legal, legitimate and won't make you a cheater. Read and discover exactly what an essay writing service is and how when used correctly, is a valuable teaching aid and no more akin to cheating than a tutor's 'model essay' or the many published essay guides available from your local book shop. You should use the work as a reference and should not hand over the exact copy of it.

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.