-
Notifications
You must be signed in to change notification settings - Fork 30
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
Improve/speed up distance function between two raster images #1551
Comments
To improve performance, it could potentially be made less precise as well (not comparing every pixel)? |
Any thoughts @davidpiuva ? |
For now, skipping half of the pixels should be enough. Later, gpu comparisons can apply some erosion and dilation for a more flexible tolerance. Do the comparison and vertical pass on the gpu, read back an image of height 1 and do the horozontal pass from single row to single value on the cpu. |
@niklasborwell - can you suggest a better approach? |
Honestly, I think we should probably write another more well defined function in parallel and start using that one instead, because a) There is no reference what this is based on (and I have no idea) and b) This comparison is pretty bad cause the result will scale with the number of pixels compared. |
I can try doing it with pointers. Related ideas/thoughts/observations:
|
I tried using a one dimensional index to get rid of the multiplication. I measured with and without the erosion feature. With erosion, the compiler made a better job at optimizing it so performance became worse. Without erosion, 140 milliseconds could be gained but the cost in lost spatial tolerance is unacceptable.
|
It doesn't look like we're gonna replace |
And as a I said above, many/most tests are looking for |
I'm thinking about having an abstract Metric: abstract class {
distance: abstract func (a, b: Image) -> Double
}
RootMeanSquareMetric: class extends Metric {
distance: override func (a, b: Image) -> Double {
// convert images to some preferred format and run L^2 metric with normalization
}
}
MemcmpMetric: class extends Metric {
distance: override func (a, b: Image) -> Double {
// run memcmp on byte buffers
}
}
SupremumMetric: ... // not sure if useful for us
... This way we could keep all the
It solves two main issues with
|
Sounds like a reasonable idea to me. |
At the moment this function is very slow and can consume several seconds per image comparison. It should be possible to optimize this function, for example by parallelizing it.
The text was updated successfully, but these errors were encountered: