Created
October 25, 2017 19:24
-
-
Save roman-smirnov/8ba348d1b3e73f090e654a60cc5086d7 to your computer and use it in GitHub Desktop.
python opencv remove alternating rows and display image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
from skimage.viewer import ImageViewer | |
def remove_rows(image, rows, cols): | |
newrows = int(rows / 2) | |
newimg = np.zeros((newrows, cols), np.uint8) | |
for r in range(1, newrows+1): | |
newimg[r-1:r, :] = image[r*2-1:r*2, :] | |
return newimg | |
img = cv2.imread('pirate.jpg', cv2.IMREAD_GRAYSCALE) | |
print(img.shape) | |
img = remove_rows(img, img.shape[0], img.shape[1]) | |
viewer = ImageViewer(img) | |
viewer.show() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment