Skip to content

Linear performance suggestions #153

Open
@spouliot

Description

When I tried Linear I noticed a performance/usability problem for my use case.

public Image Linear(double[] a, double[] b, bool? uchar = null);

I only wanted to multiply/add everything by a single values, not arrays. This is possible with the native API but not with the managed bindings.

The easy workaround is to create the arrays but the additional allocations can become costly...

using var scaled = image.Linear (new double [] { f }, new double [] { a });

Also while looking inside Linear implementation I noticed that a VOption instance is created, even if not needed for the call. That's another non-required memory allocation and it means some additional calls (e.g. in Call) gets executed when they are not needed.

I ended up doing

using var scaled = (Image) Operation.Call ("linear", null, image, f, a);

to avoid the issues but it's much less readable.

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions