-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender_output.py
More file actions
32 lines (32 loc) · 1.28 KB
/
Copy pathrender_output.py
File metadata and controls
32 lines (32 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import numpy as np
import matplotlib.pyplot as plt
from file_util import (getImagePath,bipolarToImage)
import os
#Done: Convert bw image values to bipolar values
outputFolder = "Output/v1"
examplarNumbers = [3,5]
divisor = 10
numberstr = ''.join([str(i) for i in examplarNumbers])
outputImageFolder = f"OutputImages/v1_{numberstr}"
if not os.path.exists(outputImageFolder):
os.mkdir(outputImageFolder)
for selected_number in examplarNumbers:
numberOutput = []
maxIteration = 2
for i in range(maxIteration):
for j in range(0,100,divisor):
outputName = f"{selected_number}_{i}_{j}.txt"
imagePath = getImagePath(outputFolder, outputName)
if not os.path.exists(imagePath):
print(f"Error: File {imagePath} does not exist")
break
imageMatrix = np.loadtxt(imagePath)
numberOutput.append(imageMatrix)
#print(numberOutput)
bwImages = [np.vectorize(bipolarToImage)(matrix) for matrix in numberOutput]
for image in bwImages:
for i in range(maxIteration):
for j in range(0,100,divisor):
imageName = f"{selected_number}_{i}_{j}.png"
imagePath = getImagePath(outputImageFolder,imageName)
plt.imsave(imagePath,image,cmap='gray')