sliding-window

MATLAB function to process vector with sliding window function, return matrix of vector responses

百般思念 提交于 2019-12-12 19:34:19
问题 Assuming vector v of size 1 x n and function fun that takes in a vector of length L and returns a vector of size p x 1 . Is there a MATLAB function that would take in vector v , process each sliding window of length L with function fun, and return a matrix of size p x n (or p x (n-L) ). I am aware this could be achieved with creating a matrix of windowed vectors with im2col and processing each of those, but this takes too much memory for a long vector v . 回答1: funsl=@(is) fun(v(is:is+l-1));

How to output a struct array when I use the nlfilter function?

别来无恙 提交于 2019-12-12 09:42:46
问题 I have the following function which calculates statistic parameters. I would like to pass this function to nlfilter to do the calculation for a whole image. But the output of nlfilter must be a scalar. How can I convert this to a function handle suitable for use with nlfilter so I can save the output of the function getStatistics2 ? The getStatistics2 function's output is an struct array. function [out] = getStatistics2(D) D = double(D); % out.MAX = max(D);%maximum % out.MIN = min(D);%minimum

Overlapping Sliding windows over image

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 04:49:18
问题 My objective is to have a sliding window slide over an image in overlapping steps so that I can run a classifier in each window and detect if an interesting object is there. For that, I need to make sure that windows I extract for classification truly do over the whole image, and grab the top and left coordinates of each sliding window on the original image. Following up from here: Sliding window - how to get window location on image? and based on this code for sliding windows: https://github

How can I set the value of border pixels after applying a sliding window operation?

夙愿已清 提交于 2019-12-11 13:27:07
问题 After applying a sliding-window operation like stdfilt(i, ones(5, 5)) to an image in MATLAB, I would like to set the border pixels, the pixels calculated using padding, to NaN to mark them as meaningless. In this example, I would set the outermost two rows and columns to NaN . Given an M * M window, how can I set this border that is (M - 1) / 2 pixels wide to a specific value? 回答1: Suppose, r is the matrix (result of stdfilt ). Here is an example how to assign NaN to borders. In general, you

SQL Implementation with Sliding-Window functions or Recursive CTEs

此生再无相见时 提交于 2019-12-11 12:03:51
问题 I have a problem that it's very easy to be solved in C# code for example, but I have no idea how to write in a SQL query with Recursive CTE-s or Sliding-Windows functions. Here is the situation: let's say I have a table with 3 columns ( ID, Date, Amount ), and here is some data: ID Date Amount ----------------------- 1 01.01.2016 -500 2 01.02.2016 1000 3 01.03.2016 -200 4 01.04.2016 300 5 01.05.2016 500 6 01.06.2016 1000 7 01.07.2016 -100 8 01.08.2016 200 The result I want to get from the

MATLAB Circular sliding window and pixel values on diameters extraction

巧了我就是萌 提交于 2019-12-11 03:26:59
问题 I'm trying to implement an algorithm that needs a circular sliding window, that goes through all the pixels of the image, and for each window I need to extract only pixels that lay on diameters at different angles of the circle. I try to explain better with the use of the image above. Imagine that this is the result of a circular sliding window, I want to get only the pixel values that lay on the red line (diameter tilted of pi/8). So far, I wrote these lines of code: I= imread('lena.png'); I

Numpy rolling window over 2D array, as a 1D array with nested array as data values

血红的双手。 提交于 2019-12-11 02:27:15
问题 When using np.lib.stride_tricks.as_strided , how can I manage 2D a array with the nested arrays as data values? Is there a preferable efficient approach? Specifically, if I have a 2D np.array looking as follows, where each data item in a 1D array is an array of length 2: [[1., 2.],[3., 4.],[5.,6.],[7.,8.],[9.,10.]...] I want to reshape for rolling over as follows: [[[1., 2.],[3., 4.],[5.,6.]], [[3., 4.],[5.,6.],[7.,8.]], [[5.,6.],[7.,8.],[9.,10.]], ... ] I have had a look at similar answers

Summing the counts in a data frame using sliding window

你离开我真会死。 提交于 2019-12-11 00:36:09
问题 I am new to R. I have a data frame in R like following df <- data.frame(ID=c(rep("A1",10),rep("A2",13),rep("A3",12)), Values=c(10,2,4,23,10,5,20,15,13,21,15,9,19,5,14,25,18,19,31,26,4,21,4,6,7,12,15,18,25,20,16,29,21,19,10)) For every ID I would like to sum the counts in column "Values" in a sliding windows for every 3 positions. Following data frame is an excerpt from df which includes only the records corresponding to A1 : ID Values A1 10 A1 2 A1 4 A1 23 A1 10 A1 5 A1 20 A1 15 A1 13 A1 21 I

Reuse an XML layout file to show different information (Android Application)

柔情痞子 提交于 2019-12-10 11:53:06
问题 I’m new to Android and have a simple question. Currently I’m working on a products application that allows users to add, remove and browse variety of products. The application uses a predefined XML-based layout file as a template that fills the entire screen to show the current product details. When the user adds a new product, I want to re-use the same layout file but populate it with the new product’s information. Also, I want to keep the previously added products (e.g. an ArrayList) and

Finding consecutively increasing subsequence stored in a haphazard manner

喜夏-厌秋 提交于 2019-12-10 11:45:52
问题 The problem is this, given an array of length say N , we have to find all subsequences of length W such that those W elements, when sorted, forms an arithmetic progression with interval 1. So for an array like [1,4,6,3,5,2,7,9] , and W as 5, the slice [4,6,3,5,2] can be regarded as one such subsequence, since, when sorted, it yields [2,3,4,5,6] , an A.P with common difference 1. The immediate solution which comes to the mind is to have a sliding window, for each new element, pop the old one,