1

I have an array of topography data (n x m) which is rectangular but inscribed in an array of zeros (a x b) . I want to remove the zeros and shift the array is a rectangle.

image of array where the white is the data I want and the black are extra zeros.

How do I shift the data over and get rid of not only the zeros but also the extra indices (thus it will be all data no zeros of shape nxm )?

Just removing the zeros does not help since they just become extra indices. I thought about shifting it by moving them up or down a set amount but I realized it needs to rotate around a center point which I have no idea how to do.

Any help is very appreciated ( I am familiar with both python and matlab).

akimbo
  • 45
  • 6
  • You have received answers about rotating an image but I suspect that the image you linked is just for explanation and you have an array of diagonally sampled elevations that you want to, say, straighten up... am I correct? – gboffi May 13 '19 at 09:50
  • Yes! The image is just an explanation of what the array looks like. – akimbo May 15 '19 at 18:45

1 Answers1

1

With Matlab you can rotate the image -21 deg, then clip the image. Note that this is not a perfect rectangle.

img = imread('NkiuNE9.png');
% rotate by -21deg
img = imrotate(img,-21);
% clip the image
img = img(75:445,123:367);
imshow(img)
Yuval Harpaz
  • 1,416
  • 1
  • 12
  • 16