help-octave
[Top][All Lists]
Advanced

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

Re: function image do't work!


From: Søren Hauberg
Subject: Re: function image do't work!
Date: Tue, 25 Dec 2007 19:14:52 +0100

Hi,
  I don't have a Mac, so I can't solve your problem, but I do have som
comments/questions.

tir, 25 12 2007 kl. 18:42 +0800, skrev 小笨童:
> I use octave 3.0.0 with gnuplot 4.0 & aquaterm1.0.1
Where did you get your version of Octave from? Is it the Octave.app from
octave.sf.net? If so, are you using the gnuplot binary that comes with
this file?


> img=zeros([20 20]);
> [sizeY sizeX]=size(img);
>
> offset=2
> img((sizeY/2-offset):(sizeY/2+1+offset), (sizeX/2-offset):(sizeX/2+1
> +offset))=1;
> figure; imshow(img, [min(min(img)) max(max(img))]);
This code works fine for me on Linux with gnuplot 4.2.2. I have some
comments on your program though...
First of all you should try to put commas between elements in vectors.
That is, don't write
  img=zeros([20 20]);
but instead, write
  img=zeros([20, 20]);
You can avoid some hard-to-understand bugs, if you do this.
  Your image contains values between 0 and 1, so there is no need to
change the display range when you call 'imshow'. That is, you might as
well write
  imshow(img);
instead of
  imshow(img, [min(min(img)) max(max(img))]);
For speed (and simplicity) issues it is better to write 'min(img(:))'
when you want the smallest value in the matrix (same goes for 'max').

Hope somebody else can solve your gnuplot issues,
Søren




reply via email to

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