Hi,
I have a piece of code that I am using to select some points on an image. I have a crosshair, which moves across the screen to select the points by a mouse click. Is there an easy way that I can put a small box beside the crosshair, which will show the x and y coordinates as I move the crosshair about over the image? Here is the code that I am trying to implement this with.....
X_out = [];
Y_out = [];
for i=1:n,
[px py ] = ginput(1);
X_out = [X_out ; px];
Y_out = [Y_out ; py];
plot( px, py, 'r+' );
text_handle = text( px+5, py, num2str(i) );
set(text_handle,'Color',[1 1 1])
end
Many Thanks,
Robbie
|
|
0
|
|
|
|
Reply
|
Robbie
|
11/18/2010 8:29:05 AM |
|
"Robbie " <rstevens01@qub.ac.uk> wrote in message <ic2o4h$rn4$1@fred.mathworks.com>...
> Hi,
>
> I have a piece of code that I am using to select some points on an image. I have a crosshair, which moves across the screen to select the points by a mouse click. Is there an easy way that I can put a small box beside the crosshair, which will show the x and y coordinates as I move the crosshair about over the image? Here is the code that I am trying to implement this with.....
>
> X_out = [];
> Y_out = [];
> for i=1:n,
> [px py ] = ginput(1);
> X_out = [X_out ; px];
> Y_out = [Y_out ; py];
> plot( px, py, 'r+' );
> text_handle = text( px+5, py, num2str(i) );
> set(text_handle,'Color',[1 1 1])
> end
>
> Many Thanks,
>
> Robbie
Robbie,
this works for me:
X_out = [];
Y_out = [];
n=3 ; figure ; xlim([0,1]); ylim([0,1]) ; hold on ; offset = 0.05; %added
for i=1:n,
[px py ] = ginput(1);
X_out = [X_out ; px];
Y_out = [Y_out ; py];
plot( px, py, 'r+' );
% text_handle = text( px+5, py, num2str(i) );
text_handle = text( px+offset, py, num2str(i) ); % changed
% set(text_handle,'Color',[1 1 1])
set(text_handle,'Color',[0 0 0]) % changed
end
Regards Han
|
|
0
|
|
|
|
Reply
|
Han
|
11/18/2010 9:11:09 AM
|
|
"Han Oostdijk" <han.remove.oostdijk@euronet.nl> wrote in message <ic2qjd$d2n$1@fred.mathworks.com>...
> "Robbie " <rstevens01@qub.ac.uk> wrote in message <ic2o4h$rn4$1@fred.mathworks.com>...
> > Hi,
> >
> > I have a piece of code that I am using to select some points on an image. I have a crosshair, which moves across the screen to select the points by a mouse click. Is there an easy way that I can put a small box beside the crosshair, which will show the x and y coordinates as I move the crosshair about over the image? Here is the code that I am trying to implement this with.....
> >
> > X_out = [];
> > Y_out = [];
> > for i=1:n,
> > [px py ] = ginput(1);
> > X_out = [X_out ; px];
> > Y_out = [Y_out ; py];
> > plot( px, py, 'r+' );
> > text_handle = text( px+5, py, num2str(i) );
> > set(text_handle,'Color',[1 1 1])
> > end
> >
> > Many Thanks,
> >
> > Robbie
>
> Robbie,
>
> this works for me:
>
> X_out = [];
> Y_out = [];
> n=3 ; figure ; xlim([0,1]); ylim([0,1]) ; hold on ; offset = 0.05; %added
> for i=1:n,
> [px py ] = ginput(1);
> X_out = [X_out ; px];
> Y_out = [Y_out ; py];
> plot( px, py, 'r+' );
> % text_handle = text( px+5, py, num2str(i) );
> text_handle = text( px+offset, py, num2str(i) ); % changed
> % set(text_handle,'Color',[1 1 1])
> set(text_handle,'Color',[0 0 0]) % changed
> end
>
> Regards Han
Hi Han,
Thanks for taking a look - that kind of works, however It only displays the coordinate value after I have clicked, I was kind of hoping there would be a way to 'dynamically' display the coordinates as you move the mouse over the figure, as a means to help selection of the point to click - I have tried using gtext, but it doesn't seem to work.
Thanks again,
Robbie
|
|
0
|
|
|
|
Reply
|
Robbie
|
11/18/2010 9:43:19 AM
|
|
>
> Hi Han,
>
> Thanks for taking a look - that kind of works, however It only displays the coordinate value after I have clicked, I was kind of hoping there would be a way to 'dynamically' display the coordinates as you move the mouse over the figure, as a means to help selection of the point to click - I have tried using gtext, but it doesn't seem to work.
>
> Thanks again,
>
> Robbie
Robbie,
take a look at Yair Altman's webpage
http://undocumentedmatlab.com/blog/undocumented-cursorbar-object/
Maybe this will help you or give you some ideas.
If you read this Yair: thanks for your 'Undocumented Matlab" series !
Han
|
|
0
|
|
|
|
Reply
|
Han
|
11/18/2010 10:16:04 AM
|
|
Thanks Han, your help is much appreciated!
|
|
0
|
|
|
|
Reply
|
Robbie
|
11/18/2010 10:33:06 AM
|
|
Robbie:
Did you see the function called impixelinfo? It does that. It's in
the Image Processing Toolbox.
impixelinfo
Pixel Information tool
Syntax
impixelinfo
impixelinfo(h)
impixelinfo(hparent,himage)
hpanel = impixelinfo(...)
Description
impixelinfo creates a Pixel Information tool in the current figure.
The Pixel Information tool displays information about the pixel in an
image that the pointer is positioned over. The tool can display pixel
information for all the images in a figure.
The Pixel Information tool is a uipanel object, positioned in the
lower-left corner of the figure. The tool contains the text string
Pixel info: followed by the pixel information. Before you move the
pointer over the image, the tool contains the default pixel
information text string (X,Y) Pixel Value. Once you move the pointer
over the image, the information displayed varies by image type, as
shown in the following table. If you move the pointer off the image,
the pixel information tool displays the default pixel information
string for that image type.
|
|
0
|
|
|
|
Reply
|
ImageAnalyst
|
11/18/2010 11:11:31 AM
|
|
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <53335882-d224-4aaa-800f-2f2e31fe0d20@e20g2000vbn.googlegroups.com>...
> Robbie:
> Did you see the function called impixelinfo? It does that. It's in
> the Image Processing Toolbox.
>
>
> impixelinfo
>
> Pixel Information tool
> Syntax
>
> impixelinfo
> impixelinfo(h)
> impixelinfo(hparent,himage)
> hpanel = impixelinfo(...)
> Description
>
> impixelinfo creates a Pixel Information tool in the current figure.
> The Pixel Information tool displays information about the pixel in an
> image that the pointer is positioned over. The tool can display pixel
> information for all the images in a figure.
>
> The Pixel Information tool is a uipanel object, positioned in the
> lower-left corner of the figure. The tool contains the text string
> Pixel info: followed by the pixel information. Before you move the
> pointer over the image, the tool contains the default pixel
> information text string (X,Y) Pixel Value. Once you move the pointer
> over the image, the information displayed varies by image type, as
> shown in the following table. If you move the pointer off the image,
> the pixel information tool displays the default pixel information
> string for that image type.
Hi,
Thanks for letting me know about this function - I do have the image processing toolbox available. I have tried implementing this, but without success, any suggestions as to how it would it be implemented in the code I proposed? The function I gave above is called multiple times for different images, so I cannot 'hard code' a specific image, so any workarounds for this would be useful!
Best Regards,
Robbie
|
|
0
|
|
|
|
Reply
|
Robbie
|
11/18/2010 1:25:05 PM
|
|
"Han Oostdijk" <han.remove.oostdijk@euronet.nl> wrote in message <ic2ud4$he4$1@fred.mathworks.com>...
>
> >
> > Hi Han,
> >
> > Thanks for taking a look - that kind of works, however It only displays the coordinate value after I have clicked, I was kind of hoping there would be a way to 'dynamically' display the coordinates as you move the mouse over the figure, as a means to help selection of the point to click - I have tried using gtext, but it doesn't seem to work.
> >
> > Thanks again,
> >
> > Robbie
>
> Robbie,
>
> take a look at Yair Altman's webpage
> http://undocumentedmatlab.com/blog/undocumented-cursorbar-object/
> Maybe this will help you or give you some ideas.
>
> If you read this Yair: thanks for your 'Undocumented Matlab" series !
>
> Han
My pleasure :-)
Yair Altman
http://UndocumentedMatlab.com
|
|
0
|
|
|
|
Reply
|
Yair
|
11/18/2010 4:55:25 PM
|
|
|
7 Replies
696 Views
(page loaded in 0.129 seconds)
|