Maxwell's Daemon
Maxwell's Daemon

Reputation: 631

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

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.

Upvotes: 0

Views: 87

Answers (1)

Vladimir Fokow
Vladimir Fokow

Reputation: 3883

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)

Upvotes: 1

Related Questions