Simple image processing with Python, Numpy & Matplotlib

Image

When I saw the topmost image on the Russian riot police, I just had to do a simple image transformation, more specifically, a reflection, to produce a mirror image.

Numpy’s powerful functions makes such a tranformation very simple.

 

import matplotlib.pyplot as plt
import numpy as np
import matplotlib.image as mpimg

fig = plt.figure(figsize=(14, 6.5), dpi=100)

image=mpimg.imread('omoh.jpg')
shape = image.shape
newimage = np.ndarray(shape)
newimage = np.fliplr(image)

fig.add_subplot(2,1,1)
plt.imshow(image)
plt.axis('off')

fig.add_subplot(2,1,2)
plt.imshow(newimage)
plt.axis('off')

plt.show()
Advertisements

About swdevperestroika

High tech industry veteran, avid hacker reluctantly transformed to mgmt consultant.
This entry was posted in development, software and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s