Hello I have an input image that has been imported as grayscale in float values. I am trying to use for loops to find the intensity this image. Using two for loops to loop over each row and column is not idea for larger image.
image = cv2.imread("W_A03.jpg", cv2.IMREAD_GRAYSCALE).astype(float)/255.0
intimage = np.zeros(image.shape, dtype=image.dtype)
output = np.zeros(image.shape, dtype=image.dtype)
w_Image, h_Image = image.shape[1], image.shape[0]
for h_Idx in range(h_Image):
for w_Idx in range(w_Image):
intimage[h_Idx, w_Idx] = image[0:h_Idx, 0:w_Idx].sum()
The resulting intimage should looks something like this:
Is there a shorter, cleaner, or more pythonic way to perform such tasks?
Edit: I am trying to use adaptive thresholding on a grayscale image. The pseudo code can be found here procedure AdaptiveThreshold