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)
相关推荐
今天你TLE了吗2 小时前
Stream流学习总结
java·学习
周全全6 小时前
基于ElasticSearch的语义检索学习-向量化数据、向量化相似度、向量化检索
大数据·学习·elasticsearch
4***72136 小时前
网络爬虫学习:借助DeepSeek完善爬虫软件,实现模拟鼠标右键点击,将链接另存为本地文件
爬虫·学习·计算机外设
t***31656 小时前
爬虫学习案例3
爬虫·python·学习
hhcccchh6 小时前
学习vue第七天 从单页面应用(SPA)进化为后台管理系统架构
vue.js·学习·系统架构
文涛是个小白呀7 小时前
Java集合大调研
java·学习·链表·面试
hd51cc7 小时前
MFC多线程学习笔记三:线程间的通信
笔记·学习
hd51cc7 小时前
MFC多线程学习笔记四:线程间的同步
笔记·学习·mfc
wdfk_prog7 小时前
[Linux]学习笔记系列 -- [block]bfq-iosched
linux·笔记·学习
embrace998 小时前
【C语言学习】结构体详解
android·c语言·开发语言·数据结构·学习·算法·青少年编程