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 plot function for SpaceNet datasets #252

Merged
merged 8 commits into from
Nov 22, 2021

Conversation

ashnair1
Copy link
Collaborator

@ashnair1 ashnair1 commented Nov 19, 2021

Changes:

  • Add plot function to SpaceNet base class
  • Explicitly check whether raster CRS is equal to vector CRS and transform polygon features accordingly
  • Add contrast_stretch to correctly convert between types
  • Added axis param to percentile_normalization and updated utils __all__

torchgeo/datasets/spacenet.py Show resolved Hide resolved
torchgeo/datasets/utils.py Outdated Show resolved Hide resolved
@adamjstewart adamjstewart added the datasets Geospatial or benchmark datasets label Nov 19, 2021
@ashnair1
Copy link
Collaborator Author

ashnair1 commented Nov 19, 2021

Plot samples

From SpaceNet2, PAN image and label
sn2_pan

From SpaceNet7
sn7_train

@ashnair1 ashnair1 force-pushed the spacenet-plots branch 2 times, most recently from f5455e5 to a8e8c51 Compare November 20, 2021 06:21
@ashnair1
Copy link
Collaborator Author

ashnair1 commented Nov 20, 2021

Visualisation note:
When percentile_normalization was done bandwise (before 5ea1c21) there was a one to one correspondence between the plot torchgeo produces and the plot that QGIS shows (default params i.e stretch to minmax, 2% - 98%).

Overall normalisation (currently implemented)
def1

Bandwise (before 5ea1c21) and how QGIS shows it by default
def2

I'm guessing I didn't see this difference in SpaceNet7 images since they're already uint8 while SpaceNet2 images were uint16

@calebrob6
Copy link
Member

calebrob6 commented Nov 20, 2021

Strange (and good catch)! One of the S2 datasets I was working on looked very strange when I did bandwise min-max normalization so I just changed it to global and it looked fine.

Do you think we should add an axis parameter to percentile_normalization that gets forwarded through to numpy?

@ashnair1
Copy link
Collaborator Author

ashnair1 commented Nov 20, 2021

Forwarding axis param seems like a good idea. Gives the user a way to control the type of normalization.

The SpaceNet images that I've shown above are from Worldview 3 so it could be a sensor thing (dtype). I usually plot it to be similar to QGIS (default params) but that's just my preference.

@calebrob6
Copy link
Member

Sounds good to me too! Do you want to do that?

@adamjstewart adamjstewart added this to the 0.2.0 milestone Nov 20, 2021
@ashnair1
Copy link
Collaborator Author

Sure. Would it be better to do that as a separate commit or shall I just add it here?

@calebrob6
Copy link
Member

calebrob6 commented Nov 21, 2021 via email

@ashnair1
Copy link
Collaborator Author

ashnair1 commented Nov 21, 2021

Added axis param to percentile_normalization and added function to __all__

torchgeo/datasets/utils.py Outdated Show resolved Hide resolved
torchgeo/datasets/utils.py Outdated Show resolved Hide resolved
@calebrob6 calebrob6 merged commit 3c228ba into microsoft:main Nov 22, 2021
@ashnair1 ashnair1 deleted the spacenet-plots branch November 22, 2021 17:50
@adamjstewart adamjstewart mentioned this pull request Dec 21, 2021
19 tasks
@adamjstewart adamjstewart added the utilities Utilities for working with geospatial data label Jan 2, 2022
@adamjstewart adamjstewart removed the utilities Utilities for working with geospatial data label Jan 2, 2022
yichiac pushed a commit to yichiac/torchgeo that referenced this pull request Apr 29, 2023
* Add plot function for SpaceNet datasets

* Add version string

* Set interpolation='none' while displaying mask

* Switch to percentile normalization

* Add axis param to percentile_normalization

* Tuple[int, int] -> Sequence[int]

Co-authored-by: Adam J. Stewart <[email protected]>

* Update docstring

Co-authored-by: Adam J. Stewart <[email protected]>

* Forgot to import Sequence

Co-authored-by: Adam J. Stewart <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasets Geospatial or benchmark datasets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants