Anas Blue
Anas Blue

Reputation: 9

How to Creat MATLAB GUI for this code?

Hi everyone I wrote this code using MatLab and I need to design a GUI as the following

The Code:

im1=imread('C:\Users\Shadow Of Dark\Desktop\sample','jpeg');

im1=rgb2gray(im1);

level=graythresh(im1)

bwfram3=im2bw(im1,level);

bw2=bwareaopen(bwfram3,20);

se=strel('disk',10);

bw2=imclose(bw2,se);

bw2=imcomplement(bw2);

[labeled,numObjects] = bwlabel(bw2,4);

imshow(labeled);

numObjects

info=regionprops(labeled,'all');

centers=cat(2,info.Centroid)

hold on;

angles=zeros(1,numObjects);

j=0; 

for i=1:2:2*numObjects-2

  l = line([centers(i) centers(i+2)],[centers(i+1) centers(i+3)]);

  set(l,'linewidth',3,'color','r');

  angles(1,i-j)= atan((centers(i+1) - centers(i+3))/(centers(i) - centers(i+2)))*180/pi;
  j=j+1;
end

angles

Upvotes: 1

Views: 542

Answers (2)

Dennis Jaheruddin
Dennis Jaheruddin

Reputation: 21561

I find this list to be quite usefull for getting started: http://www.mathworks.com/matlabcentral/fileexchange/24861-41-complete-gui-examples

You may also want to look at the examples that are already included in matlab.

Go to Start > Matlab > GUIDE

Upvotes: 2

Firstly, draw in a paper (or Enterprise Architect, ...) what you want and where in the layout. Afterwards, think of the sequence diagram of your process and write it in a paper. Later, divide your code into some functions, related to the steps you have described. Then, create a GUI with the GUI Editor in MATLAB and add a graphical element to your layout. Finally, link each function you have described to your graphical element (read the official help to do it).

(Alternatively, you can do it quicker mixing all these steps, but it is not an appropriate way of doing it).

Upvotes: 2

Related Questions