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)
相关推荐
Blossom.1184 分钟前
基于多智能体强化学习的云资源调度系统:如何用MARL把ECS成本打下来60%
人工智能·python·学习·决策树·机器学习·stable diffusion·音视频
嵌入式小能手23 分钟前
飞凌嵌入式ElfBoard-文件I/O的深入学习之存储映射I/O
java·前端·学习
是一个Bug31 分钟前
源码学习方法论
学习
lx7416026981 小时前
change clip架构学习
人工智能·学习·计算机视觉
做一道光1 小时前
电机控制——电流采样(三电阻)
单片机·嵌入式硬件·学习·电机控制
JS_GGbond1 小时前
JavaScript入门学习路线图
开发语言·javascript·学习
失败才是人生常态1 小时前
算法题归类学习
学习·算法
Chunyyyen1 小时前
【第二十五周】大模型动手学习01
学习
d111111111d2 小时前
STM32外设学习-WDG看门狗-(学习笔记)
笔记·stm32·单片机·嵌入式硬件·学习
数据门徒2 小时前
《人工智能现代方法(第4版)》 第7章 逻辑智能体 学习笔记
人工智能·笔记·学习