6626070
2997924

AAI01, Basic image processing

Back to the previous pagepage managementpaper reviewto NLP
List of posts to read before reading this article


Contents


Building 2d-image with numpy

dtype = np.uint8

import numpy as np
from skimage import io

image = np.array([[255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255]], dtype=np.uint8)

print('dtype : ', image.dtype)
print('shape : ', image.shape)
io.imshow(image)
OUTPUT

dtype : uint8
shape : (12, 16)
<matplotlib.image.AxesImage at 0x260c1d7d630>

다운로드 (8)






dtype = np.int8

import numpy as np
from skimage import io

image = np.array([[255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255]], dtype=np.int8)

print('dtype : ', image.dtype)
print('shape : ', image.shape)
io.imshow(image)
OUTPUT

dtype : int8
shape : (12, 16)
<matplotlib.image.AxesImage at 0x260c1ddf208>

다운로드 (9)






dtype = np.uint16

import numpy as np
from skimage import io

image = np.array([[255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255],
                  [255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0],
                  [0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255]], dtype=np.uint16)

print('dtype : ', image.dtype)
print('shape : ', image.shape)
io.imshow(image)
OUTPUT

dtype : uint16
shape : (12, 16)
<matplotlib.image.AxesImage at 0x260c1e96208>

다운로드 (10)






Building 3d-image with numpy

dtype = np.uint8

import numpy as np
from skimage import io

image = np.array([[[255,0,0],[0,255,0],[0,0,255]],
                  [[0,0,0],[128,128,128],[255,255,255]]], dtype=np.uint8)

print('dtype : ', image.dtype)
print('shape : ', image.shape)
io.imshow(image)
OUTPUT

dtype : uint8
shape : (2, 3, 3)
<matplotlib.image.AxesImage at 0x260c4e91208>

다운로드 (12)



import numpy as np
from skimage import io

image = np.array([[[-1,256,256],[256,-1,256],[256,256,-1]],
                  [[0,0,0],[-128,-128,-128],[-1,-1,-1]]], dtype=np.uint8)

print('dtype : ', image.dtype)
print('shape : ', image.shape)
io.imshow(image)
OUTPUT

dtype : uint8
shape : (2, 3, 3)
<matplotlib.image.AxesImage at 0x260c516d588>

다운로드






dtype = np.int8

import numpy as np
from skimage import io

image = np.array([[[255,0,0],[0,255,0],[0,0,255]],
                  [[0,0,0],[128,128,128],[255,255,255]]], dtype=np.int8)

print('dtype : ', image.dtype)
print('shape : ', image.shape)
io.imshow(image)
OUTPUT

dtype : int8
shape : (2, 3, 3)
<matplotlib.image.AxesImage at 0x260c51ca898>

다운로드 (1)






dtype = np.uint16

import numpy as np
from skimage import io

image = np.array([[[255,0,0],[0,255,0],[0,0,255]],
                  [[0,0,0],[128,128,128],[255,255,255]]], dtype=np.uint16)

print('dtype : ', image.dtype)
print('shape : ', image.shape)
io.imshow(image)
OUTPUT

dtype : uint16
shape : (2, 3, 3)
<matplotlib.image.AxesImage at 0x260c5282358>

다운로드 (2)






List of posts followed by this article


Reference