<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240133</link>
    <title>MATLAB Central Newsreader - changing position of a image</title>
    <description>Feed for thread: changing position of a image</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 30 Nov 2008 01:33:02 -0500</pubDate>
      <title>changing position of a image</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240133#613926</link>
      <author>Rui Gomes</author>
      <description>hi.&lt;br&gt;
&lt;br&gt;
i am developing a matlab guide.&lt;br&gt;
i have 3 images, 2 of then will never move, &lt;br&gt;
the first is to collect points,&lt;br&gt;
the second is a example image&lt;br&gt;
and the third is the smallest and will move in the second image according with the points i want the user to click on the first image.&lt;br&gt;
&lt;br&gt;
but and i do:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pos_act =get(handles.axes3,'Position');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(handles.axes3,'Position',[590 214 pos_act(3) pos_act(4)]);&lt;br&gt;
&lt;br&gt;
the third image dissipates.&lt;br&gt;
&lt;br&gt;
what can i do?&lt;br&gt;
&lt;br&gt;
thanks for the help</description>
    </item>
    <item>
      <pubDate>Sun, 30 Nov 2008 02:13:01 -0500</pubDate>
      <title>Re: changing position of a image</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240133#613930</link>
      <author>Ryan Ollos</author>
      <description>&quot;Rui Gomes&quot; &amp;lt;rpgomes84@gmail.com&amp;gt; wrote in message &amp;lt;ggsqge$hrt$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; hi.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; i am developing a matlab guide.&lt;br&gt;
&amp;gt; i have 3 images, 2 of then will never move, &lt;br&gt;
&amp;gt; the first is to collect points,&lt;br&gt;
&amp;gt; the second is a example image&lt;br&gt;
&amp;gt; and the third is the smallest and will move in the second image according with the points i want the user to click on the first image.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; but and i do:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;     pos_act =get(handles.axes3,'Position');&lt;br&gt;
&amp;gt;     set(handles.axes3,'Position',[590 214 pos_act(3) pos_act(4)]);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; the third image dissipates.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; what can i do?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; thanks for the help&lt;br&gt;
&lt;br&gt;
I would suggest first checking the units property of your axes and figure.  Assuming that isn't the problem, you might take a look at the solution someone provided me in this thread.  I was trying to &quot;stack&quot; images:&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/matlabcentral/newsreader/view_thread/237542&quot;&gt;http://www.mathworks.com/matlabcentral/newsreader/view_thread/237542&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
Also, could you make image3 and image1 share the same axes?  I think that would make the problem easier to manage.</description>
    </item>
    <item>
      <pubDate>Sun, 30 Nov 2008 02:40:18 -0500</pubDate>
      <title>Re: changing position of a image</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240133#613933</link>
      <author>Rui Gomes</author>
      <description>&lt;br&gt;
&amp;gt; I would suggest first checking the units property of your axes and figure.  Assuming that isn't the problem, you might take a look at the solution someone provided me in this thread.  I was trying to &quot;stack&quot; images:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;a href=&quot;http://www.mathworks.com/matlabcentral/newsreader/view_thread/237542&quot;&gt;http://www.mathworks.com/matlabcentral/newsreader/view_thread/237542&lt;/a&gt;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Also, could you make image3 and image1 share the same axes?  I think that would make the problem easier to manage.&lt;br&gt;
&lt;br&gt;
im making some experiences&lt;br&gt;
and when i put im guide .m file:&lt;br&gt;
&lt;br&gt;
handles.redI = imread('red_spot.jpg');&lt;br&gt;
pos_act =get(handles.axes3,'Position')&lt;br&gt;
set(handles.axes3,'Position',[111 111 pos_act(3) pos_act(4)]);&lt;br&gt;
image(handles.redI);&lt;br&gt;
axis off;&lt;br&gt;
&lt;br&gt;
my image dissipates, and the image that i had associate in handles.axes3 and to change position several times.&lt;br&gt;
&lt;br&gt;
i don't know what to do, im to novice in matlab guide.&lt;br&gt;
the image is only a red point that i want to put in front of the image that is in handles.axes2&lt;br&gt;
&lt;br&gt;
thanks for the help.</description>
    </item>
    <item>
      <pubDate>Sun, 30 Nov 2008 03:15:10 -0500</pubDate>
      <title>Re: changing position of a image</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240133#613938</link>
      <author>ImageAnalyst</author>
      <description>On Nov 29, 9:40=A0pm, &quot;Rui Gomes&quot; &amp;lt;rpgome...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; I would suggest first checking the units property of your axes and figu=&lt;br&gt;
re. =A0Assuming that isn't the problem, you might take a look at the soluti=&lt;br&gt;
on someone provided me in this thread. =A0I was trying to &quot;stack&quot; images:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&lt;a href=&quot;http://www.mathworks.com/matlabcentral/newsreader/view_thread/237542&quot;&gt;http://www.mathworks.com/matlabcentral/newsreader/view_thread/237542&lt;/a&gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Also, could you make image3 and image1 share the same axes? =A0I think =&lt;br&gt;
that would make the problem easier to manage.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; im making some experiences&lt;br&gt;
&amp;gt; and when i put im guide .m file:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; handles.redI =3D imread('red_spot.jpg');&lt;br&gt;
&amp;gt; pos_act =3Dget(handles.axes3,'Position')&lt;br&gt;
&amp;gt; set(handles.axes3,'Position',[111 111 pos_act(3) pos_act(4)]);&lt;br&gt;
&amp;gt; image(handles.redI);&lt;br&gt;
&amp;gt; axis off;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; my image dissipates, and the image that i had associate in handles.axes3 =&lt;br&gt;
and to change position several times.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; i don't know what to do, im to novice in matlab guide.&lt;br&gt;
&amp;gt; the image is only a red point that i want to put in front of the image th=&lt;br&gt;
at is in handles.axes2&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; thanks for the help.&lt;br&gt;
&lt;br&gt;
Rui:&lt;br&gt;
Use the &quot;hold on&quot; command.  What happens is that when you display the&lt;br&gt;
red dot, it replaces the image that was previously in the axes.  If&lt;br&gt;
you set hold on then I think it will retain the image and just place&lt;br&gt;
the red dot on top of the existing image.&lt;br&gt;
Regards,&lt;br&gt;
ImageAnalyst&lt;br&gt;
P.S. I think you mean &quot;disappear&quot; rather than dissipate.</description>
    </item>
    <item>
      <pubDate>Sun, 30 Nov 2008 07:55:07 -0500</pubDate>
      <title>Re: changing position of a image</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240133#613950</link>
      <author>Ryan Ollos</author>
      <description>&quot;Rui Gomes&quot; &amp;lt;rpgomes84@gmail.com&amp;gt; wrote in message &amp;lt;ggsuei$2u8$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; im making some experiences&lt;br&gt;
&amp;gt; and when i put im guide .m file:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; handles.redI = imread('red_spot.jpg');&lt;br&gt;
&amp;gt; pos_act =get(handles.axes3,'Position')&lt;br&gt;
&amp;gt; set(handles.axes3,'Position',[111 111 pos_act(3) pos_act(4)]);&lt;br&gt;
&amp;gt; image(handles.redI);&lt;br&gt;
&amp;gt; axis off;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; my image dissipates, and the image that i had associate in handles.axes3 and to change position several times.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; i don't know what to do, im to novice in matlab guide.&lt;br&gt;
&amp;gt; the image is only a red point that i want to put in front of the image that is in handles.axes2&lt;br&gt;
&lt;br&gt;
I think you need to put these 3 commands in the portion of your GUIDE code other than the Callback (such as CreateFcn for the axes).&lt;br&gt;
&lt;br&gt;
handles.redI = imread('red_spot.jpg');&lt;br&gt;
image(handles.redI);&lt;br&gt;
axis off;&lt;br&gt;
&lt;br&gt;
Then, in ButtonDownFcn for Axes 1 (assuming Axes 1 and 2 are the same size),&lt;br&gt;
&lt;br&gt;
cursorPos = get(handles.axes1, 'CurrentPosition')&lt;br&gt;
pos_act =get(handles.axes3,'Position')&lt;br&gt;
set(handles.axes3,'Position',[111 111 pos_act(3) pos_act(4)]);&lt;br&gt;
&lt;br&gt;
I think that covers the basic idea, but there is more too it than that, so I'll post an example code that you can run.</description>
    </item>
    <item>
      <pubDate>Sun, 30 Nov 2008 09:09:03 -0500</pubDate>
      <title>Re: changing position of a image</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240133#613953</link>
      <author>Ryan Ollos</author>
      <description>% This function hopefully implements what you want to do for the most part&lt;br&gt;
&lt;br&gt;
function h = moveImageTest&lt;br&gt;
&lt;br&gt;
h.figure = figure;&lt;br&gt;
&lt;br&gt;
h.axes(1) = axes('Parent', h.figure, ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'Position', [0.05 0.1 0.4 0.4], ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'XTick', [], ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'YTick', [], ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'XColor', get(h.figure, 'Color'), ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'YColor', get(h.figure, 'Color'), ...    &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'ButtonDownFcn', @axes_moveImage, ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'CreateFcn', {@axes_loadImage, 1});&lt;br&gt;
&lt;br&gt;
h.axes(2) = axes('Parent', h.figure, ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'Position', [0.55 0.1 0.4 0.4], ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'XTick', [], ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'YTick', [], ...    &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'XColor', get(h.figure, 'Color'), ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'YColor', get(h.figure, 'Color'), ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'CreateFcn', {@axes_loadImage, 2});&lt;br&gt;
&lt;br&gt;
h.axes(3) = axes('Parent', h.figure, ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'Position', [0.75 0.25 0.025 0.025], ...    &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'XTick', [], ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'YTick', [], ...    &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'CreateFcn', @axes_loadImage3);&lt;br&gt;
&lt;br&gt;
% Get handles saved in CreateFcn's&lt;br&gt;
h2 = guidata(h.figure);&lt;br&gt;
% Merge h and h2&lt;br&gt;
fieldName = fieldnames(h2);&lt;br&gt;
for i=1:length(h2)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;h.(fieldName{i}) = h2.(fieldName{i});&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
guidata(h.figure, h);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
function axes_loadImage(hObject, eventdata, axesNum)&lt;br&gt;
&lt;br&gt;
h = guidata(hObject);&lt;br&gt;
axes(hObject);&lt;br&gt;
&lt;br&gt;
I = imread('rice.png');&lt;br&gt;
&lt;br&gt;
% Use low level function call for image so axes properties are not reset&lt;br&gt;
h.image(axesNum) = image('CData', I);&lt;br&gt;
&lt;br&gt;
% Set HitTest property to off so button clicks will be handled by the &lt;br&gt;
% parent axes&lt;br&gt;
set(h.image(axesNum), 'HitTest', 'off');&lt;br&gt;
&lt;br&gt;
axis tight;&lt;br&gt;
&lt;br&gt;
hf = ancestor(hObject, 'Figure');&lt;br&gt;
guidata(hf, h);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
function axes_loadImage3(hObject, eventdata)&lt;br&gt;
&lt;br&gt;
h = guidata(hObject);&lt;br&gt;
axes(hObject);&lt;br&gt;
&lt;br&gt;
I = zeros(20,20,3); %small black square&lt;br&gt;
&lt;br&gt;
% Use low level function call for image so axes properties are not reset&lt;br&gt;
h.image(3) = image('CData', I);&lt;br&gt;
&lt;br&gt;
axis tight;&lt;br&gt;
&lt;br&gt;
hf = ancestor(hObject, 'Figure');&lt;br&gt;
guidata(hf, h);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
function axes_moveImage(hObject, eventdata)&lt;br&gt;
&lt;br&gt;
h = guidata(hObject);&lt;br&gt;
&lt;br&gt;
AxesXLim = get(hObject, 'XLim');&lt;br&gt;
AxesYLim = get(hObject, 'YLim');&lt;br&gt;
Axes2Pos = get(h.axes(2), 'Position');&lt;br&gt;
&lt;br&gt;
% Cursor position is in axes data units&lt;br&gt;
% Get cursor position in normalized units&lt;br&gt;
CursorPosition = get(hObject, 'CurrentPoint'); %in axes data units&lt;br&gt;
CursorPositionN = [CursorPosition(1, 1)/AxesXLim(2) CursorPosition(1, 2)/AxesYLim(2)];&lt;br&gt;
&lt;br&gt;
% Use cursor position (within axes 1) to find same relative position in&lt;br&gt;
% axes 2&lt;br&gt;
Axes3Pos = get(h.axes(3), 'Position');&lt;br&gt;
NewAxes3Pos(1:2) = CursorPositionN.*Axes2Pos(3:4) + Axes2Pos(1:2);&lt;br&gt;
NewAxes3Pos(3:4) = Axes3Pos(3:4);&lt;br&gt;
&lt;br&gt;
set(h.axes(3), 'Position', NewAxes3Pos);</description>
    </item>
  </channel>
</rss>

