skimage rescale学习

example1

bash 复制代码
import numpy as np
from skimage import data
from skimage.transform import rescale
import matplotlib.pyplot as plt

# Load a sample image
image = data.chelsea()
 
# Notice that you shouldn't use the multichannel parameter
# Rescale the image to 50% of its original size
image_rescaled = rescale(image, 0.5, anti_aliasing=True, channel_axis=2)

# Display the original and rescaled images
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(10, 5))

ax1.imshow(image)
ax1.set_title('Original image')

ax2.imshow(image_rescaled)
ax2.set_title('Rescaled image (50%)')

plt.tight_layout()
plt.show()

example2

bash 复制代码
import numpy as np
from skimage import data, img_as_ubyte
from skimage.transform import rescale
import matplotlib.pyplot as plt

# Load a sample image
image = data.chelsea()

# Rescale the image to 50% of its original size
image_rescaled_float = rescale(image, 0.5, anti_aliasing=True, channel_axis=2)

# Convert the rescaled image to 8-bit unsigned integer
image_rescaled = img_as_ubyte(image_rescaled_float)

# Display the original and rescaled images
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(10, 5))

ax1.imshow(image)
ax1.set_title('Original image')

ax2.imshow(image_rescaled)
ax2.set_title('Rescaled image (50%)')

plt.tight_layout()
plt.show()

# Print the data types to verify
print("Original image dtype:", image.dtype)
print("Rescaled image dtype:", image_rescaled.dtype)
相关推荐
cwtlw9 小时前
PhotoShop学习01
笔记·学习·ui·photoshop
Bluesonli9 小时前
第 22 天:多线程开发,提高 UE5 性能!
学习·游戏·ue5·虚幻引擎·unreal engine
虾球xz9 小时前
游戏引擎学习第124天
java·学习·游戏引擎
远离UE49 小时前
UE5 Computer Shader学习笔记
笔记·学习·ue5
一小路一10 小时前
从0-1学习Mysql第五章: 索引与优化
数据库·后端·学习·mysql·面试
IT、木易12 小时前
大白话css第二章深入学习
前端·css·学习
fanged12 小时前
CMake小结2(PICO为例)
学习·嵌入式
笨鸟先飞的橘猫14 小时前
lua学习(一)
开发语言·学习·lua
zhulu50614 小时前
PyTorch 源码学习:GPU 内存管理之它山之石——TensorFlow BFC 算法
学习·tensorflow
白云千载尽15 小时前
大语言加持的闭环端到端自动驾驶模型 学习笔记纯干货
论文阅读·笔记·学习·自动驾驶·carla·vlm