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)
相关推荐
01二进制代码漫游日记20 分钟前
通讯录(一)
c语言·数据结构·学习
江苏世纪龙科技24 分钟前
让汽修课堂“动”起来—哈弗M6汽车故障诊断与排除仿真教学软件
学习
小陈phd44 分钟前
多模态大模型学习笔记(二十三)——一文搞懂数虚拟人:从定义、分类到核心技术全景
笔记·学习
糖果店的幽灵1 小时前
【大模型】大模型学习总结之机器学习-3.模型评估
人工智能·学习·机器学习
Edward111111111 小时前
3月23Math类,Arrays类
java·学习
码农4271 小时前
点评项目深入改造-------日常学习笔记
java·笔记·学习·搜索引擎·全文检索
云边散步2 小时前
godot2D游戏教程系列二(19)
笔记·学习·游戏·游戏开发
我的xiaodoujiao2 小时前
4、API 接口自动化测试详细图文教程学习系列4--相关Python基础知识3
python·学习·测试工具·pytest
学机械的鱼鱼2 小时前
【学习笔记】如何快速理解ROS2
笔记·学习
red_redemption2 小时前
自由学习记录(145)
学习