Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add write support for PDS3Image #45

Open
godber opened this issue Oct 3, 2015 · 8 comments
Open

Add write support for PDS3Image #45

godber opened this issue Oct 3, 2015 · 8 comments
Assignees
Labels
Milestone

Comments

@godber
Copy link
Member

godber commented Oct 3, 2015

There may be parts we will choose to extract up into the PlanetaryImage class, but you can start with PDS3Image.

@godber
Copy link
Member Author

godber commented Oct 6, 2015

The syntax for this should be

filename = ...
image = PDS3Image.open(filename)
image.data = image.data + 1
image.save(overwrite=True)

or

...
image.save('newfilename.IMG')

The following should raise an exception if the image file already exists, otherwise, write out the file

image.save()

@wtolson
Copy link
Member

wtolson commented Oct 6, 2015

Thoughts on an api more similar to PIL/Pillow or are you basing it on something else?

@godber
Copy link
Member Author

godber commented Oct 6, 2015

Good suggestion @wtolson, basing it on something rather than making it up.

@godber
Copy link
Member Author

godber commented Oct 6, 2015

We will also want to consider how to take a simple numpy array and write it out as a PDS3Image:

# ?? the constructor (__init__) doesn't support this yet
i = PDS3Image(data=np.ones((1024, 1024, 3))
i.save()

or

PDS3Image.save(data=np.np.ones((1024, 1024, 3)))

@wtolson's suggestion of using pillow as the model is a good one. I keep forgetting that he started out with that as his model.

@wtolson
Copy link
Member

wtolson commented Oct 6, 2015

I like what your thinking @godber. Maybe something like pillow:

image = PDS3Image.fromarray(data, extra_label_data={'foo': 'bar'})
image.save('foo.IMG')

@wtolson
Copy link
Member

wtolson commented Oct 6, 2015

This has me thinking, we might want to separate out image encoding/decoding from the Image object which would allow us to do something like:

# Detect and use proper encoding to read in the data
image = Image.open('foo.cub')

# Write out the data in a different format
image.save('foo.IMG')


# Create my own image
image = Image.fromarray(data)

# Save it in multiple formats
image.save('test.IMG')
image.save('test.cub')

Not sure how easy this would be for us to separate out image representation from the encoding/decoding formats but it seems to be the architecture used by PIL and scikit image.

@wtolson
Copy link
Member

wtolson commented Oct 6, 2015

Definitely its own issue and a future project though.

@bvnayak
Copy link
Collaborator

bvnayak commented Oct 6, 2015

Separating the encoding/decoding is really great idea @wtolson.

@godber godber added this to the v0.4.0 milestone Oct 27, 2015
@godber godber added the Feature label Oct 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants