submatrix

opencv android java matrix submatrix (ROI Region of Interest)

岁酱吖の 提交于 2019-12-12 04:57:58
问题 I've mRgba Matrix and a Rect r (something recognized in the frame) I want a sub-matrix of this part of the frame which is defined by the Rect r. when I use it like this: sub = mRgba.submat(r); I get the right sub-matrix, but I've a problem with the next steps, I want to change this part of the frame and then copy it back to the original. For example: Imgproc.cvtColor(sub, sub, Imgproc.COLOR_RGBA2GRAY, 1); //make it gray Imgproc.cvtColor(sub, sub, Imgproc.COLOR_GRAY2RGBA, 4); //change to rgb

Normalize between-blocks by the maxima of the block corresponding to the columns

て烟熏妆下的殇ゞ 提交于 2019-12-12 04:17:42
问题 This question is a follow-up on my previous question Instead of normalizing blocks by the local maxima, I would like to normalize between-blocks by the maxima of the block corresponding to the columns. #dummy data mat <- matrix(round(runif(90, 0, 50),),9,9) rownames(mat) <- rep(LETTERS[1:3],3) colnames(mat) <- rep(LETTERS[1:3],3) #Normalizes within and between blocks by the maxima of the focal block ans <- mat / ave(mat, rownames(mat)[row(mat)], colnames(mat)[col(mat)], FUN = max) #Number of

Normalize blocks/sub-matrices within a matrix

独自空忆成欢 提交于 2019-12-12 02:43:48
问题 I want to normalize (i.e., 0-1) blocks/sub-matrices within a square matrix based on row/col names. It is important that the normalized matrix correspond to the original matrix. The below code extracts the blocks, e.g. all col/row names == "A" and normalizes it by its max value. How do I put that matrix of normalized blocks back together so it corresponds to the original matrix, such that each single value of the normalized blocks are in the same place as in the original matrix. I.e. you

How to print all square submatrices of square matrix in C?

强颜欢笑 提交于 2019-12-08 18:46:30
Please, help me to find and print all square submatrices of square matrix from big to small square matrices in C programming language I wrote code that works wrong: int main() { int mtrx_size = 8; int mat[8][8] = { { 1, 2, 3, 4, 5, 6, 7, 8}, { 9,10,11,12,13,14,15,16}, {17,18,19,20,21,22,23,24}, {25,26,27,28,29,30,31,32}, {33,34,35,36,37,38,39,40}, {41,42,43,44,45,46,47,48}, {49,50,51,52,53,54,55,56}, {57,58,59,60,61,62,63,64} }; int i,j; int sub_mtrx_size; for(sub_mtrx_size = mtrx_size; sub_mtrx_size > 1 ; sub_mtrx_size--) { for(i = 0; i < sub_mtrx_size; i++) { for(j = 0; j < sub_mtrx_size; j+

In R, Extract from a matrix all rows indexed by the components of a vector

Deadly 提交于 2019-12-08 05:44:19
问题 In R, let M be the matrix: [,1] [,2] [1,] 1 9 [2,] 3 12 [3,] 6 4 [4,] 7 2 I would like to extract all rows with entries equal to the components of the vector v <- c(3,6,1) from column [,1] in M producing the submatrix m: [,1] [,2] [1,] 1 9 [2,] 3 12 [3,] 6 4 I tried m <- M[which(M[,1] == v), ] obtaining the error message longer object length is not a multiple of shorter object length . Using the transpose t(v) of v does not help. Thanks a lot! Avitus 回答1: using %in% : M[M[,1] %in% v,] [,1] [

MATLAB: extract submatrix with logical indexing

馋奶兔 提交于 2019-12-06 23:29:58
问题 I'm looking for an elegant solution to this very simple problem in MATLAB. Suppose I have a matrix >> M = magic(5) M = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 and a logical variable of the form I = 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 If I try to retrieve the elements of M associated to 1 values in I , I get a column vector >> M(I) ans = 5 6 7 13 What would be the simplest way to obtain the matrix [5 7 ; 6 13] from this logical indexing? If I know the

Better way to extract all the rows from a Matrix A that contain an element of a matrix B

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 14:34:10
Matrix A is my starting matrix it holds the data logged from my MPU6050 and GPS on an SD Card (Latitude, Longitude, Time, Ax, Ay, Az, Gx,Gy,Gz). I calculated the standard deviation of Az for window size of 5 and identified all the elements that satisfy a condition (>threshold). Then in a matrix "large_windows" i stored the index of all the Az in the window that satisfy the condition. From matrix "large_windows" i calculated a new matrix B with all the rows from matrix A that contain the matrix "large_windows" elements. I think my code is effective , but very ugly and chaotic, plus i am still

MATLAB: extract submatrix with logical indexing

别等时光非礼了梦想. 提交于 2019-12-05 03:23:59
I'm looking for an elegant solution to this very simple problem in MATLAB. Suppose I have a matrix >> M = magic(5) M = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 and a logical variable of the form I = 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 If I try to retrieve the elements of M associated to 1 values in I , I get a column vector >> M(I) ans = 5 6 7 13 What would be the simplest way to obtain the matrix [5 7 ; 6 13] from this logical indexing? If I know the shape of the non-zero elements of I , I can use a reshape after the indexing, but that's not a general

Submatrices and indices using Eigen

怎甘沉沦 提交于 2019-12-03 09:02:26
问题 I'm currently working on a MATLAB project and I'd like to re-implement the most computational-heavy parts using C++ and Eigen. I'd like to know if there's a way to perform the following operation (MATLAB syntax): B = A(A < 3); For those who are not familiar with MATLAB, the above-mentioned command initializes a matrix B made of the cells in A whose values are less than 3. I've seen from a post on the Eigen forum that it's possible to obtain the indices of interest by using: MatrixXi indices =

find largest submatrix algorithm

烈酒焚心 提交于 2019-12-03 07:41:15
I have an N*N matrix (N=2 to 10000) of numbers that may range from 0 to 1000. How can I find the largest (rectangular) submatrix that consists of the same number? Example: 1 2 3 4 5 -- -- -- -- -- 1 | 10 9 9 9 80 2 | 5 9 9 9 10 3 | 85 86 54 45 45 4 | 15 21 5 1 0 5 | 5 6 88 11 10 The output should be the area of the submatrix, followed by 1-based coordinates of its top left element. For the example, it would be (6, 2, 1) because there are six 9 s situated at column 2, row 1. This is a work in progress I thought about this problem and I think I may have a O(w*h) algorithm. The idea goes like