I try to get familiar with a bit of image processing. I did an exercise online and I have a challenge with one of the functions, I cannot debug properly.
import numpy as np
from scipy import misc
import matplotlib.pyplot as plt
import imageio
# Masking Images
photoData = imageio.imread("../images/sd-3layers.jpg")
totalRows, totalCols, totalLayers = photoData.shape
X, Y = np.ogrid(:totalRows, :totalCols)
centerRow, centerCol = totalRows / 2, totalCols / 2
distanceFromCenter = (X - centerRow)**2 + (Y - centerCol)**2
radius = (totalRows / 2)**2
circularMask = (distanceFromCenter > radius)
print(circularMask[1500:1700,2000:2000])
I get the following error:
File "<ipython-input-28-6cc7fea28dce>", line 4
X, Y = np.ogrid(:totalRows, :totalCols)
^
SyntaxError: invalid syntax
I do not know why this is actually happening? The data input seems correct to me. What is wrong with the syntax. Can you help me please?
:totalRows? what should this do?np.ogrid(:totalRows, :totalCols)? Maybenp.ogrid[:totalRows, :totalCols]? (Your line looks like Ruby to me lol):liststatement ever.