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

cost() function in simplify.py #27

Open
BenoitDaviet opened this issue Jan 13, 2021 · 4 comments
Open

cost() function in simplify.py #27

BenoitDaviet opened this issue Jan 13, 2021 · 4 comments

Comments

@BenoitDaviet
Copy link
Contributor

BenoitDaviet commented Jan 13, 2021

cost() function doesn't output the correct number of points.
Here is an example : res should countain 21 elements whose type isn't "None", but instead there are 23 of them

`from cereals.src.openalea.cereals.simplification import cost
import openalea.plantgl.all as pgl

xn, yn, sn, rn = (np.linspace(0, 0.7, 155),
np.linspace(0, 0.4, 155),
np.linspace(0, 1, 155),
np.ones(155))

nb_points = 21
points = [pgl.Vector3(*pt) for pt in zip(xn, rn, yn)]

res = cost(polyline=points, nb_points=nb_points)

print(len(res)) # 155, OK
print(len([r for r in res if r])) # 23, instead of 21`

@pradal
Copy link
Contributor

pradal commented Jan 13, 2021

During the simplification, I can not remove extremal points (first and last point).
nb_point expresses only the nuber of internal point we want to keep in the polyline.

@BenoitDaviet
Copy link
Contributor Author

Ok thanks, I understand for this example.
But the problem is that for a same value of nb_point (21), the number of points I obtained is not always the same : for some polylines I obtain 23 points (like in my code example), but sometimes I also obtain 22 or 21 points.

@pradal
Copy link
Contributor

pradal commented Jan 13, 2021

OK. I will look at it. Stay tuned.

@BenoitDaviet
Copy link
Contributor Author

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants