Commit 0697219e authored by Nathaniel Callens's avatar Nathaniel Callens

Latest experimentations with tiff images

parent 9187e090
...@@ -41,31 +41,49 @@ def image_extractor(scenes): ...@@ -41,31 +41,49 @@ def image_extractor(scenes):
return images #returns a list of file paths to .tiff files in the specified directory given in file_extractor return images #returns a list of file paths to .tiff files in the specified directory given in file_extractor
if __name__ == '__main__': if __name__ == '__main__':
image = Image.open("practice_tiff.tiff")
image2 = Image.open("practice2.tiff")
imarray2 = np.array(image2)
imarray = np.array(image)
work = imarray2[:,:,0]
ind1, ind2 = np.random.randint(0,434), np.random.randint(0,650)
surrounding = []
for i,j in product(np.arange(-1,2), repeat=2):
if i == 0 and j == 0:
continue
else:
surrounding.append(work[ind1+i, ind1+j])
diff = []
diff.append(np.max(surrounding)-np.min(surrounding))
print(surrounding)
print(diff)
"""For boundary cases: Start by grabbing the shape of the images and saving those """For boundary cases: Start by grabbing the shape of the images and saving those
as variables. Then, if statements for if row == 0 or row == maximum and if as variables. Then, if statements for if row == 0 or row == maximum and if
col == 0 or col == maximum. Then grab corresponding open pixels. Then proceed to do col == 0 or col == maximum. Then grab corresponding open pixels. Then proceed to do
an and statement that handles the corners""" an and statement that handles the corners"""
tiff0 = []
tiff1 = []
tiff2 = []
tiff3 = []
files = os.listdir("images")
scenes = []
for file in files:
scene = os.path.join("images", file)
sc = os.listdir(scene)
for s in sc:
if s[-6] == '0':
tiff0.append(os.path.join(scene, s))
elif s[-6] == '1':
tiff1.append(os.path.join(scene, s))
elif s[-6] == '2':
tiff2.append(os.path.join(scene, s))
elif s[-6] == '3':
tiff3.append(os.path.join(scene, s))
diff = []
for ii in range(len(tiff1)):
image = Image.open(tiff1[ii])
image = np.array(image)[1:,:]
ar1, ar2 = image.shape
ind1, ind2 = np.random.randint(0,ar1), np.random.randint(0,ar2)
surrounding = []
for i,j in product(np.arange(-1,2), repeat=2):
if i == 0 and j == 0:
continue
else:
surrounding.append(image[ind1+i, ind1+j])
diff.append(np.max(surrounding)-np.min(surrounding))
print(diff)
"""scene_names = file_extractor() """scene_names = file_extractor("images")
images = image_extractor(scene_names) images = image_extractor(scene_names)
im = Image.open(images[0]) im = Image.open(images[0])
imarray = np.array(im) imarray = np.array(im)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment