Questions tagged [stride]

The stride of an array is the number of locations in memory between beginnings of successive array elements, measured in bytes or in units of the size of the array's elements. Arrays may have a stride larger than their elements' width in bytes, which are called a non-unit stride. One particular use of non-unit stride is for images, when creating subimages without copying the pixel data.

The stride of an array is the number of locations in memory between beginnings of successive array elements, measured in bytes or in units of the size of the array's elements. Arrays may have a stride larger than their elements' width in bytes, which are called a non-unit stride. One particular use of non-unit stride is for images, when creating subimages without copying the pixel data.

157 questions
67
votes
3 answers

How to understand numpy strides for layman?

I am currently going through numpy and there is a topic in numpy called "strides". I understand what it is. But how does it work? I did not find any useful information online. Can anyone let me understand in a layman's terms?
Atif
  • 1,012
  • 1
  • 9
  • 23
31
votes
2 answers

Using Stride in Swift 2.0

I'm trying to figure out how to use the Stride features in Swift. It seems to have changed again, since Xcode 7.0 beta 6. Previously I could use let strideAmount = stride(from: 0, to: items.count, by: splitSize) let sets = strideAmount.map({…
DogCoffee
  • 19,820
  • 10
  • 87
  • 120
29
votes
2 answers

Can anyone help in understanding AVFrame.linesize[]?

I tried to find what each cell of AVFrame.linesize[] means, but I didn't found. As I understood linesize[0] is the width, linesize[1] is the height. If I'm right what does other cells mean? why after avcodec_decode_video2(codecCtxDecode,…
theateist
  • 13,879
  • 17
  • 69
  • 109
25
votes
6 answers

Python String Slicing Stride Clarification

So I don't really get the deal with the stride parameter in slicing. For example, "123456"[::-2] produces "642", but why does "123456"[1::-2] produce "2" and "123456"[2::-2] produce "31"?
user995788
  • 251
  • 1
  • 3
  • 4
17
votes
2 answers

OpenGL 3/4 glVertexAttribPointer stride and offset miscalculation

I am having a problem getting my vertex array pointed to properly: const float vertices[] = { /* position */ 0.75f, 0.75f, 0.0f, 1.0f, /* color */ 1.0f, 0.0f, 0.0f, 1.0f, /* position */ 0.75f, -0.75f, 0.0f, 1.0f, /* color */ 0.0f, 1.0f, 0.0f,…
user2350858
  • 681
  • 2
  • 10
  • 16
16
votes
1 answer

Is there a standard, strided version of memcpy?

I have a column vector A which is 10 elements long. I have a matrix B which is 10 by 10. The memory storage for B is column major. I would like to overwrite the first row in B with the column vector A. Clearly, I can do: for ( int i=0; i < 10;…
M. Tibbits
  • 8,400
  • 8
  • 44
  • 59
13
votes
1 answer

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…
Mayank
  • 1,099
  • 4
  • 17
  • 44
13
votes
2 answers

Copying strided data in C++

I have two arrays and I want to copy one array into the other with some stride. For example, I have A A A A A A A A ... B B B B B B B B ... and I want to copy every three elements of B to A to obtain B A A B A A B A ... From the post "Is there a…
Vitality
  • 20,705
  • 4
  • 108
  • 146
12
votes
8 answers

Fastest way to copy memory with stride in C?

I'm trying to copy 1 or 2 colour channels from RGBA image data as quickly as possible (this is the slowest part of my code, and it's slowing the whole app down). Is there a fast way of copying with stride? The data is simply laid out as RGBARGBARGBA…
user816936
12
votes
2 answers

It is possible to get an IntPtr from an int[] array?

Greetings. In C#: If I have an int[] array declared like this int[] array = new array[size]; there is an way to get the IntPtr from this array? The thing is that I'm using the EmguCV framework, and there is an constructor to create an image which…
João Cardoso
  • 351
  • 3
  • 5
  • 13
8
votes
6 answers

How can I copy the pixel data from a Bitmap with negative stride?

I was looking for the fastest way to convert a Bitmap to 8bpp. I found 2 ways: 1. public static System.Drawing.Image ConvertTo8bpp(Bitmap oldbmp) { using (var ms = new MemoryStream()) { oldbmp.Save(ms,…
Pedro77
  • 5,176
  • 7
  • 61
  • 91
8
votes
1 answer

Defining a stride of (2, 2) in Keras -- what is the second value?

I'm a bit confused by the idea of a stride that is, say, (2, 2) in keras. What is the second 2 in the tuple (2,2) doing? I'd understand if the stride was (2), because then we'd be moving a filter across an image by 2 pixels. If we are striding…
Monica Heddneck
  • 2,973
  • 10
  • 55
  • 89
8
votes
1 answer

Why does BitmapSource.Create throw an ArgumentException?

I'm trying to get an bitmap created from raw data to show in WPF, by using an Image and a BitmapSource: Int32[] data = new Int32[RenderHeight * RenderWidth]; for (Int32 i = 0; i < RenderHeight; i++) { for (Int32 j = 0; j < RenderWidth; j++) …
Mike Pateras
  • 14,715
  • 30
  • 97
  • 137
7
votes
0 answers

pytorch tensor stride - how it works

PyTorch doesn't seem to have documentation for tensor.stride(). Can someone confirm my understanding? My questions are three-fold. Stride is for accessing an element in the storage. So stride size will be the same as the dimension of the tensor.…
aerin
  • 20,607
  • 28
  • 102
  • 140
6
votes
1 answer

numpy stride_tricks.as_strided vs list comprehension for rolling window

When dealing with rolling windows, I wrote my functions in the way like list comprehension [np.std(x[i:i+framesize]) for i in range(0, len(x)-framesize, hopsize)])] Recently I discovered numpy.lib.stride_tricks.as_strided and found it is used…
wsdzbm
  • 3,096
  • 3
  • 25
  • 28
1
2 3
10 11