Home > Blockchain >  centering an 2D image with respect to x,y axis
centering an 2D image with respect to x,y axis

Time:09-01

I have a 2D array with shape (512,512) that looks like this:

my_image

I'd like to display it with the center point, which is (183., 185.), to be the origin of coordinates, i.e., (0,0).

If I subtract each of those values (183. and 185.), row and column-wise, respectively, the axis don't move, but the values of the arrays change, obviously.

How to achieve that transformation?

Thanks in advance.

CodePudding user response:

Try:

tick_step = 100

x_len = my_img.shape[0]
y_len = my_img.shape[1]

xticks = np.arange(0, x_len, tick_step)
yticks = np.arange(0, y_len, tick_step)

ax.set_xticks(xticks)
ax.set_yticks(yticks)

ax.set_xticklabels(xticks - 183)
ax.set_yticklabels(yticks - 185)
  • Related