DSPRelated.com
Forums

getting output

Started by Justice February 4, 2005

Hello,

I want to get pixel values from the image interactively.... I have tried to use
pixval(fig,option) but I cant get its output to some other variables/parameters...

for instance, I tried .....

I =imread('C:\myimage.gif')
[x,y, d] =pixval(I, 'on'),
where my aim is to get X , Y values and d(=Euclidean distance), while moving my cursor on the image.

what is wrong with my approach? can anyone suggest the best way to get these values into other variables and not just to have have them displayed on the image?

Any word of help is appreciated.

Thanks,
Justice



Hi,
The function bellow is a partial solution. There is 2
disadvantages:
1) The values are updated only when you press a mouse
button.
2) The distance is not displayed or given in the
output (this is easy to correct by adding a simple
calculation to the function).
*code*
function C=pixvalout(A,B)
% To stop press CTRL
persistent h
C='';
if nargin == 0
pixval
elseif nargin==1
pixval(A)
else
pixval(A,B)
end
while 1
waitforbuttonpress
if isempty(h)
h=findobj(allchild(gcf),'tag','pixel value
display bar');
end
if ishandle(h) &
double(get(gcf,'CurrentCharacter'))~=2
C=strvcat(C,get(h,'String'));
else
break
end
end
*code end*

Joe Sababa

BSTeX - Equation viewer for Matlab
http://www.geocities.com/bstex2001/

--- Justice <> wrote:

>
> Hello,
>
> I want to get pixel values from the image
> interactively.... I have tried to use
> pixval(fig,option) but I cant get its output to some
> other variables/parameters...
>
> for instance, I tried .....
>
> I =imread('C:\myimage.gif')
> [x,y, d] =pixval(I, 'on'),
> where my aim is to get X , Y values and
> d(=Euclidean distance), while moving my cursor on
> the image.
>
> what is wrong with my approach? can anyone suggest
> the best way to get these values into other
> variables and not just to have have them displayed
> on the image?
>
> Any word of help is appreciated.
>
> Thanks,
> Justice

__________________________________