help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function works with number literal but not with variable


From: Sergei Steshenko
Subject: Re: Function works with number literal but not with variable
Date: Wed, 16 Dec 2009 15:15:49 -0800 (PST)


--- On Wed, 12/16/09, George <address@hidden> wrote:

> From: George <address@hidden>
> Subject: Re: Function works with number literal but not with variable
> To: address@hidden
> Date: Wednesday, December 16, 2009, 3:43 AM
> On Wed, Dec 16, 2009 at 11:36 AM,
> George <address@hidden>
> wrote:
> > imshow doesn't work if an image contains both positive
> and negative
> > values. So I tried to write a wrapper for imshow that
> will scale the
> > image so that all the elements are positive. So I call
> imshow from
> > within my function. The problem is that it doesn't
> work if I pass the
> > limits from variables, but it works if I type them as
> numbers. So this
> > code doesn't work:
> >
> >        minVal = min(min(image));
> >        maxVal = max(max(image));
> >        [rows, columns] = size(image);
> >        normalized = image - ones(rows,columns) *
> (minVal);
> >        minVal = min(min(normalized));
> >        maxVal = max(max(normalized)); % for my
> test image this is 44.2, I
> > can see it if I remove the semicolon
> >        imshow(normalized, [0, maxVal]);
> >
> > But it works if I change the last line to this:
> >
> >        imshow(normalized, [0, 44.2]);
> >
> > Two questions here:
> >
> > Why does this happen?
> > Why doesn't imshow work with images that have both
> positive and negative values?
> 
> I found that the problem was that my image was of type
> 'single'. If I
> convert it to 'double' imshow works. Is this a bug? I think
> so.
> 
> _______________________________________________


If you think the behavior is wrong, you should provide a better proof.

For example, a proof that in non-working code maxVal is a (reasonable) 
number and not, say a vector or a matrix - otherwise working and-non
working variants of code are not equivalent.

Secondly, I guess the developers would like a test image which triggers
the bug - if it's a bug.

Regards,
  Sergei.


      



reply via email to

[Prev in Thread] Current Thread [Next in Thread]