# create1DImage

MainPage

Description: This function recieves a (1 x n) 1D image with pixels intensities between 0 and 7 and returns a pixels image ready for display.

Signature: img1D = create1DImage(img)

Input:
• img, 2d-array, uint8. Image 1xn corresponding to a 1D image.

Output:

• img1D, 2d-array,uint8. 1D image ready for display.

# Python Implementation

1 import numpy as np
2
3 def create1DImage(img):
4     """
5     ((1xn)-array) (int) -> (pixels_sizexn*pixels_size)-array)
6     This function recieves a (1 x n) 1D image with pixels intensities between
7     0 and 7 and returns a pixels image ready for display. pixels_size define
8     the size of the pixels.
9     """
10
11     pixels_size = 25
12     img1D = img.copy()
13     img1D = np.repeat(img1D*35, pixels_size,axis = 1)
14     img1D = np.repeat(img1D,pixels_size,axis = 0)
15
16     #Drawing yellow lines to separate the pixels
17     img1D = np.array([img1D,img1D,img1D])
18     img1D[2,:,::pixels_size] = 0
19     img1D[2,::pixels_size,:] = 0
20     img1D[0,::pixels_size,:] = 255
21     img1D[0,:,::pixels_size] = 255
22     img1D[1,::pixels_size,:] = 255
23     img1D[1,:,::pixels_size] = 255
24     img1D[2,:,-1] = 0
25     img1D[2,-1,:] = 0
26     img1D[0,-1,:] = 255
27     img1D[0,:,-1] =255
28     img1D[1,-1,:] = 255
29     img1D[1,:,-1] = 255
30     return img1D

# Example

1 from iamxt.draw_1D_image import create1DImage
2 import numpy as np
3
4 img = np.array([[0,1,2,3,4,5,4,3,2,1,0]], dtype = np.uint8)
5 img1D = create1DImage(img)
6