stride

Stride on image using Opencv C++

安稳与你 提交于 2019-12-01 11:02:43
问题 I am on windows and use opencv 2.4.2 on C++. I read an image with imread and put it in a Mat object. After that, i get a pointer on the raw data using the function ptr of the Mat class. I would like to know how works imread when the image contains stride. Is there stride in the data of the Mat or only data of pixels ? Additional information: I need the raw data because I am using a code written with array and I don't want to change it for the Mat class. 回答1: The stride is that each new row of

c# scan0 and stride

冷暖自知 提交于 2019-12-01 08:01:48
Anyone know what Scan0 and Stride for? I need a good explanation Thanks. Are you talking about the BitmapData class? If so, the description in the documentation is reasonably clear, I think: Scan0 : Gets or sets the address of the first pixel data in the bitmap. This can also be thought of as the first scan line in the bitmap. In other words, this lets you find the data to examine or change - or even lets you make the bitmap to a completely different piece of data. Stride : The stride is the width of a single row of pixels (a scan line), rounded up to a four-byte boundary. If the stride is

What is the meaning of 2D stride in convolution?

依然范特西╮ 提交于 2019-12-01 06:16:53
I know what meaning stride has when it is just an integer number (by which step you should apply filter to image). But what about (1, 1) or even more dimensional stride? The stride defines how the filter is moved along the input image (tensor). Nothing stops you from striding along different axes differently, e.g., stride=[1, 2] means move 1px at a time along 0 axis, and 2px at a time along 1 axis. This particular combination isn't common, but possible. Tensorflow API goes even further and allows custom striding for all axes of the 4D input tensor (see tf.nn.conv2d ). Using this API it's not

What is the meaning of 2D stride in convolution?

放肆的年华 提交于 2019-12-01 05:57:33
问题 I know what meaning stride has when it is just an integer number (by which step you should apply filter to image). But what about (1, 1) or even more dimensional stride? 回答1: The stride defines how the filter is moved along the input image (tensor). Nothing stops you from striding along different axes differently, e.g., stride=[1, 2] means move 1px at a time along 0 axis, and 2px at a time along 1 axis. This particular combination isn't common, but possible. Tensorflow API goes even further

Copying strided data in C++

主宰稳场 提交于 2019-11-29 12:52:38
问题 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 standard, strided version of memcpy?", it seems that there is no such a possibility in C. However, I have experienced that, in some cases, memcpy is faster than a for loop based copy. My question is; Is there any way to efficiently perform strided

Can anyone help in understanding AVFrame.linesize[]?

非 Y 不嫁゛ 提交于 2019-11-29 01:17:06
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, frameDecoded, &frameFinished, &packet); only linesize[0] has the value and other cells are always 0? UPDATED I think AVFrame.data[i] and AVFrame.linesize[i] are the data of specific color in the row and the length of the row, am I correct? pogorskiy In the case of planar data, such as YUV420 , linesize[i] contains stride for the i -th plane. For example, for

How to understand numpy strides for layman?

◇◆丶佛笑我妖孽 提交于 2019-11-28 23:37:41
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? The actual data of a numpy array is stored in a homogeneous and contiguous block of memory called data buffer. For more information see NumPy internals . Using the (default) row-major order, a 2D array looks like this: To map the indices i,j,k,... of a multidimensional array to the positions in the data buffer (the offset, in bytes), NumPy uses the notion of strides .

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

送分小仙女□ 提交于 2019-11-28 12:24:13
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, ImageFormat.Gif); ms.Position = 0; return System.Drawing.Image.FromStream(ms); } } 2. http://www.wischik.com/lu/programmer/1bpp.html But: 1. Results in a very low quality result (bad pallet) and 2 gives me a Bitmap with negative stride, when I try to lockbits and copy the data to a byte array I get an exception: Attempted to read or write protected memory. This is often an indication that other

Why does BitmapSource.Create throw an ArgumentException?

亡梦爱人 提交于 2019-11-27 14:11:51
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++) { Int32 index = j + (i * RenderHeight); if (i + j % 2 == 0) data[index] = 0xFF0000; else data[index] = 0x00FF00; } } BitmapSource source = BitmapSource.Create(RenderWidth, RenderHeight, 96.0, 96.0, PixelFormats.Bgr32, null, data, 0); RenderImage.Source = source; However the call to BitmapSource.Create throws an ArgumentException, saying "Value does not fall

Find boolean mask by pattern

◇◆丶佛笑我妖孽 提交于 2019-11-27 07:56:04
问题 I have array: arr = np.array([1,2,3,2,3,4,3,2,1,2,3,1,2,3,2,2,3,4,2,1]) print (arr) [1 2 3 2 3 4 3 2 1 2 3 1 2 3 2 2 3 4 2 1] I would like find this pattern and return booelan mask: pat = [1,2,3] N = len(pat) I use strides : #https://stackoverflow.com/q/7100242/2901002 def rolling_window(a, window): shape = a.shape[:-1] + (a.shape[-1] - window + 1, window) strides = a.strides + (a.strides[-1],) c = np.lib.stride_tricks.as_strided(a, shape=shape, strides=strides) return c print (rolling_window