Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).

eg1 :  float 超出 0-1范围

import numpy as np
import matplotlib.pyplot as plt
import torch as t
import cv2
# image1=cv2.imread(r"..\..\..\数据集和预训练模型\datasets\datasets\train\cat\cat.0.jpg")
image1=cv2.imdecode(np.fromfile(r"..\..\..\数据集和预训练模型\datasets\datasets\train\cat\cat.0.jpg",dtype=np.uint8),-1)
print(image1.shape)
image1=t.tensor(image1,dtype=t.float32).permute(2,0,1).permute(1,2,0)
print(image1[:,:,2])
image1=np.array(image1)
b,g,r=cv2.split(image1)
image1=cv2.merge([r,g,b])
print(image1[:,:,0])
plt.imshow(image1)
plt.show()

D:\Anaconda\envs\deep_learning\python.exe E:/classification-pytorch-main/classification-pytorch-main/utils/dataloader.py
(374, 500, 3)
tensor([[203., 203., 204.,  ..., 240., 239., 238.],[203., 203., 204.,  ..., 241., 240., 238.],[203., 203., 204.,  ..., 241., 240., 239.],...,[153., 153., 153.,  ...,   2.,   2.,   2.],[152., 152., 152.,  ...,   2.,   2.,   2.],[151., 151., 151.,  ...,   1.,   1.,   1.]])
[[203. 203. 204. ... 240. 239. 238.][203. 203. 204. ... 241. 240. 238.][203. 203. 204. ... 241. 240. 239.]...[153. 153. 153. ...   2.   2.   2.][152. 152. 152. ...   2.   2.   2.][151. 151. 151. ...   1.   1.   1.]]
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).

eg2: float 回到0-1范围

import numpy as np
import matplotlib.pyplot as plt
import torch as t
import cv2
# image1=cv2.imread(r"..\..\..\数据集和预训练模型\datasets\datasets\train\cat\cat.0.jpg")
image1=cv2.imdecode(np.fromfile(r"..\..\..\数据集和预训练模型\datasets\datasets\train\cat\cat.0.jpg",dtype=np.uint8),-1)
print(image1.shape)
image1=t.tensor(image1,dtype=t.float32).permute(2,0,1).permute(1,2,0)
print(image1[:,:,2])
image1=np.array(image1)
b,g,r=cv2.split(image1)
image1=cv2.merge([r,g,b])/255
print(image1[:,:,0])
plt.imshow(image1)
plt.show()
D:\Anaconda\envs\deep_learning\python.exe E:/transformer_1/classification-pytorch-main/classification-pytorch-main/utils/dataloader.py
(374, 500, 3)
tensor([[203., 203., 204.,  ..., 240., 239., 238.],[203., 203., 204.,  ..., 241., 240., 238.],[203., 203., 204.,  ..., 241., 240., 239.],...,[153., 153., 153.,  ...,   2.,   2.,   2.],[152., 152., 152.,  ...,   2.,   2.,   2.],[151., 151., 151.,  ...,   1.,   1.,   1.]])
[[0.79607844 0.79607844 0.8        ... 0.9411765  0.9372549  0.93333334][0.79607844 0.79607844 0.8        ... 0.94509804 0.9411765  0.93333334][0.79607844 0.79607844 0.8        ... 0.94509804 0.9411765  0.9372549 ]...[0.6        0.6        0.6        ... 0.00784314 0.00784314 0.00784314][0.59607846 0.59607846 0.59607846 ... 0.00784314 0.00784314 0.00784314][0.5921569  0.5921569  0.5921569  ... 0.00392157 0.00392157 0.00392157]]

eg3: int 保持在 0-255

import numpy as np
import matplotlib.pyplot as plt
import torch as t
import cv2
# image1=cv2.imread(r"..\..\..\数据集和预训练模型\datasets\datasets\train\cat\cat.0.jpg")
image1=cv2.imdecode(np.fromfile(r"..\..\..\数据集和预训练模型\datasets\datasets\train\cat\cat.0.jpg",dtype=np.uint8),-1)
print(image1.shape)
image1=t.tensor(image1,dtype=t.int32).permute(2,0,1).permute(1,2,0)
print(image1[:,:,2])
image1=np.array(image1)
b,g,r=cv2.split(image1)
image1=cv2.merge([r,g,b])
print(image1[:,:,0])
plt.imshow(image1)
plt.show()
D:\Anaconda\envs\deep_learning\python.exe E:/transformer_1/classification-pytorch-main/classification-pytorch-main/utils/dataloader.py
(374, 500, 3)
tensor([[203, 203, 204,  ..., 240, 239, 238],[203, 203, 204,  ..., 241, 240, 238],[203, 203, 204,  ..., 241, 240, 239],...,[153, 153, 153,  ...,   2,   2,   2],[152, 152, 152,  ...,   2,   2,   2],[151, 151, 151,  ...,   1,   1,   1]], dtype=torch.int32)
[[203 203 204 ... 240 239 238][203 203 204 ... 241 240 238][203 203 204 ... 241 240 239]...[153 153 153 ...   2   2   2][152 152 152 ...   2   2   2][151 151 151 ...   1   1   1]]

eg4:  int 转化为 0-1 float

import numpy as np
import matplotlib.pyplot as plt
import torch as t
import cv2
# image1=cv2.imread(r"..\..\..\数据集和预训练模型\datasets\datasets\train\cat\cat.0.jpg")
image1=cv2.imdecode(np.fromfile(r"..\..\..\数据集和预训练模型\datasets\datasets\train\cat\cat.0.jpg",dtype=np.uint8),-1)
print(image1.shape)
image1=t.tensor(image1,dtype=t.int32).permute(2,0,1).permute(1,2,0)
print(image1[:,:,2])
image1=np.array(image1)
b,g,r=cv2.split(image1)
image1=cv2.merge([r,g,b])/255
print(image1[:,:,0])
plt.imshow(image1)
plt.show()
D:\Anaconda\envs\deep_learning\python.exe E:/transformer_1/classification-pytorch-main/classification-pytorch-main/utils/dataloader.py
(374, 500, 3)
tensor([[203, 203, 204,  ..., 240, 239, 238],[203, 203, 204,  ..., 241, 240, 238],[203, 203, 204,  ..., 241, 240, 239],...,[153, 153, 153,  ...,   2,   2,   2],[152, 152, 152,  ...,   2,   2,   2],[151, 151, 151,  ...,   1,   1,   1]], dtype=torch.int32)
[[0.79607843 0.79607843 0.8        ... 0.94117647 0.9372549  0.93333333][0.79607843 0.79607843 0.8        ... 0.94509804 0.94117647 0.93333333][0.79607843 0.79607843 0.8        ... 0.94509804 0.94117647 0.9372549 ]...[0.6        0.6        0.6        ... 0.00784314 0.00784314 0.00784314][0.59607843 0.59607843 0.59607843 ... 0.00784314 0.00784314 0.00784314][0.59215686 0.59215686 0.59215686 ... 0.00392157 0.00392157 0.00392157]]

【笔记】input data to the valid range for imshow with RGB data [0..1] for floats or [0.255] for integers相关推荐

  1. Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for i

    keras  imshow显示图片显示不出来,报错 Clipping input data to the valid range for imshow with RGB data ([0..1] fo ...

  2. python Clipping input data to the valid range for imshow with RGB data解决方法

    文章目录 遇到的问题 全部代码 参考 遇到的问题 第一点,遇到的问题是 Clipping input data to the valid range for imshow with RGB data ...

  3. 解决:Clipping input data to the valid range for imshow with RGB data

    Clipping input data to the valid range for imshow with RGB data 今天在提取彩色图像RGB通道值合成单通道图像时,出现问题: Clippi ...

  4. Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255]解决方法

    Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] ❓报错原因 ...

  5. 错误解决:Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255]

    今天又是快乐改错误的经历: 在做k-means进行图片压缩的实战项目中,我遇到了这样一个pyplot显示图像报错问题:Clipping input data to the valid range fo ...

  6. 解决matplotlib无法imshow/imsave真彩色图像或提示Clipping input data to the valid range for imshow with RGB data (

    问题描述及解决方案 问题描述 解决matplotlib无法imshow/imsave真彩色图像或提示Clipping input data to the valid range for imshow ...

  7. Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255]

  8. Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] ...

    警告的位置在matplotlib.image中: 从源码可知如果图像(np.array)数值范围小于0或者大于1(或255),则会用np.clip将其截断

  9. 应用matplotlib的imshow函数显示彩色图像(RGB data)报错的解决方法

    何时出现错误提示 :"Clipping input data to the valid range for imshow with RGB data ([0..1] for floats o ...

最新文章

  1. Spring Cloud Gateway(限流)
  2. 10个典型实用的PHP代码片段
  3. http://udacity.com 和 https://www.udemy.com 请注意区分!
  4. centos7安装docker并配置阿里云镜像
  5. android 9格式吗,Android Studio中关于9-patch格式图片的编译错误
  6. 最长不重复子串python_python经典算法题:无重复字符的最长子串
  7. 建立和使用Maven项目骨架Archetype
  8. mysql排序自段为字符串类型问题解决
  9. G++和C++区别和评测注意事项
  10. 51单片机读引脚和读端口测试总结
  11. 云服务器搭网站需要买域名吗,买了云服务器还要买域名吗
  12. mysql 主从1236_mysql主从复制1236错误
  13. 解决 手机能连接上wifi而电脑却却不能连接上wifi的情况
  14. 一文详解AndroidX,再也不会傻傻分不清了
  15. 哈工大计算机考研854会改成408吗?哈工大854性价比如何?怎么复习?
  16. MFC在两控件间画线
  17. Impossible n‘est pas français (Exploit) 答案
  18. php riak,PHP-Riak:快速获取多个项目
  19. JavaSE 第三章 流程控制语句方法定义 笔记
  20. idea ctrl+alt+向左箭头不能用

热门文章

  1. 洁静,澳大利亚,昨天下午
  2. 20180629小测
  3. linux+4t分区+扩容lvm,Linux中利用LVM实现分区动态扩容
  4. 制作抖音超火的罗盘时钟(HTML+CSS+JS)
  5. Unity CustomFont (怎么制作图片文字)
  6. 处理iphone 微信中.play()方法不能播放的问题
  7. 下载的问题,attachment什么意思??
  8. 反思“百果园们”:谁在侵蚀行业生态地基?
  9. VSCODE 使用One Dark Pro并优化
  10. 所有程序中的java在哪里设置密码_关于安全性:如何在桌面客户端应用程序(Java)中存储密码和敏感数据?...