imagesc

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

imagesc

pathematica
octave 3.23/ubuntu 10.04

I would be grateful if someone could explain how to use imagesc(). If it is clear to someone who knows how to use it that I do not have the necessary insight and remedial education is not a practical option in this forum, please do not be afraid to say so in this forum - I will not be offended!

I was hoping (I might have misunderstood) that it allows scaling of images so that a suitable sized raster image might be plotted for rendering in a browser.

Following the instructions in the manual, I have installed xloadimage (into ubuntu) using the Synaptic Package Manager.

% the following is just a random plot (not important) to illustrate the point
tx = ty = linspace (0, 3, 31)';
[xx, yy] = meshgrid (tx, ty);
tz = exp(-xx);
mesh (tx, ty, tz);
box("off"); hold("on");
% end of plot

% then, intending to scale by 0.5, I have tried the following (I am embarrassed to admit I am not sure how to interpret the 'x' given in the manual):

imagesc(x, 0.5);

% with the hope of printing a scaled png image with eg
print -dpng filename.png

This yields the following error messages
error: `x' undefined near line () column ()
error: evaluating argument list element number 1
error: evaluating argument list element number 1

I apologise if my reading of the function is naive and this looks stupid! Still, I have no pride and I will not be offended if someone merely lets me know that I do not have the necessary skills or insight to use the function :-)
However good you think Octave is, it's much, much better.
Reply | Threaded
Open this post in threaded view
|

RE: imagesc

William Krekeler


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of pathematica
Sent: Thursday, July 28, 2011 12:44 PM
To: [hidden email]
Subject: imagesc

octave 3.23/ubuntu 10.04

I would be grateful if someone could explain how to use imagesc(). If it is
clear to someone who knows how to use it that I do not have the necessary
insight and remedial education is not a practical option in this forum,
please do not be afraid to say so in this forum - I will not be offended!

I was hoping (I might have misunderstood) that it allows scaling of images
so that a suitable sized raster image might be plotted for rendering in a
browser.

Following the instructions in the manual, I have installed xloadimage (into
ubuntu) using the Synaptic Package Manager.

% the following is just a random plot (not important) to illustrate the
point
tx = ty = linspace (0, 3, 31)';
[xx, yy] = meshgrid (tx, ty);
tz = exp(-xx);
mesh (tx, ty, tz);
box("off"); hold("on");
% end of plot

% then, intending to scale by 0.5, I have tried the following (I am
embarrassed to admit I am not sure how to interpret the 'x' given in the
manual):

imagesc(x, 0.5);

% with the hope of printing a scaled png image with eg
print -dpng filename.png

This yields the following error messages
error: `x' undefined near line () column ()
error: evaluating argument list element number 1
error: evaluating argument list element number 1

I apologise if my reading of the function is naive and this looks stupid!
Still, I have no pride and I will not be offended if someone merely lets me
know that I do not have the necessary skills or insight to use the function
:-)


--
View this message in context: http://octave.1599824.n4.nabble.com/imagesc-tp3701954p3701954.html
Sent from the Octave - General mailing list archive at Nabble.com.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave

Imagesc works great and creates its own scaling if you just give it a matrix as input. I generally don't try to scale be a specific value though you could provide limits over the range of which to scale.

% examples
X = rand(100,100).*(2^14); % you can't plot this 14 bit image in 8 bit image space
figure,imagesc(X); colorbar % but you can plot it scaled
or you could apply limits
figure, imagesc( X, [ 6000 10000 ] ); colorbar; % or limit the range of presented data to be scaled to 6000 to 10000

% start specific explanations
Note often times the documentation for Matlab found online closely links or directly matches the Octave functions.

imagesc(x,y,C) displays C as an image and specifies the bounds of the x- and y-axis with vectors x and y. If x(1) > x(2) or y(1) > y(2), the image is flipped left-right or up-down, respectively
imagesc(...,clims) normalizes the values in C to the range specified by clims and displays C as an image. clims is a two-element vector that limits the range of data values in C. These values map to the full range of values in the current colormap.

Hope that helps.

Bill Krekeler
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

RE: imagesc

pathematica
This post was updated on .
Thanks for the replies (including Przemek, whose reply has not made it onto the board).

On reflection, what I intended to ask is whether imagesc() might be used in a compound function taking the output of another function as its argument.

I wondered whether the plot function might produce something that resembled the appropriate matrix of RGB values to which imagesc() might be applied, so that it might be possible to do something along the lines of (I realise that this might look naive but I was hoping that some modification of it might work)

> x = SomeVector
> SomeObject = imagesc(plot(x, f(x)), SomeScale)

(Then, of course, find some way to print the SomeObject into a file).

Again, don't worry if my question cannot be answered in a sensible way here because I have not grasped how the various functions work. :-)
However good you think Octave is, it's much, much better.
Reply | Threaded
Open this post in threaded view
|

RE: imagesc

William Krekeler


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of pathematica
Sent: Thursday, July 28, 2011 2:51 PM
To: [hidden email]
Subject: RE: imagesc

Thanks for the replies (including Przemek, whose reply has not made it onto
the board).

On reflection, what I intended to ask is whether imagesc() might be used in
a compound function taking the output of another function as its argument.

I wondered whether the plot function might produce something that resembled
the appropriate matrix of RGB values to which imagesc() might be applied, so
that it might be possible to do something along the lines of (I realise that
this might look naive but I was hoping that some modification of it might
work)

> x = SomeVector
> SomeObject = imagesc(plot(x, f(x), SomeScale)

(Then, of course, find some way to print the SomeObject into a file).

Again, don't worry if my question cannot be answered in a sensible way here
because I have not grasped how the various functions work. :-)


--
View this message in context: http://octave.1599824.n4.nabble.com/imagesc-tp3701954p3702322.html
Sent from the Octave - General mailing list archive at Nabble.com.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave

You want:

X = somevector;
figHandle = imagesc( X );
scaled = get( figHandle, 'CData' ); % note get( figHandle ) will list all properties

scaled is a vector with value 0-1 for each data point in the array.

Bill Krekeler
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

RE: imagesc

pathematica
Thanks to everyone. I understand its role a little better and I certainly have enough to experiment.

Best wishes

However good you think Octave is, it's much, much better.
Reply | Threaded
Open this post in threaded view
|

RE: imagesc

pathematica
A recent post alerted me to the solution that I was seeking for this problem.
So thanks goes to Max Wilkinson and Liam Groener.
I had not phrased the problem well.

I hope you will not mind if I reproduce the solution to the problem I was seeking (in case others have searched for a solution to the same problem and are using search terms similar to the ones I was using - they might find this thread).

The type of scaling I was seeking (to allow posting on a webpage) requires the command

print '-S450,300' filename.png

where '-S###,###' denotes size in pixels.

Thanks guys.
However good you think Octave is, it's much, much better.