当前位置:网站首页>skimage: imread & imsave & imshow

skimage: imread & imsave & imshow

2022-07-05 00:26:00 harry_ tea

install

scikit-image Official website :https://scikit-image.org/docs/dev/api/skimage.measure.html

install :pip install scikit-image

Read and write operations

Be careful cv2 The read and write types of are np.array、uint8、255、HWC、RGB

1. imread

io.imread(filename)

  • filename: The path to read the file
  • as_gray: If you read RGB chart , take RGB Turn into Gray, If it is Gray It does not change ,default=False

Load a picture
Loads an image from a file.

The return property is np.arrayuint8255HWCRBG

Code example

from skimage import io
img_color = io.imread('color.jpg')
# img_color2gray = io.imread('color.jpg', as_gray=True) 
img_gray  = cv2.imread('gray.jpg')

2. imsave

io.imwrite(filename, img)

  • filename: Path to store
  • im: Saved pictures

Save the picture to a specific path filename
Saves an image to a specified file.

Be similar to imread Mirror operation of , What type is read in , What type is it when saving np.arrayuint8255HWCRGB

Code example

from skimage import io
img1 = io.imread('color.jpg')
io.imwrite("color2.jpg", img1)

3. imshow

io.imshow(image)

  • image: Pictures shown

Show the picture to a specific window
Displays an image in the specified window.

image type np.arrayuint8255HWCRGB

It's also easy to use

from imageio import io
img1 = io.imread('color.jpg')
io.imshow("color", img1)
io.show()

原网站

版权声明
本文为[harry_ tea]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141125169983.html