strange behavior with imshow

Hello everybody,

I am experiencing a strange behavior with the imshow() function when
using the nearest interpolation method.

Executing the code listed below, I obtain a good image when using the bilinear interpolation method

and a totally white image when using the nearest interpolation method.
I have attached the input data buffer and the resulting images too.

import numpy as n
import pylab as p

input data

dataFile = “/users/lelepass/python/test_imagesc/buffer.float”

samples = 15
lines = 39
imagescCanvasXDim = 800
imagescCanvasDpi = 100
data_aspect_ratio = 0.75707855955290304
vMin = -3.3467740682968197
vMax = 0.65322593170318011
outImageFileBilinear = “/users/lelepass/python/test_imagesc/subpxAzBilinear.png”

outImageFileNearest = “/users/lelepass/python/test_imagesc/subpxAzNearest.png”

loading input data file

s = file(dataFile, ‘rb’).read()
data = n.fromstring(s, ‘f’)
data.shape = lines, samples

data = n.transpose(data)

image canvas dimension setting

xAxisInches = float(imagescCanvasXDim) / float(imagescCanvasDpi)
yPixelsDim = imagescCanvasXDim * data_aspect_ratio
yAxisInches = float(yPixelsDim) / float(imagescCanvasDpi)

buffer.float (2.29 KB)

subpxAzBilinear.png

subpxAzNearest.png

···

################################

bilinear image

################################

image canvas

canvasObj = p.figure(facecolor=“w”, edgecolor=“w”, figsize=(xAxisInches, yAxisInches), frameon=True, dpi=imagescCanvasDpi)

axis setting

axisLocationList = [0,0,1,1]
axisObj = canvasObj.add_axes(axisLocationList)
axisObj.axesPatch.set_alpha(1)

colormap

colorMap = p.cm.jet_r

bilinear image drawing

p.imshow(data, cmap=colorMap, vmin=vMin, vmax=vMax, interpolation=“bilinear”, origin=“lower”, aspect=“auto”, alpha=1)

reversing = axisObj.set_ylim(axisObj.get_ylim()[::-1])

bilinear image saving and closing

canvasObj.savefig(outImageFileBilinear, dpi=imagescCanvasDpi)
p.close()

################################

nearest image

################################

image canvas

canvasObj = p.figure(facecolor=“w”, edgecolor=“w”, figsize=(xAxisInches, yAxisInches), frameon=True, dpi=imagescCanvasDpi)

axis setting

axisLocationList = [0,0,1,1]

axisObj = canvasObj.add_axes(axisLocationList)
axisObj.axesPatch.set_alpha(1)

colormap

colorMap = p.cm.jet_r

nearest image drawing

p.imshow(data, cmap=colorMap, vmin=vMin, vmax=vMax, interpolation=“nearest”, origin=“lower”, aspect=“auto”, alpha=1)

reversing = axisObj.set_ylim(axisObj.get_ylim()[::-1])

nearest image saving and closing

canvasObj.savefig(outImageFileNearest, dpi=imagescCanvasDpi)
p.close()

I use matplotlib to generate a lot of images in batch mode and this

behavior appear not to be deterministic. It seems to depend on the input data buffer.
Can anyone help me ?

I use
Linux openSUSE 11.3 (x86_64)
Linux sat1 2.6.34.7-0.7-default #1 SMP 2010-12-13 11:13:53 +0100 x86_64 x86_64 x86_64 GNU/Linux

Python 2.6.5
numpy 1.5.1
matplotlib 1.0.1 with backend Agg v2.2

If it can be of some help this strange behavior does not appear with a system
Linux Ubuntu 9.10
Linux joshua 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:48:10 UTC 2009 i686 GNU/Linux

Python 2.6.4
numpy 1.3.0
matplotlib 0.99.0 with backend Agg v2.2

Executing the script with verbosity I get the subsequent output
python /users/lelepass/python/test_imagesc/test.py --verbose-helpful

$HOME=/users/lelepass
CONFIGDIR=/users/lelepass/.matplotlib

Bad key “numerix” on line 30 in
/users/lelepass/.matplotlib/matplotlibrc.
You probably need to get an updated matplotlibrc file from

http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution
matplotlib data path /usr/lib64/python2.6/site-packages/matplotlib/mpl-data

loaded rc file /users/lelepass/.matplotlib/matplotlibrc
matplotlib version 1.0.1
verbose.level helpful
interactive is False
units is True
platform is linux2
Using fontManager instance from /users/lelepass/.matplotlib/fontList.cache

backend agg version v2.2
findfont: Matching :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium to Bitstream Vera Sans (/usr/lib64/python2.6/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf) with score of 0.000000

Thank you all.
Bye.

Emanuele Passera

Software Engineer

Tele-Rilevamento Europa - T.R.E. srl
Via Vittoria Colonna, 7
20149 Milano – Italia
Tel.: +39.02.4343.121 - Fax: +39.02.4343.1230

emanuele.passera@…1676… - www.treuropa.com


This communication, that may contain confidential and/or legally privileged information, is intended solely for the use of the intended addressees. Opinions, conclusions and other information contained in this message, that do not relate to the official business of this firm, shall be considered as not given or endorsed by it. Every opinion or advice contained in this communication is subject to the terms and conditions provided by the agreement governing the engagement with such a client. If you have received this communication in error, please notify us immediately by responding to this email and then delete it from your system. Any use, disclosure, copying or distribution of the contents of this communication by a not-intended recipient or in violation of the purposes of this communication is strictly prohibited and may be unlawful.

I have checked with all the interpolation modes and the only one that
behaves badly is 'nearest'. There are them:
http://dl.dropbox.com/u/1351211/Interpolation_modes.zip

···

On Mon, Apr 18, 2011 at 12:46 PM, Emanuele Passera <emanuele.passera@...1676...> wrote:

Hello everybody,

I am experiencing a strange behavior with the imshow() function when
using the nearest interpolation method.

Executing the code listed below, I obtain a good image when using the
bilinear interpolation method
and a totally white image when using the nearest interpolation method.
I have attached the input data buffer and the resulting images too.

import numpy as n
import pylab as p

# input data
dataFile = "/users/lelepass/python/test_imagesc/buffer.float"
samples = 15
lines = 39
imagescCanvasXDim = 800
imagescCanvasDpi = 100
data_aspect_ratio = 0.75707855955290304
vMin = -3.3467740682968197
vMax = 0.65322593170318011
outImageFileBilinear =
"/users/lelepass/python/test_imagesc/subpxAzBilinear.png"
outImageFileNearest =
"/users/lelepass/python/test_imagesc/subpxAzNearest.png"

# loading input data file
s = file(dataFile, 'rb').read()
data = n.fromstring(s, 'f')
data.shape = lines, samples
data = n.transpose(data)

# image canvas dimension setting
xAxisInches = float(imagescCanvasXDim) / float(imagescCanvasDpi)
yPixelsDim = imagescCanvasXDim * data_aspect_ratio
yAxisInches = float(yPixelsDim) / float(imagescCanvasDpi)

################################
# bilinear image #
################################
# image canvas
canvasObj = p.figure(facecolor="w", edgecolor="w", figsize=(xAxisInches,
yAxisInches), frameon=True, dpi=imagescCanvasDpi)
# axis setting
axisLocationList = [0,0,1,1]
axisObj = canvasObj.add_axes(axisLocationList)
axisObj.axesPatch.set_alpha(1)
# colormap
colorMap = p.cm.jet_r
# bilinear image drawing
p.imshow(data, cmap=colorMap, vmin=vMin, vmax=vMax,
interpolation="bilinear", origin="lower", aspect="auto", alpha=1)
reversing = axisObj.set_ylim(axisObj.get_ylim()[::-1])
# bilinear image saving and closing
canvasObj.savefig(outImageFileBilinear, dpi=imagescCanvasDpi)
p.close()

################################
# nearest image #
################################
# image canvas
canvasObj = p.figure(facecolor="w", edgecolor="w", figsize=(xAxisInches,
yAxisInches), frameon=True, dpi=imagescCanvasDpi)
# axis setting
axisLocationList = [0,0,1,1]
axisObj = canvasObj.add_axes(axisLocationList)
axisObj.axesPatch.set_alpha(1)
# colormap
colorMap = p.cm.jet_r
# nearest image drawing
p.imshow(data, cmap=colorMap, vmin=vMin, vmax=vMax, interpolation="nearest",
origin="lower", aspect="auto", alpha=1)
reversing = axisObj.set_ylim(axisObj.get_ylim()[::-1])
# nearest image saving and closing
canvasObj.savefig(outImageFileNearest, dpi=imagescCanvasDpi)
p.close()

I use matplotlib to generate a lot of images in batch mode and this
behavior appear not to be deterministic. It seems to depend on the input
data buffer.
Can anyone help me ?

I use
Linux openSUSE 11.3 (x86_64)
Linux sat1 2.6.34.7-0.7-default #1 SMP 2010-12-13 11:13:53 +0100 x86_64
x86_64 x86_64 GNU/Linux
Python 2.6.5
numpy 1.5.1
matplotlib 1.0.1 with backend Agg v2.2

If it can be of some help this strange behavior does not appear with a
system
Linux Ubuntu 9.10
Linux joshua 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:48:10 UTC 2009
i686 GNU/Linux
Python 2.6.4
numpy 1.3.0
matplotlib 0.99.0 with backend Agg v2.2

Executing the script with verbosity I get the subsequent output
python /users/lelepass/python/test_imagesc/test.py --verbose-helpful

$HOME=/users/lelepass
CONFIGDIR=/users/lelepass/.matplotlib

Bad key "numerix" on line 30 in
/users/lelepass/.matplotlib/matplotlibrc.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution
matplotlib data path /usr/lib64/python2.6/site-packages/matplotlib/mpl-data
loaded rc file /users/lelepass/.matplotlib/matplotlibrc
matplotlib version 1.0.1
verbose.level helpful
interactive is False
units is True
platform is linux2
Using fontManager instance from /users/lelepass/.matplotlib/fontList.cache
backend agg version v2.2
findfont: Matching
:family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium
to Bitstream Vera Sans
(/usr/lib64/python2.6/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf)
with score of 0.000000

Thank you all.
Bye.

Emanuele Passera

Software Engineer

Tele-Rilevamento Europa - T.R.E. srl
Via Vittoria Colonna, 7
20149 Milano – Italia
Tel.: +39.02.4343.121 - Fax: +39.02.4343.1230
emanuele.passera@...1676... - www.treuropa.com

--
This communication, that may contain confidential and/or legally privileged
information, is intended solely for the use of the intended addressees.
Opinions, conclusions and other information contained in this message, that
do not relate to the official business of this firm, shall be considered as
not given or endorsed by it. Every opinion or advice contained in this
communication is subject to the terms and conditions provided by the
agreement governing the engagement with such a client. If you have received
this communication in error, please notify us immediately by responding to
this email and then delete it from your system. Any use, disclosure, copying
or distribution of the contents of this communication by a not-intended
recipient or in violation of the purposes of this communication is strictly
prohibited and may be unlawful.
--

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Hello everybody,

I am experiencing a strange behavior with the imshow() function when
using the nearest interpolation method.

Executing the code listed below, I obtain a good image when using the
bilinear interpolation method
and a totally white image when using the nearest interpolation method.
I have attached the input data buffer and the resulting images too.

[...]

I use matplotlib to generate a lot of images in batch mode and this
behavior appear not to be deterministic. It seems to depend on the input
data buffer.
Can anyone help me ?

I use
Linux openSUSE 11.3 (x86_64)
Linux sat1 2.6.34.7-0.7-default #1 SMP 2010-12-13 11:13:53 +0100 x86_64
x86_64 x86_64 GNU/Linux
Python 2.6.5
numpy 1.5.1
matplotlib 1.0.1 with backend Agg v2.2

If it can be of some help this strange behavior does not appear with a
system
Linux Ubuntu 9.10
Linux joshua 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:48:10 UTC
2009 i686 GNU/Linux
Python 2.6.4
numpy 1.3.0
matplotlib 0.99.0 with backend Agg v2.2

Nor does it appear on my system with mpl from git, but it does with mpl 1.0.1, so it looks like this is something that was broken temporarily in the 1.0 series but is now fixed.

Eric

···

On 04/18/2011 12:46 AM, Emanuele Passera wrote:

Executing the script with verbosity I get the subsequent output
python /users/lelepass/python/test_imagesc/test.py --verbose-helpful

$HOME=/users/lelepass
CONFIGDIR=/users/lelepass/.matplotlib

Bad key "numerix" on line 30 in
/users/lelepass/.matplotlib/matplotlibrc.
You probably need to get an updated matplotlibrc file from
http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source
distribution
matplotlib data path /usr/lib64/python2.6/site-packages/matplotlib/mpl-data
loaded rc file /users/lelepass/.matplotlib/matplotlibrc
matplotlib version 1.0.1
verbose.level helpful
interactive is False
units is True
platform is linux2
Using fontManager instance from /users/lelepass/.matplotlib/fontList.cache
backend agg version v2.2
findfont: Matching
:family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium
to Bitstream Vera Sans
(/usr/lib64/python2.6/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf)
with score of 0.000000

Thank you all.
Bye.

Emanuele Passera

Software Engineer

Tele-Rilevamento Europa - T.R.E. srl
Via Vittoria Colonna, 7
20149 Milano – Italia
Tel.: +39.02.4343.121 - Fax: +39.02.4343.1230
emanuele.passera@...1676... <mailto:emanuele.passera@…1676…> -
www.treuropa.com <http://www.treuropa.com>

Thank you all,
using mpl from git worked fine.
Problem solved.
Is there a deadline for the new version release ?

Emanuele Passera

Software Engineer

Tele-Rilevamento Europa - T.R.E. srl

Via Vittoria Colonna, 7
20149 Milano – Italia
Tel.: +39.02.4343.121 - Fax: +39.02.4343.1230
emanuele.passera@…1676… - www.treuropa.com

···


This communication, that may contain confidential and/or legally privileged information, is intended solely for the use of the intended addressees. Opinions, conclusions and other information contained in this message, that do not relate to the official business of this firm, shall be considered as not given or endorsed by it. Every opinion or advice contained in this communication is subject to the terms and conditions provided by the agreement governing the engagement with such a client. If you have received this communication in error, please notify us immediately by responding to this email and then delete it from your system. Any use, disclosure, copying or distribution of the contents of this communication by a not-intended recipient or in violation of the purposes of this communication is strictly prohibited and may be unlawful.

On Tue, Apr 19, 2011 at 9:02 AM, Eric Firing <efiring@…83…202…> wrote:

On 04/18/2011 12:46 AM, Emanuele Passera wrote:

Hello everybody,

I am experiencing a strange behavior with the imshow() function when

using the nearest interpolation method.

Executing the code listed below, I obtain a good image when using the

bilinear interpolation method

and a totally white image when using the nearest interpolation method.

I have attached the input data buffer and the resulting images too.

[…]

I use matplotlib to generate a lot of images in batch mode and this

behavior appear not to be deterministic. It seems to depend on the input

data buffer.

Can anyone help me ?

I use

Linux openSUSE 11.3 (x86_64)

Linux sat1 2.6.34.7-0.7-default #1 SMP 2010-12-13 11:13:53 +0100 x86_64

x86_64 x86_64 GNU/Linux

Python 2.6.5

numpy 1.5.1

matplotlib 1.0.1 with backend Agg v2.2

If it can be of some help this strange behavior does not appear with a

system

Linux Ubuntu 9.10

Linux joshua 2.6.28-11-server #42-Ubuntu SMP Fri Apr 17 02:48:10 UTC

2009 i686 GNU/Linux

Python 2.6.4

numpy 1.3.0

matplotlib 0.99.0 with backend Agg v2.2

Nor does it appear on my system with mpl from git, but it does with mpl

1.0.1, so it looks like this is something that was broken temporarily in

the 1.0 series but is now fixed.

Eric

Executing the script with verbosity I get the subsequent output

python /users/lelepass/python/test_imagesc/test.py --verbose-helpful

$HOME=/users/lelepass

CONFIGDIR=/users/lelepass/.matplotlib

Bad key “numerix” on line 30 in

/users/lelepass/.matplotlib/matplotlibrc.

You probably need to get an updated matplotlibrc file from

http://matplotlib.sf.net/_static/matplotlibrc or from the matplotlib source

distribution

matplotlib data path /usr/lib64/python2.6/site-packages/matplotlib/mpl-data

loaded rc file /users/lelepass/.matplotlib/matplotlibrc

matplotlib version 1.0.1

verbose.level helpful

interactive is False

units is True

platform is linux2

Using fontManager instance from /users/lelepass/.matplotlib/fontList.cache

backend agg version v2.2

findfont: Matching

:family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium

to Bitstream Vera Sans

(/usr/lib64/python2.6/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf)

with score of 0.000000

Thank you all.

Bye.

Emanuele Passera

Software Engineer

Tele-Rilevamento Europa - T.R.E. srl

Via Vittoria Colonna, 7

20149 Milano – Italia

Tel.: +39.02.4343.121 - Fax: +39.02.4343.1230

emanuele.passera@…1676… mailto:emanuele.passera@...1676... -

www.treuropa.com <http://www.treuropa.com>


Benefiting from Server Virtualization: Beyond Initial Workload

Consolidation – Increasing the use of server virtualization is a top

priority.Virtualization can reduce costs, simplify management, and improve

application availability and disaster protection. Learn more about boosting

the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users