soft-matter / trackpy-examples

sample images, examples, and speed tests for trackpy
Other
21 stars 42 forks source link

Walkthrough, as_grey option not working, png images have 4 channels #23

Open sciunto opened 9 years ago

sciunto commented 9 years ago

Hi,

I'm preparing a tutorial for my lab on trackpy and going though the walkthrough notebook, I noticed that the png images have 4 channels

from skimage.data import imread
imread('../sample_data/bulk_water/bulk_water_000.png')[0]
array([[146, 125,  54, 255],
       [146, 125,  54, 255],
       [146, 125,  56, 255],
       ..., 
       [140, 120,  55, 255],
       [141, 120,  59, 255],
       [142, 121,  60, 255]], dtype=uint8)

frames = pims.ImageSequence('../sample_data/bulk_water/*.png', as_grey=True)

raises

NotImplementedError: I don't know how to convert an image of shaped (424, 640, 4) to greyscale. Write you own function and pass it using the process_func keyword argument.

I can fix the notebook. Do you prefer to keep the use of as_grey option or show how to write a preprocess function...

Might be worth to illustrate both too. I don't know of the preprocess kwarg is illustrated somewhere.

Best

sciunto commented 9 years ago

I just read the code of pims and I think it's fixed in master.

cennoreth commented 9 years ago

Still broken in the version I have!

sciunto commented 9 years ago

@cennoreth What's your pims version? master freshly build?

cennoreth commented 9 years ago

yes, I think so - how do I check?

sciunto commented 9 years ago

If it's correctly done in pims, this should tell you if you use the git version or a released version.

python -c 'import pims; print(pims.__version__)'
sciunto commented 9 years ago

I'm with 0.2.2 and it doesn't work, but the implementation in master is different. I didn't try master so far.

cennoreth commented 9 years ago

It works with these images: https://github.com/soft-matter/pims/tree/master/examples/image_sequence

But not with these: https://github.com/soft-matter/trackpy-examples/tree/master/sample_data/bulk_water

Ah - version is also 0.2.2