Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: GUI to load image and draw on it???
Date: Mon, 3 Nov 2008 22:20:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 64
Message-ID: <gentek$np2$1@fred.mathworks.com>
References: <gen746$jkd$1@fred.mathworks.com> <gen9oi$dqo$1@fred.mathworks.com> <genaba$m0s$1@fred.mathworks.com> <genglp$eu5$1@fred.mathworks.com> <genj8b$s60$1@fred.mathworks.com> <genqb5$59p$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1225750804 24354 172.30.248.37 (3 Nov 2008 22:20:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 3 Nov 2008 22:20:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1338633
Xref: news.mathworks.com comp.soft-sys.matlab:498757


You can 'merge' the original image and the overlayed line using the 'getframe' command like this:

n=2; % no points to create line
[x,y] = ginput(n); % allows user to pick points with mouse to create line
line(x,y) % creates line
image_with_line=getframe(gcf); % creates a merged image
image_with_line=image_with_line.cdata; % extracts the image from the structure created by getframe
figure
imshow(image_with_line)


Use this idea for your GUI axes.

Dave


"Becca Davidson" <becca.davidson@gmail.com> wrote in message <genqb5$59p$1@fred.mathworks.com>...
> Thanks again Dave.
> 
> I'm not convinced the line() method is doing it. It seems like it is drawing the line on the plot rather than changing the colros of the pixels on the image.
> 
> Is there an easy way to save the image, with the changes?
> 
> "Dave Brackett" <davebrackett@hotmail.com> wrote in message <genj8b$s60$1@fred.mathworks.com>...
> > The  'line' function will do what you want. Type 'help line' in the command window.
> > 
> > 
> > 
> > "Becca Davidson" <becca.davidson@gmail.com> wrote in message <genglp$eu5$1@fred.mathworks.com>...
> > > Thank you Dave - your explanation was perfect and I have it all working.
> > > 
> > > The function returns an array of x's and y's. The next step is for me to draw a line on the original image.
> > > 
> > > Can anyone explain how to accomplish this or point me in the direction of a good resource?
> > > 
> > > Thanks again Dave. That was great.
> > > 
> > > "Becca Davidson" <becca.davidson@gmail.com> wrote in message <genaba$m0s$1@fred.mathworks.com>...
> > > > Thank you very much for your guidance Dave.
> > > > 
> > > > The user should be able to open an image, then freedraw on top of the image. If that is not possible or too complicated, then a straight line should suffice.
> > > > 
> > > > "Dave Brackett" <davebrackett@hotmail.com> wrote in message <gen9oi$dqo$1@fred.mathworks.com>...
> > > > > "Becca Davidson" <becca.davidson@gmail.com> wrote in message <gen746$jkd$1@fred.mathworks.com>...
> > > > > > Hi Everyone,
> > > > > > 
> > > > > > I am relatively new to Matlab, and I have been given a task to be integrated into a research project in my Lab. I would appreciate some help if you have a moment.
> > > > > > 
> > > > > > Basically, I need to load an image in Matlab using a Gui. Then the user should be able to draw on top of the image.
> > > > > > 
> > > > > > I am not sure where to start with this task and have limited familiarity with Matlab. Where should I start?
> > > > > > 
> > > > > > Also, can this be done in matlab. Would it be better to do parts of the GUI in java and integrate it with Matlab?
> > > > > > 
> > > > > > Thank You,
> > > > > > Becca
> > > > > 
> > > > > What do you mean exactly by 'draw on top of the image'. Draw what?
> > > > > 
> > > > > It is easy to display an image in a GUI but if you can clarify what you want with regards to the drawing aspect we can provide further help.
> > > > > 
> > > > > Type 'guide' into the command window and this will bring up the GUI tool. Click on the axes control on the left toolbar and drag it onto the grid. Resize how you want. Now right click on that axes object and go to callbacks. This will create the .m file associated with the GUI figure. In that space you can then type simple code to load the image, e.g. axes(handles.axes1), then imshow('your picture filename here').
> > > > > 
> > > > > Then run the .m file.