help-octave
[Top][All Lists]
Advanced

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

Function works with number literal but not with variable


From: George
Subject: Function works with number literal but not with variable
Date: Wed, 16 Dec 2009 11:36:58 +0000

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?


reply via email to

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