matplotlib image tutorial

Here you go. If you can think of anything else to include, I'll work
on it. I think the next thing I'll add is something on embedding
images in the corners of plots. figimage is the way to do this,
right?

It depends on exactly what you are trying to do -- figimage is a pure
pixel dump, so it doesn't scale with DPI. It is good for people who
want to put raw data into a figure, but not for much else. You can
also use the "extent" argument to a regular image to

The image is on that I took, so don't worry about licensing on it. My
images are licensed under Creative Commons.

Great -- I've pushed this out to the website. Thanks a lot. You can
see the fruits of your labors at

http://matplotlib.sourceforge.net/users/image_tutorial.html

If you want to make any more enhancements, the easiest way for me is
to submit a diff against the 0.99 release branch

> svn co https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_99_maint
mpl99
  # make your edits
> svn diff > imagetut.diff

See also, http://matplotlib.sourceforge.net/faq/howto_faq.html#contributing-howto

As for stuff to be added, here is a laundry list after a quick once
over, in no particular order

  * pointers to the matplotlib.colors, matplotlib.cm,
matplotlib.colorbar api docs

  * port the matplotlib.image module to have rest compliant docs,
incorporate them into the api docs, and link to them from the tutorial

  * discuss the image aspect settings with some examples

  * show how to use the matplotlib.cm objects, eg cm.jet, cm.hot in
addition to the strings 'jet', 'hot'

  * adjusting the size of the colorbar so it is the same height as your image

  * show how to create a custom colormap (there are examples for this
you could follow), either using listed colors or writing your own
linear segmented colormap

  * discuss figimage

  * discuss the extent argument

For many of these, if you don't know how to get started, read the doc
strings and then go to the search page and use the codex argument to
search for code examples. Eg a search for "codex imshow extent" will
show image examples that use the extent kwarg

  Search — Matplotlib 3.8.2 documentation

Going forward, if you have further questions or need pointers to docs
or examples, please post to matplotlib-devel and let people know what
you are doing. I sometimes get swallowed by all the stuff I am doing
so cannot always answer promptly, so it is good to have some backup.
I've take the liberty of CC-ing the devel list here in case others
want to jump in with suggestions or contributions to the tutorial

  matplotlib-devel List Signup and Options

Thanks a lot for this -- the docs are making a lot of progress and
there is a ton of good stuff in mpl that still has no tutorial on how
to use it, so this is plugging one of those holes.

JDH

···

On Sat, Aug 29, 2009 at 10:58 AM, Michael Sarahan<mcsarahan@...594...> wrote:

Very nice addition Michael.

I note that the plt.colormap() line must have gotten lost. It's referred to but not there.
I'll add some ideas to John's list:

* Demonstrate the imsave() command.
* Rather than show 50 lines or so of array data, just show a few lines, but demonstrate what img.shape is before and after slicing out the B channel with img[:,:,0]
* It may be worth mentioning explicitly that img[:,:,0] will give you the blue channel for an RGB and an RGBA image.
* Demonstrate the "upper" and "lower" keywords where relevant.
* Add a pointer to the scipy.ndimage module
* Extend the examples with RGB and RGBA images.
* You might like to show how to recarrays and views on the individual colour channels. There are examples in the mailing list archives or maybe on the scipy website - I can't remember where.
* If you want to get more advanced, talk about higher bit depth images than 8 bits per channel.
* If you want to get even more advanced, show how to change the UI to probe the pixel value (I wish matplotlib did this by default).

Gary R.

John Hunter wrote:

···

On Sat, Aug 29, 2009 at 10:58 AM, Michael Sarahan<mcsarahan@...594...> wrote:

Here you go. If you can think of anything else to include, I'll work
on it. I think the next thing I'll add is something on embedding
images in the corners of plots. figimage is the way to do this,
right?

Great suggestions. I'll find time to work on them in the near future,
hopefully.

-Mike

···

On Sat, Aug 29, 2009 at 6:06 PM, Gary Ruben<gruben@...1...> wrote:

Very nice addition Michael.

I note that the plt.colormap() line must have gotten lost. It's referred to
but not there.
I'll add some ideas to John's list:

* Demonstrate the imsave() command.
* Rather than show 50 lines or so of array data, just show a few lines, but
demonstrate what img.shape is before and after slicing out the B channel
with img[:,:,0]
* It may be worth mentioning explicitly that img[:,:,0] will give you the
blue channel for an RGB and an RGBA image.
* Demonstrate the "upper" and "lower" keywords where relevant.
* Add a pointer to the scipy.ndimage module
* Extend the examples with RGB and RGBA images.
* You might like to show how to recarrays and views on the individual colour
channels. There are examples in the mailing list archives or maybe on the
scipy website - I can't remember where.
* If you want to get more advanced, talk about higher bit depth images than
8 bits per channel.
* If you want to get even more advanced, show how to change the UI to probe
the pixel value (I wish matplotlib did this by default).

Gary R.

John Hunter wrote:

On Sat, Aug 29, 2009 at 10:58 AM, Michael Sarahan<mcsarahan@...594...> >> wrote:

Here you go. If you can think of anything else to include, I'll work
on it. I think the next thing I'll add is something on embedding
images in the corners of plots. figimage is the way to do this,
right?

I was looking through this, and have a suggestion as well:

You have a line that reads
In[10]: plt.hist(lum_img)

This should probably be
plt.hist(lum_img.ravel(),bins=<some larger number>)

As it is right now, you are making a histogram of each line
individually, and my experience has been that this tends to cause
issues (memory and confusion-related) with relatively large images.

···

On Wed, Sep 2, 2009 at 6:42 AM, Michael Sarahan <mcsarahan@...594...> wrote:

Great suggestions. I'll find time to work on them in the near future,
hopefully.

-Mike

On Sat, Aug 29, 2009 at 6:06 PM, Gary Ruben<gruben@...1...> wrote:

Very nice addition Michael.

I note that the plt.colormap() line must have gotten lost. It's referred to
but not there.
I'll add some ideas to John's list:

* Demonstrate the imsave() command.
* Rather than show 50 lines or so of array data, just show a few lines, but
demonstrate what img.shape is before and after slicing out the B channel
with img[:,:,0]
* It may be worth mentioning explicitly that img[:,:,0] will give you the
blue channel for an RGB and an RGBA image.
* Demonstrate the "upper" and "lower" keywords where relevant.
* Add a pointer to the scipy.ndimage module
* Extend the examples with RGB and RGBA images.
* You might like to show how to recarrays and views on the individual colour
channels. There are examples in the mailing list archives or maybe on the
scipy website - I can't remember where.
* If you want to get more advanced, talk about higher bit depth images than
8 bits per channel.
* If you want to get even more advanced, show how to change the UI to probe
the pixel value (I wish matplotlib did this by default).

Gary R.

John Hunter wrote:

On Sat, Aug 29, 2009 at 10:58 AM, Michael Sarahan<mcsarahan@...594...> >>> wrote:

Here you go. If you can think of anything else to include, I'll work
on it. I think the next thing I'll add is something on embedding
images in the corners of plots. figimage is the way to do this,
right?

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

Hi Michael,

Here you go. If you can think of anything else to include, I'll work
on it. I think the next thing I'll add is something on embedding
images in the corners of plots. figimage is the way to do this,
right?

This is very nice, many thanks! If you are interested, I think that a
presentation on this would be very well received at the informal
scientific computing in python group that I coordinate at UC Berkeley:

https://cirl.berkeley.edu/view/Py4Science

I don't know how convenient it is for you to make the trip, but if
it's possible, we'd love to have you do a presentation on image
processing. Just let me know any time, it's best if you write
directly to my work address:

Fernando.Perez@...453...

in case I miss a message on the mailing lists (I monitor that address
much more closely).

Cheers,

f

···

On Sat, Aug 29, 2009 at 9:45 AM, John Hunter <jdh2358@...149...> wrote:

On Sat, Aug 29, 2009 at 10:58 AM, Michael Sarahan<mcsarahan@...594...> wrote: