Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
io.imsave() problems with passing arguments to plugin "freeimage"
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sigmund  
View profile  
 More options May 12 2012, 4:04 am
From: Sigmund <sig...@gmail.com>
Date: Sat, 12 May 2012 01:04:39 -0700 (PDT)
Local: Sat, May 12 2012 4:04 am
Subject: io.imsave() problems with passing arguments to plugin "freeimage"

Hallo!
To read uncompressed TIFF files I use the freeimage plugin. The reading
works great but since last week I need to save a summed Image. I used the
io.imsave() with the freeimage plugin but by default it writs a compressed
TIFF file. The freeimage documentation provides Flags to use for different
compressions or for a non compressed type (TIFF_NONE). Can someone tell me
how to pass theses Flags to the plugin?
I saw that Christophs 'tifffile' plugin does the job but still I would like
to know how to use the freeimage plug-n for it.

Thanks!

Siggi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zachary Pincus  
View profile  
 More options May 12 2012, 9:47 am
From: Zachary Pincus <zachary.pin...@yale.edu>
Date: Sat, 12 May 2012 09:47:10 -0400
Local: Sat, May 12 2012 9:47 am
Subject: Re: io.imsave() problems with passing arguments to plugin "freeimage"
Hi Siggi,

This functionality is not exposed by the imsave() apparatus, but can be accessed by the image writing functions in the plugin that imsave() calls.

A quick scan through the source code is likely to be the most helpful thing, regarding the available flags, etc:
https://github.com/scikits-image/scikits-image/blob/master/skimage/io...

In particular, the freeimage_plugin.write() function, around which freeimage_plugin.imsave() is a thin wrapper, allows you to set various flags.
So:
import skimage.io._plugins.freeimage_plugin as fi
image = fi.read('/path/to/whatever')
fi.write(image, 'whatever.tif', fi.IO_FLAGS.TIFF_NONE)

Zach

On May 12, 2012, at 4:04 AM, Sigmund wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sigmund  
View profile  
 More options May 13 2012, 9:33 am
From: Sigmund <sig...@gmail.com>
Date: Sun, 13 May 2012 06:33:36 -0700 (PDT)
Local: Sun, May 13 2012 9:33 am
Subject: Re: io.imsave() problems with passing arguments to plugin "freeimage"

Thanks! Works great!

Siggi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sigmund  
View profile  
 More options Jul 9 2012, 9:13 am
From: Sigmund <sig...@gmail.com>
Date: Mon, 9 Jul 2012 06:13:58 -0700 (PDT)
Local: Mon, Jul 9 2012 9:13 am
Subject: Re: io.imsave() problems with passing arguments to plugin "freeimage"

Hallo!

As I wrote, the workaround:

Am Samstag, 12. Mai 2012 15:47:10 UTC+2 schrieb Zachary Pincus:

> import skimage.io._plugins.freeimage_plugin as fi
> fi.write(image, 'whatever.tif', fi.IO_FLAGS.TIFF_NONE)

by Zach worked fine for me. Now I tried the same code on a WIN 7 64 bit
system (EPD 7.3.1) and got the following error:

Traceback (most recent call last):
  File "G:\Marwen\Summer.py", line 67, in <module>
    fi.write(summation,
str(datensatz)+"_interval-"+str(interval_length)+"_"+str(count)+'.tif',
fi.IO_FLAGS.TIFF_NONE)
  File
"C:\Python27\lib\site-packages\skimage\io\_plugins\freeimage_plugin.py",
line 538, in write
    bitmap, fi_type = _array_to_bitmap(array)
  File
"C:\Python27\lib\site-packages\skimage\io\_plugins\freeimage_plugin.py",
line 604, in _array_to_bitmap
    raise ValueError('Cannot write arrays of given type and shape.')
ValueError: Cannot write arrays of given type and shape.

I checked the .dtype of the array and compared them to the one on the 32bit
and the OS X system but coutn't see any difference.

I'm reading several Images with
numpy.array(io.imread(bild, plugin="freeimage"),dtype=np.int32)
and sum then up one by one to write them out afterwards as one file.

Siggi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zachary Pincus  
View profile   Translate to Translated (View Original)
 More options Jul 9 2012, 9:25 am
From: Zachary Pincus <zachary.pin...@yale.edu>
Date: Mon, 9 Jul 2012 09:25:55 -0400
Local: Mon, Jul 9 2012 9:25 am
Subject: Re: io.imsave() problems with passing arguments to plugin "freeimage"
Can you save via the imsave() command? (E.g. when using compression?) That is, is this error specific to trying to use the  TIFF_NONE flag, or general to saving images (or TIFF images) on Win7 64?

This may be an issue with the underlying FreeImage library, or a lingering 64-bit bug in the wrappers. So if you could do a bit more sleuthing and figure out the exact trigger for the problem, that would be very helpful in fixing it.

Thanks,
Zach

On Jul 9, 2012, at 9:13 AM, Sigmund wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sigmund  
View profile  
 More options Jul 9 2012, 9:44 am
From: Sigmund <sig...@gmail.com>
Date: Mon, 9 Jul 2012 06:44:34 -0700 (PDT)
Local: Mon, Jul 9 2012 9:44 am
Subject: Re: io.imsave() problems with passing arguments to plugin "freeimage"

same problem with io.imsave

Traceback (most recent call last):
  File "G:\Marwen\Summer.py", line 61, in <module>
io.imsave("test.tif",summation, plugin="freeimage")
  File "C:\Python27\lib\site-packages\skimage\io\_io.py", line 129, in
imsave return call_plugin('imsave', fname, arr, plugin=plugin,
**plugin_args)
  File "C:\Python27\lib\site-packages\skimage\io\_plugins\plugin.py", line
88, in call return func(*args, **kwargs)
  File
"C:\Python27\lib\site-packages\skimage\io\_plugins\freeimage_plugin.py",
line 668, in imsave write(img, filename)
  File
"C:\Python27\lib\site-packages\skimage\io\_plugins\freeimage_plugin.py",
line 538, in write bitmap, fi_type = _array_to_bitmap(array)
  File
"C:\Python27\lib\site-packages\skimage\io\_plugins\freeimage_plugin.py",
line 604, in _array_to_bitmap raise ValueError('Cannot write arrays of
given type and shape.')
ValueError: Cannot write arrays of given type and shape.

siggi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sigmund  
View profile   Translate to Translated (View Original)
 More options Jul 9 2012, 10:01 am
From: Sigmund <sig...@gmail.com>
Date: Mon, 9 Jul 2012 07:01:18 -0700 (PDT)
Local: Mon, Jul 9 2012 10:01 am
Subject: Re: io.imsave() problems with passing arguments to plugin "freeimage"

without the try: and raise ValueError in the freeimage_plugin.py it returns:

Traceback (most recent call last):
  File "G:\Marwen\Summer.py", line 61, in
<module>io.imsave("test.tif",summation, plugin="freeimage")
  File "C:\Python27\lib\site-packages\skimage\io\_io.py", line 129, in
imsave return call_plugin('imsave', fname, arr, plugin=plugin,
**plugin_args)
  File "C:\Python27\lib\site-packages\skimage\io\_plugins\plugin.py", line
88, in call return func(*args, **kwargs)
  File
"C:\Python27\lib\site-packages\skimage\io\_plugins\freeimage_plugin.py",
line 669, in imsave write(img, filename)
  File
"C:\Python27\lib\site-packages\skimage\io\_plugins\freeimage_plugin.py",
line 538, in write bitmap, fi_type = _array_to_bitmap(array)
  File
"C:\Python27\lib\site-packages\skimage\io\_plugins\freeimage_plugin.py",
line 601, in _array_to_bitmap fi_type = FI_TYPES.fi_types[(dtype.type,
n_channels)]
KeyError: (<type 'numpy.int32'>, 1)

I'm afraid that is all I can do with my limited skills...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sigmund  
View profile  
 More options Jul 9 2012, 10:14 am
From: Sigmund <sig...@gmail.com>
Date: Mon, 9 Jul 2012 07:14:01 -0700 (PDT)
Local: Mon, Jul 9 2012 10:14 am
Subject: Re: io.imsave() problems with passing arguments to plugin "freeimage"

I proved myselfe wrong ;-)

It is working if I chose numpy.float32 as dtype!

uint32 doesn't work either. Leads to KeyError: (<type 'numpy.int64'>, 1)

Siggi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zachary Pincus  
View profile   Translate to Translated (View Original)
 More options Jul 9 2012, 10:19 am
From: Zachary Pincus <zachary.pin...@yale.edu>
Date: Mon, 9 Jul 2012 10:19:06 -0400
Local: Mon, Jul 9 2012 10:19 am
Subject: Re: io.imsave() problems with passing arguments to plugin "freeimage"
Hmm, there's clearly something going wrong with int types. (There are also some failing / segfaulting tests on SPARC with int types too... I wonder if these are related?)

> It is working if I chose numpy.float32 as dtype!

> uint32 doesn't work either. Leads to KeyError: (<type 'numpy.int64'>, 1)

Could you provide a bit of self-contained test code (starting with creating a new numpy array with known dtype and then trying to save it) that re-creates the above error? And the full backtrace? I'm not sure how saving a uint32 array is causing a KeyError with int64 -- something odd seems to be happening there, maybe.

Zach


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sigmund  
View profile  
 More options Jul 10 2012, 9:35 am
From: Sigmund <sig...@gmail.com>
Date: Tue, 10 Jul 2012 06:35:07 -0700 (PDT)
Local: Tues, Jul 10 2012 9:35 am
Subject: Re: io.imsave() problems with passing arguments to plugin "freeimage"

Hey!

Whil writing the test code I found out that saving the array by itself
doesn't cause the error. Only after summing two arrays it fails.

import numpy as np
import skimage.io as io
io.use_plugin("freeimage", "imread")
one = np.ones([2048,2048],dtype=np.int32)
two = np.zeros([2048,2048],dtype=np.int32)
summation = one + two
io.imsave("test.tif",summation, plugin="freeimage")

 not using the freeimage plugin in not failing.

Siggi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zachary Pincus  
View profile  
 More options Jul 11 2012, 8:50 am
From: Zachary Pincus <zachary.pin...@yale.edu>
Date: Wed, 11 Jul 2012 08:50:11 -0400
Local: Wed, Jul 11 2012 8:50 am
Subject: Re: io.imsave() problems with passing arguments to plugin "freeimage"
I wonder if this has to do with the type-promotion behavior changes in a recent numpy version? What is the dtype of "summation" below?

On Jul 10, 2012, at 9:35 AM, Sigmund wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sigmund  
View profile  
 More options Jul 12 2012, 8:41 am
From: Sigmund <sig...@gmail.com>
Date: Thu, 12 Jul 2012 05:41:58 -0700 (PDT)
Local: Thurs, Jul 12 2012 8:41 am
Subject: Re: io.imsave() problems with passing arguments to plugin "freeimage"

On Wednesday, July 11, 2012 2:50:11 PM UTC+2, Zachary Pincus wrote:

> I wonder if this has to do with the type-promotion behavior changes in a
> recent numpy version? What is the dtype of "summation" below?

> two.dtype and summation.dtype return "int32"  .dtype.type is returning

"<type 'numpy.int32'>" in both cases.
I just tried it on a diffrent PC. Same problem on a Win32 XP 32bit system
with EPD 7.2-2 Python 2.7.2

In summary.
It is working on :
Python 2.7.1 |EPD 7.0-2 (32-bit)| Win 7 32
Python 2.7.2 |EPD 7.2-2 (64-bit)| Mac OSX
And not working on:
Python 2.7.3 |EPD 7.3-1 (64-bit)| Win 7 64
Python 2.7.2 IEPD 7.2-2 (32-bit)| Win XP


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zachary Pincus  
View profile  
 More options Jul 12 2012, 10:09 am
From: Zachary Pincus <zachary.pin...@yale.edu>
Date: Thu, 12 Jul 2012 10:09:24 -0400
Local: Thurs, Jul 12 2012 10:09 am
Subject: Re: io.imsave() problems with passing arguments to plugin "freeimage"
This is very curious. You have two arrays of identical dtype (that is, "two" and "summation"), and one can be saved via freeimage yet the other cannot? Is this correct?

Hopefully someone can try to verify this. Strange, too, that it would fail on XP but work on Win 7 32-bit. Perhaps that's a red herring and it has to do with the EPD version?

On Jul 12, 2012, at 8:41 AM, Sigmund wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christoph Gohlke  
View profile  
 More options Jul 12 2012, 1:39 pm
From: Christoph Gohlke <cjgoh...@gmail.com>
Date: Thu, 12 Jul 2012 10:39:52 -0700
Local: Thurs, Jul 12 2012 1:39 pm
Subject: Re: io.imsave() problems with passing arguments to plugin "freeimage"
The freeimage plugin is comparing numpy's dtype.type (not dtype), which
apparently does not work in this case:

import numpy as np
one = np.ones([2048,2048],dtype=np.int32)
two = np.zeros([2048,2048],dtype=np.int32)
summation = one + two

assert repr(summation.dtype) == repr(one.dtype)
assert summation.dtype == one.dtype
assert hash(summation.dtype) == hash(one.dtype)

assert repr(summation.dtype.type) == repr(one.dtype.type)
assert summation.dtype.type != one.dtype.type
assert hash(summation.dtype.type) != hash(one.dtype.type)

I submitted a PR at
<https://github.com/scikits-image/scikits-image/pull/214>

Christoph

On 7/12/2012 7:09 AM, Zachary Pincus wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »