matrix

How does pinch zoom work with panning for image in Android

旧城冷巷雨未停 提交于 2020-01-05 05:41:48
问题 Goal An activity is made to view image, we can pinch zoom or pan the image. The image is centered in the screen in the beginning. Pinch zoom is centered at the center of the image, even after the image is panned somewhere else in the screen. The image for displaying is downloaded from a given URL, and the URL is passed from extra of an intent to start the image viewing activity. Pinch zoom is implemented by postScale() , pan by postTranslate() . Problem After panning the image somewhere, the

What does a matrix array look like for a Johnson graph?

强颜欢笑 提交于 2020-01-05 05:10:01
问题 I can't seem to find any examples (or much information at all) of what a matrix array looks like for a Johnson graph. Can anyone send me an example of what their arrays look like? 回答1: This directly uses the definition of a Johnson Graph given here Wiki Johnson Graph johnsonmatrix[n_, k_] := Module[{s=Select[Subsets[Range[n]], Length[#]==k&]}, {s, MatrixForm[Table[If[Length[Intersection[s[[i]], s[[j]]]]==k-1, 1, 0], {i, Length[s]}, {j, Length[s]}]]}] and generates the list of subsets which

Tkinter 16 grids (4x4 orientation) with 5x5 button grid each

我的梦境 提交于 2020-01-05 04:41:11
问题 I have this simple 5x5 button grid: from tkinter import * class App(): def __init__(self, root): self.root = root self.TopFrame = Frame(root) self.BottomFrame = Frame(root) self.TopFrame.grid(row=0) self.BottomFrame.grid(row=6) buttonQ = Button(self.BottomFrame, text="Quit", command=quit) buttonS = Button(self.BottomFrame, text="Save", command=self.saveToFile) buttonS.grid(row=0, column=0, padx=10) buttonQ.grid(row=0, column=1, padx=10) def Function(self): self.grid = [] for i in range(5):

Iterate over diagonal elements of a Matrix in MatLab

↘锁芯ラ 提交于 2020-01-05 04:25:13
问题 I need to get the indexes of all diagonals in a matrix. The matrix can be non square. The diag function gives the values, but I need the coords. So for instance with this: [1 2 3; 4 5 6; 7 8 9] , I want [1 1; 2 2; 3;3] PLUS [2 6] and 3 because they are the upper diagonals of the matrix, and same for below i.e. [4 8] and 7 . So the full list of indexes is: [1 1; 2 2; 3 3], [1 2; 2 3], [1 3], [2 1], [3 2], [3 1] . And I need this in the other diagonal direction too... And it needs to work for

Algorithm to find the shortest path in a matrix

有些话、适合烂在心里 提交于 2020-01-05 04:05:10
问题 I tried to find an algorithm for the following problem, but I couldn't. you have a matrix, 10X6 if it matters. (10 on x dimension 6 on y dimension). the algorithm receives 2 point, the opening point and the target point. the array is full of 0's and 1's and it should find the shortest path of 1's between them, and return the first point in this path (the next point in the way to the target). But here's the catch: each point can get the value only of the following points: the point above it.

Replace all elements of a matrix by their inverses

喜你入骨 提交于 2020-01-05 03:48:10
问题 I've got a simple problem and I can't figure out how to solve it. Here is a matrix: A = np.array([[1,0,3],[0,7,9],[0,0,8]]) . I want to find a quick way to replace all elements of this matrix by their inverses, excluding of course the zero elements. I know, thanks to the search engine of Stackoverflow, how to replace an element by a given value with a condition. On the contrary, I do not figure out how to replace elements by new elements depending on the previous ones (e.g. squared elements,

Matlab - 8x8 window and finding mean

随声附和 提交于 2020-01-05 03:27:19
问题 Say I have a matrix of an image, and I want to do the following: Slide an 8x8 window over the matrix Calculate the mean for each pixel in the matrix How can I do that in matlab , provided that I'm kind of new to coding in matlab. Thanks. 回答1: You could use conv2 with a ones(8) filter, as in I2 = conv2(I, 1.0 / 64.0 * ones(8), 'valid'); . We divide by 64.0 because the "filter" isn't normalized. 回答2: You can also use nlfilter : fun = @(x) mean(x(:)); ans= nlfilter(img,[8 8],fun); But as @s

Matlab - 8x8 window and finding mean

試著忘記壹切 提交于 2020-01-05 03:27:07
问题 Say I have a matrix of an image, and I want to do the following: Slide an 8x8 window over the matrix Calculate the mean for each pixel in the matrix How can I do that in matlab , provided that I'm kind of new to coding in matlab. Thanks. 回答1: You could use conv2 with a ones(8) filter, as in I2 = conv2(I, 1.0 / 64.0 * ones(8), 'valid'); . We divide by 64.0 because the "filter" isn't normalized. 回答2: You can also use nlfilter : fun = @(x) mean(x(:)); ans= nlfilter(img,[8 8],fun); But as @s

Converting from sparse to dense to sparse again decreases density after constructing sparse matrix

故事扮演 提交于 2020-01-05 03:26:28
问题 I am using scipy to generate a sparse finite difference matrix, constructing it initially from block matrices and then editing the diagonal to account for boundary conditions. The resulting sparse matrix is of the BSR type. I have found that if I convert the matrix to a dense matrix and then back to a sparse matrix using the scipy.sparse.BSR_matrix function, I am left with a sparser matrix than before. Here is the code I use to generate the matrix: size = (4,4) xDiff = np.zeros((size[0]+1

R Pairwise comparison of matrix columns ignoring empty values

强颜欢笑 提交于 2020-01-05 03:09:11
问题 I have an array for which I would like to obtain a measure of the similarity between values in each column. By which I mean I wish to compare the rows between pairwise columns of the array and increment a measure when their values match. The resulting measure would then be at a maximum for two columns exactly the same. Essentially my problem is the same as discussed here: R: Compare all the columns pairwise in matrix except that I do not wish empty cells to be counted. With the example data