## DEV Community

Sai Rajesh Vanimireddy

Posted on • Updated on

# Datatypes in array object

### 1D Image:

One-dimensional pictures are those containing only one dimension. This is only possible when you're dealing with a line, as the only dimension you have is length, defined by a single array.When data objects are stored in an array, individual objects are selected by an index that is usually a non-negative scalar integer. Indexes are also called subscripts. An index maps the array value to a stored object. There are three ways in which the elements of an array can be indexed:

• 0 (zero-based indexing): The first element of the array is indexed by subscript of 0.
• 1 (one-based indexing): The first element of the array is indexed by subscript of 1.
• n (n-based indexing): The base index of an array can be freely chosen. Usually programming languages allowing n-based indexing also allow negative index values and other scalar data types like enumerations, or characters may be used as an array index.
• ``````import numpy as np
a = np.array([1, 2, 3,4,5])
a
a.ndim
a.shape
len(a)
Out[69]: 5
}
``````

### 2D Image:

The two dimensions depicted are length and width and the objects on the picture are flat. one of the examples of 2D images are gray scale images, a kind of black-and-white or gray monochrome.

``````import numpy as np
b = np.array([[0, 1, 2], [3, 4, 5]])
b
b.ndim
b.shape
len(b)
Out[67]: 2
``````

### 3D Image:

Three-dimensional pictures contain yet another dimension can be a color image. Information in 3-D coordinates can also be objects that have less than three spatial dimensions and in which the third coordinate describes another property, such as time, color or a color channel.

``````import numpy as np
c = np.array([[[1], [2]], [[3], [4]]])
c
c.shape
Out[70]: (2, 2, 1)
``````