Commit 1e878b78 authored by constantin.hoeing's avatar constantin.hoeing
Browse files

Upload New File

parent c0e253cf
written on 10. May 2019 by
Constantin Höing
Inst. Fuer Numerische und Angewandte Mathematik
Universität Göttingen
DESCRIPTION: Reorders a 2x2 image
INPUT: A, an image to be reordered
OUTPUT: B, the reordered image
USAGE: B=Reorder(A)
from numpy import shape, zeros, arange, concatenate, size
def Reorder(B):
# Reorders a matrix
n1 = shape(B)[-2] -1
n2 = shape(B)[-1]
# if it is a nxmxk matix
#A = zeros((n1+1, n2))
A = zeros((size(B[:, 0]), n2))
for j in range(n1+1):
#A[n1-j, :] = B[j, :]
A[:, n1-j] = concatenate(B[:, j])
return A.T
#if it is a n x m matrix
A = zeros((n1+1, n2))
#A = zeros((size(B[:, 0]), n2))
for j in range(n1+1):
A[n1-j, :] = B[j, :]
#A[:, n1-j] = concatenate(B[:, j])
return A
if __name__ == "__main__":
# does the Reorder.m file miss a "end" statemant at the end of the function ??
A = arange(1,19).reshape(2,3,3)
A = arange(1,10).reshape(3,3)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment