Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

imsave and imshow ignore vmin/vmax #5382

Closed
Milestone
@Arnoques

Description

@Arnoques

I'm sure this should be already known, but I couldn't find any issue related to this.

As far as I can tell, imsave and imshow expect arrays of floats to be from 0 to 1, and arrays of uint8 to be from 0 to 255. In both cases, the vmin and vmax arguments are completely ignored.

The following code shows the issue with imsave, and I'm attaching the resulting images. It was tested with matplotlib 1.5.0 and numpy 1.8.2.

importmatplotlibprintmatplotlib.__version__## 1.5.0importmatplotlib.imageasima=im.imread('lena.jpg')print'a: ',a.min(),a.max(),a.dtype## a:  0 255 uint8# This works fineim.imsave('test0.png',a)# vmin and vmax are ignored. Expected a saturated imageim.imsave('test1.png',a,vmin=0,vmax=128)a_expected=a.astype('float')/128im.imsave('test1_expected.png',a_expected)b=a.astype('float')print'b: ',b.min(),b.max(),b.dtype## b:  0.0 255.0 float64# imsave should use b.min() and b.max() as limits.im.imsave('test2.png',b)im.imsave('test2_expected.png',b/255)# vmin and vmax are ignored. Expected an image equal to the originalim.imsave('test3.png',b,vmin=0,vmax=255)im.imsave('test3_expected.png',b/255)c=b/b.max()print'c: ',c.min(),c.max(),c.dtype##c:  0.0 1.0 float64# This works fineim.imsave('test4.png',c)# vmin and vmax are ignored. Expected a saturated imageim.imsave('test5.png',c,vmin=0,vmax=0.5)im.imsave('test5_expected.png',c*2)

lena original
test0 test0
test1 test1
test1_expected test1_expected
test2 test2
test2_expected test2_expected
test3 test3
test3_expected test3_expected
test4 test4
test5 test5
test5_expected test5_expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp