MATLAB Answers

Hello, I'm undertaking a project that estimates the size of a crowd using image processing techniques. I'm experiencing difficulties in designing my gui to have different axes with the different stages of processing, e.g grayscale,edge detection.

2 views (last 30 days)
Christine Lwanga
Christine Lwanga on 26 Apr 2014
Answered: Roberto on 26 Apr 2014
I also want to enlist the use of list boxes with choices of the different image processing techniques as well as push buttons. Below is my code.
global im [path,user_cance]=imgetfile(); if user_cance msgbox(sprintf('Error'),'Error','Error'); return end im=imread(path); im=im2double(im); %converts to double axes(handles.axes1); imshow(im); imgray=(im(:,:,1)+im(:,:,2)+im(:,:,2))/3; axes(handles.axes1); imshow(imgray); hy=fspecial('sobel'); hx=hy; Iy=imfilter(double(imgray),hy,'replicate'); Ix=imfilter(double(imgray),hx,'replicate'); imgradmag=sqrt(Ix.^2+Iy.^2); axes(handles.axes1); imshow(imgradmag); se=strel('disk',20); Ie=imerode(imgray,se); Iobr=imreconstruct(Ie,imgray); axes(handles.axes1); imshow(Iobr); edgeim=edge(Iobr,'canny',[0.15 0.2]); axes(handles.axes1); imshow(edgeim); d=imdistline; [centers,radii]=imfindcircles(edgeim,[5 10],'sensitivity',0.92,'Edge',0.03); viscircles(centers,radii,'EdgeColor','b'); axes(handles.axes1); figure,imshow(edgeim); h=length(centers); Total=ones(240,320); figure,imshow(Total); hold on HDText=insertText(Total,[205 55],h,'AnchorPoint','LeftCenter'); imshow(HDText); text(25,55,'TOTAL : ','FontSize',12,'FontWeight','bold','Color','m'); hold off rgbImage=imread(im); imshow(rgbImage,'Parent',handles.axes1); imshow(imgray,'Parent',handles.axes2); imshow(imgradmag,'Parent',handles.axes3); imshow(Iobr,'Parent',handles.axes4); imshow(Total,'Parent',handles.axes5);
  1 Comment
Christine Lwanga
Christine Lwanga on 26 Apr 2014
sorry the code copied wrongly. here is my code again.
global im
[path,user_cance]=imgetfile();
if user_cance
msgbox(sprintf('Error'),'Error','Error');
return
end
im=imread(path);
im=im2double(im); %converts to double
axes(handles.axes1);
imshow(im);
imgray=(im(:,:,1)+im(:,:,2)+im(:,:,2))/3;
axes(handles.axes1);
imshow(imgray);
hy=fspecial('sobel');
hx=hy;
Iy=imfilter(double(imgray),hy,'replicate');
Ix=imfilter(double(imgray),hx,'replicate');
imgradmag=sqrt(Ix.^2+Iy.^2);
axes(handles.axes1);
imshow(imgradmag);
se=strel('disk',20);
Ie=imerode(imgray,se);
Iobr=imreconstruct(Ie,imgray);
axes(handles.axes1);
imshow(Iobr);
edgeim=edge(Iobr,'canny',[0.15 0.2]);
axes(handles.axes1);
imshow(edgeim);
d=imdistline;
[centers,radii]=imfindcircles(edgeim,[5 10],'sensitivity',0.92,'Edge',0.03);
viscircles(centers,radii,'EdgeColor','b');
axes(handles.axes1);
figure,imshow(edgeim);
h=length(centers);
Total=ones(240,320);
figure,imshow(Total);
hold on
HDText=insertText(Total,[205 55],h,'AnchorPoint','LeftCenter');
imshow(HDText);
text(25,55,'TOTAL : ','FontSize',12,'FontWeight','bold','Color','m');
hold off
rgbImage=imread(im);
imshow(rgbImage,'Parent',handles.axes1);
imshow(imgray,'Parent',handles.axes2);
imshow(imgradmag,'Parent',handles.axes3);
imshow(Iobr,'Parent',handles.axes4);
imshow(Total,'Parent',handles.axes5);

Sign in to comment.

Answers (1)

Roberto
Roberto on 26 Apr 2014
I think that in order to program a GUI you need to get a different programming philosophy, e.g. OOP: I know it's an extensive subject, in the mean time, you can use this code wich is not OOP but will do it:
function myGUI
[path,user_cance]=imgetfile();
if user_cance
msgbox(sprintf('Error'),'Error','Error');
return
end
im=imread(path);
im=im2double(im);
imgray=(im(:,:,1)+im(:,:,2)+im(:,:,2))/3;
handles.figure = figure('Name','MyGui');
handles.axes1 = axes('Position',[.05 .05 .4 .9]);
imshow(im) ;
handles.axes2 = axes('Position',[.55 .05 .4 .9]);
imshow(imgray);
end

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by