Coder Social home page Coder Social logo

Comments (10)

bw4sz avatar bw4sz commented on July 3, 2024 1

from pyfor.

brycefrank avatar brycefrank commented on July 3, 2024

Ben,

You have found a bit of a sore spot for me. I have been looking to get this consistent myself. I am wrapping up a small assignment right now, but I can hop on this in a few minutes.

from pyfor.

bw4sz avatar bw4sz commented on July 3, 2024

Sure, i'm trying to think about how to make a reproducible example. its within the deep learning data generator that would take alot for you to bury into. Trying now. My labmate thinks its option 2. The rgb image plot shows the UTM N increasing as you go up, which i guess is arbitrary, but we should be consistent.

from pyfor.

brycefrank avatar brycefrank commented on July 3, 2024

To be honest there is a deep nest of flips and unflips in pyfor (one of those things, you know). The least I can tell you is that line 170 only flips for visualization. It may be worthwhile to matshow the image and CHM separately in two different plot for debugging. You could probably take advantage of the top left corner of the image you have to make sure they are correct. You can access the chm array like so:

pc = Cloud('my_las.las')
my_chm = pc.chm(1)
chm.array

My other though is that when I generate the bins for the points to convert to a raster is that, I think, they start from the bottom left, rather than the top left. Hence all the flipping/flopping. I will come up with a more formal solution soon. Keep me posted on here (or gitter if you want more instant feedback)!

from pyfor.

bw4sz avatar bw4sz commented on July 3, 2024

Okay this should be reproducible.

Data: Archive.zip

import pyfor
from PIL import Image
from matplotlib import pyplot
import numpy as np

pc=pyfor.cloud.Cloud("/Users/ben/Documents/DeepLidar/data/SJER/SJER_002.laz")
im=Image.open("/Users/ben/Documents/DeepLidar/data/SJER/SJER_002.tif")
#Maybe numpy inverts the image from PIL?
image = np.array(im)    

pc.normalize(2)
chm = pc.chm(cell_size = 0.1 , interp_method = "nearest", pit_filter = "median", kernel_size = 9)

fig, ax = pyplot.subplots()
ax.imshow(image)
ax.matshow(chm.array,alpha=0.4)
fig.title="Original"

#versus
fig, ax = pyplot.subplots()
ax.imshow(image)
ax.matshow(np.flip(chm.array,0),alpha=0.4)
fig.title="CHM Flipped"
pyplot.show()

figure_1
figure_2

I'm going to assume that the CHM is flipped for some reason (UTM N facing down, not up) and just move forward.

from pyfor.

brycefrank avatar brycefrank commented on July 3, 2024

Ben,

I just arrived to the same conclusion. The index [0,0] of chm.array refers to the bottom left of the CHM (in real space). When we display this in matplotlib using plt.matshow(chm.array) it is displayed upside-down for this reason.

I will need to think about the implications down the line for flipping it up in rasterizer.Raster. It seems to be an easy fix, but I need to write some tests for this sort of thing anyway. I

I am committing the rest of the day (barring any other unforeseen work) to the testing suite and other fixes you have presented. I will let you know when I push to laz_fix, and I will include a UserWarning in this push when the array is constructed such that [0,0] refers to the top left when rasterizer.Raster is initialized.

from pyfor.

brycefrank avatar brycefrank commented on July 3, 2024

Ben,

A quick update. I am debating fixing this way up at the top (when the bins themselves are assigned). This will likely take a day or two to solidify. At least we know the temporary solution works for now. There are a lot of loose threads as well that I think would benefit from fixing all the way back in Grid.__init__ specifically:

https://github.com/brycefrank/pyfor/blob/laz_fix/pyfor/rasterizer.py#L28-L30

Edit

After spending a bit of time with it it is much more maintainable to do the fix all the way up in Grid. All of the calls to np.flipud are no longer needed. I have to un-do a few more of these types of calls, but I am much more happy with how it is turning out. I will push to laz_fix in an hour or so.

from pyfor.

brycefrank avatar brycefrank commented on July 3, 2024

This fix (along with the laz_fix branch) has been merged to master. If you update, make sure to remove any flipping you have done yourself. It should no longer be needed (a UserWarning is issued any time a Grid object is initialized, I'll leave this in until 0.3.2 is merged to master, which will be a while).

from pyfor.

bw4sz avatar bw4sz commented on July 3, 2024

from pyfor.

brycefrank avatar brycefrank commented on July 3, 2024

Looking forward to the next challenge ;)

from pyfor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.