问题标签 [stride]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
6164 浏览

opengl-es - What does stride mean in OpenGL|ES

I was going through the signature of the method glVertexPointer which is

void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)

Can anyone help me understand what does the third argument stride do.

I got this definition for stride after googling about it

Amount of bytes from the beginning of one element to the beginning of the following element. If you pass a zero as stride, it means they are tightly packed. If you have an array of floats, which contains vertices like this, x1,y1,z1,x2,y2,z2... and so on, you can set stride to either zero (as tightly packed), or 12 (3 floats*4 bytes each from the beginning of vertex one to the beginning of vertex two).

I am not able to get what does this mean ? it would be really helpful if someone explains it with the help of an example.

thanks.

0 投票
0 回答
772 浏览

python - 在Python中移动具有完整边界的窗口

我最近一直在使用滚动/移动窗口,如果这些值不能放在完整的窗口中,那么到目前为止我看到的所有实现都会忽略数组边界中包含的值。例如,假设您有这个数组:

使用 scikit-image 中的 view_as_windows,您可以看到有几个元素(最后两列和最后两行)不能放在另一个4x4窗口中:

我认为sklearn.feature_extraction.image.extract_patches_2d行为方式相同。据我了解,两者都使用跨步技巧来获取数组的内存视图。但是,即使它们的大小不同,我也希望能够获得部分窗口。

0 投票
1 回答
2176 浏览

c++ - BITMAP 的正确步幅公式

计算表面步幅

在未压缩的位图中,步幅是从一行像素的开头到下一行的开头所需的字节数。

以上来自BITMAPINFOHEADER 结构,绝对有意义。

同一站点给出了以下公式来计算步幅:

对于未压缩的 RGB 格式,最小步幅总是以字节为单位的图像宽度,四舍五入到最接近的 DWORD。您可以使用以下公式来计算步幅:

步幅 = ((((biWidth * biBitCount) + 31) & ~31) >> 3)

假设图片宽度为 600,高度为 800,1bpp

我预计步幅为 600/8 = 75 ......但上面的公式给了我 76 !

我正在使用(w + 7) / 8并获得预期的 75 ......

仍然看到上面来自 Microsoft 的公式让我感到疑惑 - 该公式是否正确?

0 投票
2 回答
230 浏览

python - 强制 numpy 数组物理匹配内存中的跨步

对于互相关例程,我想获取一些二维矩阵(灰度图像),将其中一半旋转 90 度,然后对它们进行傅里叶变换。我正在交叉关联大量帧,因此我尝试将 pyFFTW 与我过去成功使用的 FFTW 对象接口一起使用。

但是,在这里使用numpy.rot90()我遇到的问题是 numpy 不是物理地旋转内存中的数组,而是简单地改变步幅,而 FFTW 需要实际旋转物理内存中的数组。

使用.as_strided()恢复原始步幅,以便可以将其输入 pyFFTW。但是,应用该.as_strided()函数后,mage2不再相对于 旋转mage.as_strided()已经撤消了旋转操作,所以上面的代码什么也不做。

程序员如何在物理上强制一个 numpy 数组匹配它在内存中的步幅?

0 投票
2 回答
2739 浏览

geojson - Openlayers 3 How to render every point in a geometry at a high ( small ) resolution?

How do I force ol3 to render every single point in a geometry?

I'm having an issue with openlayers 3, where although I'm plotting a line string with 3000 points over a distance of maybe 100m, only about 1000 are rendering.

EDIT: Now - Openlayers 3 v.3.7.0

Zooming in far enough on a set of points in openlayers 3 reveals that only a few points are drawn, in a grid pattern. I would like to zoom in to see a hundred points drawn slightly offset from each other in a centimeter or millimeter scale map.

Is this possible with openlayers 3?

0 投票
2 回答
17222 浏览

swift - 在 Swift 2.0 中使用 Stride

我试图弄清楚如何在 Swift 中使用 Stride 功能。

自 Xcode 7.0 beta 6 以来,它似乎又发生了变化。

以前我可以使用

现在,尽管有代码提示,但我无法弄清楚如何使用此功能。

任何示例都会有所帮助,谢谢。

我看过例子,但我无法掌握如何使用它。我从 Apple Docs 获得的一切都是有限的。

谢谢

0 投票
0 回答
87 浏览

c++ - 通过 HDF5 的 C/C++ API 存储缓冲区时指定内存步长数据

我已经多次使用 Python 中的 HDF5,通过h5py,我被它与 NumPy 的平滑集成宠坏了。现在,在 C/C++ 领域,我正在尝试在 HDF5 存储中保存和加载图像数据,但我无法弄清楚如何指定图像数据的步幅。

读取和写入维度数据(Python 中的矩阵形状)非常简单;我是这样读的:

…并以类似方式编写(对于图像实例input):

…我能找到的 HDF5 代码示例要么是完全微不足道的示例——其中正在写入或读取的数据非常小且大小已知——要么是非常先进且高于我当前的薪酬等级,例如h5pyortables源。我正在寻找一个简单的示例,说明如何将矩阵步幅数据映射到 HDF5 API。

0 投票
1 回答
358 浏览

python - 快速获得 NumPy 数组反向的方法

我有一个应用程序,我需要根据某个步幅沿 NumPy 数组的一个轴反转元素。例如,假设我有以下数组

我想沿第一个轴 ( axis=0) 以 2 的步幅反转这个数组。换句话说,我想快速得到以下数组:

有没有一种使用内置 NumPy 例程的快速方法来做到这一点?

0 投票
2 回答
921 浏览

python - 如何从 numpy 中的 dtype 获得进步?

我想我可以做到: np.zeros((), dtype=dt).strides,但是当 dtype 是像这样的大型数组类型时,这似乎效率不高('<f8', (200, 100))。有没有办法直接从 dtype 到 numpy 中的跨步?

0 投票
1 回答
117 浏览

windows - 填充位图图像数据行(步幅 - 宽度)的目的是什么?

我可以理解它是否被用于某种元数据,但我找不到任何证实这一点的东西。

这种添加填充是否有原因?如果是这样,它是什么?