图像加载器加权算法
我正在构建一个图像预加载器,并尝试创建一个加权函数来确定接下来加载哪个图像。
以下是我的需求的快速细分:
我有一系列按连续顺序排列的图像。我有一个变量权重,其值必须介于 -1 和 1 之间。
权重为 -1 表示仅加载索引低于先前加载的图像的图像。
权重为 1 表示仅加载索引大于先前加载的图像的图像。
权重为 0 表示均匀分布图像的加载。
十进制权重例如(0.6)意味着加载索引在60%的时间比前一个图像大的图像以及比前一个图像索引低的40%的时间。
权重始终从 0 开始。每次更新的权重都提供要查看的新图像的索引以及上次查看的图像的索引。
我希望修改每个图像视图的权重,考虑到:
新索引是否大于旧索引(用户有 前进)
给定索引下方的图像数量与上方的数量。
之前的权重(分布越倾向于尺度的一端,权重向该端的增量就越慢,并且向另一端的增量就越大)。
我希望我把问题说得足够清楚了。有谁知道可以帮助提供此功能的算法或公式?
谢谢。
I am building an image preloader and am attempting to create a weighting function to determine which image to load next.
Here is a quick breakdown of my needs:
I have an array of images in successive order. I have a variable weighting which must have a value between -1 and 1.
A weighting of -1 means to load only images which have an index lower than the previously loaded image.
A weighting of 1 means to load only images which have an index greater than the previously loaded image.
A weighting of 0 means to evenly distribute the loading of images.
A decimal weighting e.g.(0.6) means to load images with an index greater than the previous image 60% of the time and those lower 40% of the time.
The weighting always starts at 0. The weighting on each update is provided with the index of a new image to view, and the index of the last viewed image.
I wish to modify the weighting on each image view taking into account:
whether the new index is greater than the old index (the user has
gone forward)the number of images below the given index versus the number above.
the previous weighting (The greater the distribution leans towards one end of the scale the slower the weighting increments towards that end and the greater it increments towards the other).
I hope I made the problem clear enough. Does anyone know of an algorithm or formula which can help provide this functionality?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我开始这样想:
但我怀疑加权比简单的预加载更能让用户受益,例如:
其中
next
是所选方向(更大或更小的索引)i started thinking like this:
but i doubt the weighting would benefit users any more than simple preloading, e.g.:
where
next
is the chosen direction (either bigger or smaller indices)