Loading compress_start.py +12 −8 Original line number Original line Diff line number Diff line Loading @@ -101,18 +101,18 @@ def plot_hist(tiff_list): image = Image.open(image) #Open the image and read it as an Image object image = Image.open(image) #Open the image and read it as an Image object image = np.array(image)[1:,:] #Convert to an array, leaving out the first row because the first row is just housekeeping data image = np.array(image)[1:,:] #Convert to an array, leaving out the first row because the first row is just housekeeping data row, col = image.shape row, col = image.shape predict = np.empty(row,col) # create a empty matrix to update prediction predict = np.empty((row,col)) # create a empty matrix to update prediction predict[0,:] = image[0,:] # keep the first row from the image predict[0,:] = image[0,:] # keep the first row from the image predict[:,0] = image[:,0] # keep the first columen from the image predict[:,0] = image[:,0] # keep the first columen from the image diff = np.empty(row,col) diff = np.empty((row,col)) diff[0,:] = np.zeros(row) # keep the first row from the image diff[0,:] = np.zeros(col) # keep the first row from the image diff[:,0] = np.zeros(col) diff[:,0] = np.zeros(row) for r in range(1,row): # loop through the rth row for r in range(1,row-1): # loop through the rth row for c in range(1,col): # loop through the cth column for c in range(1,col-1): # loop through the cth column surrounding = anp.array([predict[r-1,c-1], predict[r-1,c], predict[r-1,c+1], predict[r1,c-1]]) surrounding = np.array([predict[r-1,c-1], predict[r-1,c], predict[r-1,c+1], predict[r,c-1]]) predict[r,c] = np.mean(surrounding) # take the mean of the previous 4 pixels predict[r,c] = np.mean(surrounding) # take the mean of the previous 4 pixels diff[r,c] = (np.max(surrounding)-np.min(surrounding)) diff[r,c] = (np.max(surrounding)-np.min(surrounding)) return image, predict, diff if __name__ == '__main__': if __name__ == '__main__': Loading @@ -124,5 +124,9 @@ if __name__ == '__main__': scenes = file_extractor() scenes = file_extractor() images = image_extractor(scenes) images = image_extractor(scenes) image, predict, difference = plot_hist(images) error = np.abs(image-predict) No newline at end of file Loading
compress_start.py +12 −8 Original line number Original line Diff line number Diff line Loading @@ -101,18 +101,18 @@ def plot_hist(tiff_list): image = Image.open(image) #Open the image and read it as an Image object image = Image.open(image) #Open the image and read it as an Image object image = np.array(image)[1:,:] #Convert to an array, leaving out the first row because the first row is just housekeeping data image = np.array(image)[1:,:] #Convert to an array, leaving out the first row because the first row is just housekeeping data row, col = image.shape row, col = image.shape predict = np.empty(row,col) # create a empty matrix to update prediction predict = np.empty((row,col)) # create a empty matrix to update prediction predict[0,:] = image[0,:] # keep the first row from the image predict[0,:] = image[0,:] # keep the first row from the image predict[:,0] = image[:,0] # keep the first columen from the image predict[:,0] = image[:,0] # keep the first columen from the image diff = np.empty(row,col) diff = np.empty((row,col)) diff[0,:] = np.zeros(row) # keep the first row from the image diff[0,:] = np.zeros(col) # keep the first row from the image diff[:,0] = np.zeros(col) diff[:,0] = np.zeros(row) for r in range(1,row): # loop through the rth row for r in range(1,row-1): # loop through the rth row for c in range(1,col): # loop through the cth column for c in range(1,col-1): # loop through the cth column surrounding = anp.array([predict[r-1,c-1], predict[r-1,c], predict[r-1,c+1], predict[r1,c-1]]) surrounding = np.array([predict[r-1,c-1], predict[r-1,c], predict[r-1,c+1], predict[r,c-1]]) predict[r,c] = np.mean(surrounding) # take the mean of the previous 4 pixels predict[r,c] = np.mean(surrounding) # take the mean of the previous 4 pixels diff[r,c] = (np.max(surrounding)-np.min(surrounding)) diff[r,c] = (np.max(surrounding)-np.min(surrounding)) return image, predict, diff if __name__ == '__main__': if __name__ == '__main__': Loading @@ -124,5 +124,9 @@ if __name__ == '__main__': scenes = file_extractor() scenes = file_extractor() images = image_extractor(scenes) images = image_extractor(scenes) image, predict, difference = plot_hist(images) error = np.abs(image-predict) No newline at end of file