This commit introduces an image generator:
- How to execute:
`$ ./imagegen.py`
Two output images are generated: `image.bin` and `image.ppm`.
- Changing the size of the output image
Change variable `image_size` at the beginning of `imagegen.py`.
- Changing output image format
If you want to output another image format, you can use as below:
`im.save("image.jpg")`
Signed-off-by: Junghyun Kim <jh0822.kim@samsung.com>
--- /dev/null
+# A simple image generator
+
+## How to execute:
+`$ ./imagegen.py`
+Two output images are generated: `image.bin` and `image.ppm`.
+
+## Changing the size of the output image
+Change variable `image_size` at the beginning of `imagegen.py`.
+
+## Changing output image format
+If you want to output another image format, you can use as below:
+`im.save("image.jpg")`
+
+# An image importer
+Need description.
--- /dev/null
+#!/usr/bin/python
+from PIL import Image
+import numpy as np
+
+image_size = {
+ "H":10,
+ "W":10,
+ "C":3 # C is fixed as 3 for R,G,B channels
+ }
+
+rgb = np.zeros([image_size['H'],image_size['W'],image_size["C"]], dtype=np.uint8)
+for y in range(image_size["H"]):
+ for x in range(image_size["W"]):
+ for c in range(image_size["C"]):
+ rgb[y][x][c] = 255 #value range = [0~255]
+
+im = Image.fromarray(rgb)
+im.save("image.ppm")
+
+# image can be saved as .jpg or .png
+# im.save("image.jpg")
+# im.save("image.png")
+
+with open("image.bin", "wb") as f:
+ f.write(im.tobytes())