Consider:
i = 2
feature_vector_set = []
while i < 2405 - 2:
    j = 2
    while j < 1200 - 2:
       block = diff_image[i-2:i+3, j-2:j+3]
       feature = block.flatten()
       feature_vector_set.append(feature)
       j = j+1
    i = i+1
diff_image is of type int16 with shape(2405, 1200). The whole loop takes 40 minutes to run and is mainly caused by the following line:
feature_vector_set.append(feature)
Is there an alternative way to achieve the same result?
 
     
    