help-octave
[Top][All Lists]
Advanced

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

Re: image from matrix at original size [newbie]


From: Ben Abbott
Subject: Re: image from matrix at original size [newbie]
Date: Mon, 26 Dec 2011 18:45:12 -0500

On Dec 26, 2011, at 12:01 PM, marasolc wrote:

> Thank you,
> 
> yes, I want to display image with same number of pixels as is the
> matrix(1024x256).
> The following code adjusts the size quite well, but still the number of
> pixels is not exactly the same:
> 
> s = size(img)(1:2);
> set(gcf, "position", [0 0 1500 300])
> set(gca, "position", [0.05 0.05 0.05+1024/1500 0.05+256/300])
> imagesc(img,[minv maxv]);
> colorbar();
> print("image.png","-dpng","-S1500,300")
> 
> I just wondered whether there is some simple and safe way how to display the
> matrix so that every number corresponds to one pixel (and colorbar
> attached).

Octave's gnuplot backend doesn't support changing the figure position after the 
figure has been created.

You'll need to set the figure's position property when it is created. The 
script below works for me.

margin = 100;
width = 1024;
height = 256;
fwidth = width + 2*margin;
fheight = height + 2*margin;
fpos = [0 0 fwidth fheight];
apos = [margin/fwidth, margin/fheight, width/fwidth,  height/fheight];

figure ("position", fpos)
clf
image (rand (width, height), "cdatamapping", "scaled")
set (gca, "position", apos);

Ben


reply via email to

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