├── .nojekyll ├── _sidebar.md ├── INTRODUCTION.md ├── 图形学基础 ├── README.md ├── 信号与噪声.md └── 图像滤波.md ├── 20~3D CV ├── 3D 模型检索 │ ├── 3D 模型检索.md │ └── SIS │ │ └── SIS.md ├── 3D 模型识别 │ └── 99~参考资料 │ │ ├── README.md │ │ ├── 2022~3D Object Recognition Using Fast Overlapped Block Processing Technique.pdf │ │ └── 2022~Deep Neural Network for 3D Shape Classification Based on Mesh Feature.pdf └── 3D AIGC │ ├── Shap-E │ └── 99~参考资料 │ │ └── 2023-Shap·E- Generating Conditional 3D Implicit Functions.pdf │ └── Point-E │ └── 99~参考资料 │ └── 2023-模型方法---创作能力很一般的 3D 模型 Point-E.md ├── 卷积神经网络 └── README.md ├── 目标检测 └── README.md ├── 扩散模型 ├── Diffusion Models │ ├── 99~参考资料 │ │ └── 2024~Diffusion Models.md │ └── README.md └── 99~参考资料 │ └── 2022-The Illustrated Stable Diffusion.md ├── README.md ├── .gitignore ├── scikit-image ├── README.md ├── 基础读写.md ├── 像素处理.md └── 绘制与转化.md ├── index.html ├── header.svg └── LICENSE /.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_sidebar.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /INTRODUCTION.md: -------------------------------------------------------------------------------- 1 | # 本篇导读 2 | -------------------------------------------------------------------------------- /图形学基础/README.md: -------------------------------------------------------------------------------- 1 | # 图形学基础 2 | -------------------------------------------------------------------------------- /20~3D CV/3D 模型检索/3D 模型检索.md: -------------------------------------------------------------------------------- 1 | # 3D 模型检索 2 | -------------------------------------------------------------------------------- /20~3D CV/3D 模型识别/99~参考资料/README.md: -------------------------------------------------------------------------------- 1 | # 3D 模型识别参考资料 2 | -------------------------------------------------------------------------------- /卷积神经网络/README.md: -------------------------------------------------------------------------------- 1 | # 卷积神经网络 2 | 3 | # Links 4 | 5 | - https://mp.weixin.qq.com/s/F8Yaux8nDNeZ_zavXn3FKA 6 | -------------------------------------------------------------------------------- /目标检测/README.md: -------------------------------------------------------------------------------- 1 | # 目标检测 2 | 3 | # Links 4 | 5 | - https://mp.weixin.qq.com/s/V7kwjJbmnsmpMhZxHBC-BA 目标检测入门学习笔记 6 | -------------------------------------------------------------------------------- /扩散模型/Diffusion Models/99~参考资料/2024~Diffusion Models.md: -------------------------------------------------------------------------------- 1 | > [原文地址](https://andrewkchan.dev/posts/diffusion.html#section-2.4) 2 | 3 | # Diffusion Models 4 | -------------------------------------------------------------------------------- /扩散模型/99~参考资料/2022-The Illustrated Stable Diffusion.md: -------------------------------------------------------------------------------- 1 | > [原文地址](https://blog.csdn.net/yujianmin1990/article/details/129143157) 2 | 3 | # The Illustrated Stable Diffusion 4 | -------------------------------------------------------------------------------- /20~3D CV/3D AIGC/Shap-E/99~参考资料/2023-Shap·E- Generating Conditional 3D Implicit Functions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/CV-Notes/master/20~3D CV/3D AIGC/Shap-E/99~参考资料/2023-Shap·E- Generating Conditional 3D Implicit Functions.pdf -------------------------------------------------------------------------------- /20~3D CV/3D 模型识别/99~参考资料/2022~3D Object Recognition Using Fast Overlapped Block Processing Technique.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/CV-Notes/master/20~3D CV/3D 模型识别/99~参考资料/2022~3D Object Recognition Using Fast Overlapped Block Processing Technique.pdf -------------------------------------------------------------------------------- /20~3D CV/3D 模型识别/99~参考资料/2022~Deep Neural Network for 3D Shape Classification Based on Mesh Feature.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wx-chevalier/CV-Notes/master/20~3D CV/3D 模型识别/99~参考资料/2022~Deep Neural Network for 3D Shape Classification Based on Mesh Feature.pdf -------------------------------------------------------------------------------- /20~3D CV/3D AIGC/Point-E/99~参考资料/2023-模型方法---创作能力很一般的 3D 模型 Point-E.md: -------------------------------------------------------------------------------- 1 | > [原文地址](https://zhuanlan.zhihu.com/p/593608930) 2 | 3 | # 模型方法---创作能力很一般的 3D 模型 Point-E 4 | 5 | OpenAI 在最近又开源了一个新模型,通过图像或者文字生成 3D 云图的代码。OpenAI 今年的 Dall-E2 和 ChatGPT 已经很抢眼了。虽然第一版本的 Point-E 效果差强人意吧,但还算是开源模型,本地能玩就比之前那几个注册海外手机号省事很多。 6 | -------------------------------------------------------------------------------- /20~3D CV/3D 模型检索/SIS/SIS.md: -------------------------------------------------------------------------------- 1 | # SIS 2 | 3 | # Links 4 | 5 | - https://github.com/matsui528/sis 6 | - https://github.com/DennisLiu1993/Fastest_Image_Pattern_Matching 7 | - https://github.com/KilianB/JImageHash 8 | - https://github.com/zddhub/opensse 9 | - https://github.com/thekevinscott/ml-classifier-ui 10 | -------------------------------------------------------------------------------- /扩散模型/Diffusion Models/README.md: -------------------------------------------------------------------------------- 1 | # Diffusion 模型 2 | 3 | # Links 4 | 5 | - https://nakaizura.blog.csdn.net/article/details/126576756?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-3-126576756-blog-126716370.pc_relevant_3mothn_strategy_and_data_recovery&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-3-126576756-blog-126716370.pc_relevant_3mothn_strategy_and_data_recovery&utm_relevant_index=4 6 | 7 | - https://blog.csdn.net/qq_38406029/article/details/125526604 8 | -------------------------------------------------------------------------------- /图形学基础/信号与噪声.md: -------------------------------------------------------------------------------- 1 | # 信号与噪声 2 | 3 | 信号与噪声是一对敌人,图像的空间是有限的,信号多一点,噪声就少一点,反之亦然。我们在打电话中如果觉得杂音特别多,那么也就是此时通话数据中的噪声特别多,已经达到了影响正常通话的程度。甚至噪声特别大的时候,信号容易淹没在噪声中。图像也是一种数据,图像中也存在信号和噪声。 4 | 5 | # 信号 6 | 7 | 信号是我们想要的数据。信号越多,噪声的干扰便会越少,数据的质量也就越高。我们可以使用信噪比这个概念来衡量数据质量的高低。所谓信噪比就是指信号与噪声二者能量之比值。直观来讲,噪声越少,信噪比越大,数据的质量越佳。 8 | 9 | ![受到噪声干扰的图像与未经噪声干扰的图像](https://ngte-superbed.oss-cn-beijing.aliyuncs.com/item/20230418154534.png) 10 | 11 | # 噪声 12 | 13 | 经过噪声干扰的图像令我们难以获取图片所要表达的原始信息,使得图像所表达信息的确定程度减少,也就是所谓的信息熵增大。而在实际生活中,通过图像采集设备获取到的图片也或多或少会引入噪声,这主要是由摄像机等图像采集设备的感光元件受到干扰产生的噪声表现在图像上而形成的,主要表现为黑白杂点等。 14 | 15 | 图像中随机出现的黑白杂点称为椒盐噪声,“椒”代表黑色,“盐”代表白色,故而用椒盐噪声这个概念来表示图像中存在的黑白杂点,其在图片中出现的位置是随机的。而图像中也可能会随机出现某些颜色的改变。造成此类杂点最典型的就是高斯噪声,这是由于在原图片的基础上叠加了高斯噪声而造成的。 16 | 17 | 所谓高斯噪声是指图像叠加的噪声概率密度服从高斯分布,也就是正态分布。这是自然界中最为常见的一种噪声类别,例如夜晚通过照相机拍照获得的照片就可能存在该类噪声。 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 计算机视觉 2 | 3 | 计算机视觉的主要目标是教会计算机如何去获取图片信息中的知识,例如人脸识别就是让计算机去自动获取与识别人脸图像中的知识,这个“知识”的范畴可以是“两张图片中的人脸是否来自于同一个人”,也可以是“图片中的人脸是男人还是女人”。 4 | 5 | 维基百科上对计算机视觉的定义如下:计算机视觉是一个跨学科领域,涉及如何使用计算机获取数字图像与视频中的高层次理解。从工程角度来看,它的目标是寻找一种能够与人类视觉系统实现相同功能的自动化任务。这段话表明了计算机视觉的跨学科特点,它与人工智能、固态物理学、神经生物学、信号处理等产生诸多关联。传统的计算机视觉的处理方法多是采用信号处理方法,而机器学习技术浪潮的兴起,为计算机视觉打开了一扇新的大门。 6 | 7 | 当然,计算机视觉的数据输入源最简单和常见的就是摄像头了。但是,计算机视觉技术对于非摄像头的数据输入源也能提供很好的支持。这段话表明了计算机视觉的跨学科特点,它与人工智能、固态物理学、神经生物学、信号处理等产生诸多关联。从这个角度说,计算机视觉的技术辐射度和应用范围是非常广泛的,计算机视觉技术能够使我们的生活更加多姿多彩,为创造更美好的世界提供了一个强大的工具。 8 | 9 | 众所周知,自从 2012 年的 Alexnet 横空出世夺取当年的 ImageNet 的 svRC 挑战赛的冠军后,将这项比赛的准确率逐年提升从不到 75%近期已经达到 98%甚至 99%以上的结果,这就意昧着基于深度学习的图像分类能力已经远远超出人类肉眼的分辨能力。当前 cν 领域的深度学习主要包括两个大的方向,"低层次的感知″和“高层次的认知"。主要的应用领域包括视频监控、人脸识别、医学图像分析、自动驾驶、机器人、AR、ⅤR;主要的技术方向包括图像分类、目标检测、分割、目标追踪、边缘检测、姿势评估、理解 CNN、超分辨率璽建、序列学习、特征检测与匹配、图像标定,视频标定、问答系统、图片生成、视觉关注性和显著性、人脸识别、3D 重建、推荐系统、细粒度图像分析、图像压缩。 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore all 2 | * 3 | 4 | # Unignore all with extensions 5 | !*.* 6 | 7 | # Unignore all dirs 8 | !*/ 9 | 10 | .DS_Store 11 | 12 | # Logs 13 | logs 14 | *.log 15 | npm-debug.log* 16 | yarn-debug.log* 17 | yarn-error.log* 18 | 19 | # Runtime data 20 | pids 21 | *.pid 22 | *.seed 23 | *.pid.lock 24 | 25 | # Directory for instrumented libs generated by jscoverage/JSCover 26 | lib-cov 27 | 28 | # Coverage directory used by tools like istanbul 29 | coverage 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | 50 | # TypeScript v1 declaration files 51 | typings/ 52 | 53 | # Optional npm cache directory 54 | .npm 55 | 56 | # Optional eslint cache 57 | .eslintcache 58 | 59 | # Optional REPL history 60 | .node_repl_history 61 | 62 | # Output of 'npm pack' 63 | *.tgz 64 | 65 | # Yarn Integrity file 66 | .yarn-integrity 67 | 68 | # dotenv environment variables file 69 | .env 70 | 71 | # next.js build output 72 | .next 73 | -------------------------------------------------------------------------------- /图形学基础/图像滤波.md: -------------------------------------------------------------------------------- 1 | # 图像滤波 2 | 3 | 噪声是我们不想要的一类数据。但是在实际操作中往往会引入噪声,例如图片经过低质量的信道传输,引入了信道中存在的噪声;图像采集设备由于某些电子学原因而引入了噪声等。 4 | 5 | 噪声的存在必然会对我们正常的图像处理造成干扰,尽可能多地滤除噪声是我们进行图像预处理的一个重要步骤。 6 | 7 | # 均值滤波 8 | 9 | 这里提到的均值滤波器更确切地说是算数均值滤波器,这是最简单的一种图像滤波方法,可以滤除均匀噪声和高斯噪声,但是会对图像造成一定程度的模糊。它是将图片中指定区域内的像素点进行平均滤波的方法。这个过程与前面我们所说的卷积的计算过程是类似的。 10 | 11 | ![](https://ngte-superbed.oss-cn-beijing.aliyuncs.com/item/007rAy9hgy1g3rmmujedyj30cw04gglm.jpg) 12 | 13 | 对左图中左上角的 9 个点进行均值滤波,得到右图中左上角 9 个点的中心值 3 的计算过程为: 14 | 15 | ``` 16 | 1/9(1+2+1+1+2+2+5+7+6)=3 17 | ``` 18 | 19 | 均值滤波器的缺点是会使图像变得模糊,这是因为它将所有的点都进行了均值处理。而实际上,在绝大多数情况下,噪声的占比是少数,将所有的点都以同样的权值进行处理,势必会导致图像的模糊。而且,这个滤波器的宽度越大,滤波后的图片就会越模糊,也就是丢失图像的细节部分,使图像变得更加“中庸”。当然,根据这个特点,也可以将这个滤波器的权值更改一下,以便达到有所侧重的效果。 20 | 21 | 例如,在对图片进行滤波操作时,不应该全部按照系数为 1 进行加权求和,从而进行滤波。我们知道,图像的像素是连续的,距离越近的像素点间的联系越大,那么,滤波器的参数越靠近中心位置的权值越大,越靠近边缘位置的权值越小。 22 | 23 | 一种可行的实现方法便是将这个滤波器的参数按照高斯分布形式进行修改,那么这个滤波器就称为高斯滤波器。如下图所示是二维高斯分布曲面图及其投影,我们选择的滤波器权值就是高斯曲面的投影。 24 | 25 | ![](https://ngte-superbed.oss-cn-beijing.aliyuncs.com/item/007rAy9hgy1g3rmmujedyj30cw04gglm.jpg) 26 | 27 | # 中值滤波 28 | 29 | 我们在上面介绍了均值滤波,使用均值滤波会造成图片的模糊,即使修改均值滤波的权值,也还是会造成图片的模糊。因此,我们既要对图片进行滤波处理,又要尽量减少图片的模糊程度,那么就要考虑另外一种思路来实现滤波过程。 30 | 31 | 中值滤波是一种与均值滤波过程不同的滤波方法。相比于均值滤波,中值滤波可以有效减少图片的模糊程度。中值滤波的原理如下:与均值滤波的原理大体相似,同样使用一个指定大小的滑动窗口,在图片上进行滑动,不断地进行滤波处理。不过,与均值滤波的不同在于,中值滤波在对像素点进行处理时,并不是采取简单的取平均数的做法,而是改为取其中位数的做法。 32 | 33 | 以椒盐噪声为例,其像素的灰度值要么是最低的,要么是最高的,总是处于两个极端。而图像中绝大多数正常点处于这样一个区间之中,因此,将滤波器所选取区域中的像素点,以其灰度值的大小进行排序,如果存在噪声,则基本处于两端的位置。 34 | 35 | 此时,这组数据的中位数在绝大多数情况下都是图像中正常的信息而不是噪声,这样就可以实现滤波过程。 36 | 37 | 对于椒盐噪声来讲,中值滤波的效果要好于均值滤波。而对于高斯噪声来讲,均值滤波的效果优于中值滤波,这是因为,高斯噪声的特点是噪声颜色值不固定,基本符合高斯随机分布的特点,这样就会导致中值滤波无法按照默认的噪声范围进行滤波,其效果自然就没有均值滤波好。 38 | -------------------------------------------------------------------------------- /scikit-image/README.md: -------------------------------------------------------------------------------- 1 | # skimage 2 | 3 | 基于 Python 脚本语言开发的数字图片处理包,比如 PIL, Pillow, opencv, scikit-image 等。 4 | PIL 和 Pillow 只提供最基础的数字图像处理,功能有限;opencv 实际上是一个 c++库,只是提供了 python 接口,更新速度非常慢。scikit-image 是基于 scipy 的一款图像处理包,它将图片作为 numpy 数组进行处理,正好与 matlab 一样,因此,我们最终选择 scikit-image 进行数字图像处理。 5 | 6 | skimage 包的全称是 scikit-image SciKit (toolkit for SciPy),它对 scipy.ndimage 进行了扩展,提供了更多的图片处理功能。它是由 python 语言编写的,由 scipy 社区开发和维护。skimage 包由许多的子模块组成,各个子模块提供不同的功能。主要子模块列表如下: 7 | 8 | ```s 9 | 子模块名称  主要实现功能 10 | io 读取、保存和显示图片或视频 11 | data 提供一些测试图片和样本数据 12 | color 颜色空间变换 13 | filters 图像增强、边缘检测、排序滤波器、自动阈值等 14 | draw 操作于numpy数组上的基本图形绘制,包括线条、矩形、圆和文本等 15 | transform 几何变换或其它变换,如旋转、拉伸和拉东变换等 16 | morphology 形态学操作,如开闭运算、骨架提取等 17 | exposure 图片强度调整,如亮度调整、直方图均衡等 18 | feature 特征检测与提取等 19 | measure 图像属性的测量,如相似性或等高线等 20 | segmentation 图像分割 21 | restoration 图像恢复 22 | util 通用函数 23 | ``` 24 | 25 | ## PIL vs skimage 26 | 27 | Image 读出来的是 PIL 的类型,而 skimage.io 读出来的数据是 numpy 格式的: 28 | 29 | ```py 30 | import Image as img 31 | import os 32 | from matplotlib import pyplot as plot 33 | from skimage import io,transform 34 | #Image和skimage读图片 35 | img_file1 = img.open('./CXR_png/MCUCXR_0042_0.png') 36 | img_file2 = io.imread('./CXR_png/MCUCXR_0042_0.png') 37 | ``` 38 | 39 | 输出可以看出 Img 读图片的大小是图片的(width, height);而 skimage 的是(height,width, channel)。 40 | 41 | ```py 42 | #读图片后数据的大小: 43 | print "the picture's size: ", img_file1.size 44 | print "the picture's shape: ", img_file2.shape 45 | 46 | the picture's size: (4892, 4020) 47 | the picture's shape: (4020, 4892) 48 | 49 | #得到像素: 50 | print(img_file1.getpixel((500,1000)), img_file2[500][1000]) 51 | print(img_file1.getpixel((500,1000)), img_file2[1000][500]) 52 | print(img_file1.getpixel((1000,500)), img_file2[500][1000]) 53 | (0, 139) 54 | (0, 0) 55 | (139, 139) 56 | ``` 57 | 58 | Img 读出来的图片获得某点像素用 getpixel((w,h))可以直接返回这个点三个通道的像素值 59 | skimage 读出来的图片可以直接 img_file2[0][0]获得,但是一定记住它的格式,并不是你想的(channel,height,width)。 60 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CGDataVis Series 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 32 | 35 | 37 | 42 | 43 |
44 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 89 | 90 | 91 | 92 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /scikit-image/基础读写.md: -------------------------------------------------------------------------------- 1 | # 基础读写 2 | 3 | # 图片读取 4 | 5 | 读取单张彩色 rgb 图片,使用 `skimage.io.imread(fname)` 函数,带一个参数,表示需要读取的文件路径。显示图片使用 `skimage.io.imshow(arr)` 函数,带一个参数,表示需要显示的 arr 数组(读取的图片以 numpy 数组形式计算)。 6 | 7 | ```py 8 | from skimage import io 9 | img=io.imread('d:/dog.jpg') 10 | io.imshow(img) 11 | ``` 12 | 13 | 读取单张灰度图片,使用 `skimage.io.imread(fname,as_grey=True)` 函数,第一个参数为图片路径,第二个参数为 as_grey, bool 型值,默认为 False。 14 | 15 | ```py 16 | from skimage import io 17 | img=io.imread('d:/dog.jpg',as_grey=True) 18 | io.imshow(img) 19 | ``` 20 | 21 | ## 内置图片 22 | 23 | skimage 程序自带了一些示例图片,如果我们不想从外部读取图片,就可以直接使用这些示例图片: 24 | 25 | ```s 26 | astronaut 航员图片 coffee 一杯咖啡图片 27 | lena lena美女图片 camera 拿相机的人图片 28 | coins 硬币图片 moon 月亮图片 29 | checkerboard 棋盘图片 horse 马图片 30 | page 书页图片 chelsea 小猫图片 31 | hubble_deep_field 星空图片 text 文字图片 32 | clock 时钟图片 immunohistochemistry 结肠图片 33 | ``` 34 | 35 | 显示这些图片可用如下代码,不带任何参数: 36 | 37 | ```py 38 | from skimage import io, data 39 | img=data.lena() 40 | io.imshow(img) 41 | ``` 42 | 43 | 图片名对应的就是函数名,如 camera 图片对应的函数名为 camera(). 这些示例图片存放在 skimage 的安装目录下面,路径名称为 data_dir,我们可以将这个路径打印出来看看: 44 | 45 | ```py 46 | from skimage import data_dir 47 | print(data_dir) 48 | ``` 49 | 50 | ## 保存图片 51 | 52 | 使用 io 模块的 `imsave(fname,arr)` 函数来实现。第一个参数表示保存的路径和名称,第二个参数表示需要保存的数组变量。 53 | 54 | ```py 55 | from skimage import io,data 56 | img=data.chelsea() 57 | io.imshow(img) 58 | io.imsave('d:/cat.jpg',img) 59 | ``` 60 | 61 | 保存图片的同时也起到了转换格式的作用。如果读取时图片格式为 jpg 图片,保存为 png 格式,则将图片从 jpg 图片转换为 png 图片并保存。 62 | 63 | # 图片属性 64 | 65 | 其他的 skimage 中常用的图片属性的方法有: 66 | 67 | ```py 68 | from skimage import io, data 69 | img = data.chelsea() 70 | io.imshow(img) 71 | print(type(img)) # 显示类型 72 | print(img.shape) # 显示尺寸 73 | print(img.shape[0]) # 图片高度 74 | print(img.shape[1]) # 图片宽度 75 | print(img.shape[2]) # 图片通道数 76 | print(img.size) # 显示总像素个数 77 | print(img.max()) # 最大像素值 78 | print(img.min()) # 最小像素值 79 | print(img.mean()) # 像素平均值 80 | print(img[0][0])# 图像的像素值 81 | 82 | # 获取图像的灰度值范围 83 | width = img.size[0] 84 | height = img.size[1] 85 | 86 | # 输出图片的像素值 87 | count = 0 88 | for i in range(0, width): 89 | for j in range(0, height): 90 | if img.getpixel((i, j))>=0 and img.getpixel((i, j))<=255: 91 | count +=1 92 | print count 93 | print(height*width) 94 | ``` 95 | 96 | # 图像的批量处理 97 | 98 | 有些时候,我们不仅要对一张图片进行处理,可能还会对一批图片处理。这时候,我们可以通过循环来执行处理,也可以调用程序自带的图片集合来处理。 99 | 100 | ## 批量读取 101 | 102 | 图片集合函数为: 103 | 104 | ```py 105 | skimage.io.ImageCollection(load_pattern,load_func=None) 106 | ``` 107 | 108 | 这个函数是放在 io 模块内的,带两个参数,第一个参数 load_pattern, 表示图片组的路径,可以是一个 str 字符串。第二个参数 load_func 是一个回调函数,我们对图片进行批量处理就可以通过这个回调函数实现。回调函数默认为 imread(),即默认这个函数是批量读取图片。先看一个例子: 109 | 110 | ```py 111 | import skimage.io as io 112 | from skimage import data_dir 113 | str=data_dir + '/*.png' 114 | coll = io.ImageCollection(str) 115 | print(len(coll)) 116 | ``` 117 | 118 | 显示结果为 25, 说明系统自带了 25 张 png 的示例图片,这些图片都读取了出来,放在图片集合 coll 里。如果我们想显示其中一张图片,则可以在后加上一行代码: 119 | 120 | ```sh 121 | io.imshow(coll[10]) 122 | ``` 123 | 124 | 如果一个文件夹里,我们既存放了一些 jpg 格式的图片,又存放了一些 png 格式的图片,现在想把它们全部读取出来,该怎么做呢? 125 | 126 | ```py 127 | import skimage.io as io 128 | from skimage import data_dir 129 | str='d:/pic/*.jpg:d:/pic/*.png' 130 | coll = io.ImageCollection(str) 131 | print(len(coll)) 132 | ``` 133 | 134 | 注意这个地方'd:/pic/.jpg:d:/pic/.png',是两个字符串合在一起的,第一个是'd:/pic/.jpg', 第二个是'd:/pic/.png',合在一起后,中间用冒号来隔开,这样就可以把 d:/pic/文件夹下的 jpg 和 png 格式的图片都读取出来。如果还想读取存放在其它地方的图片,也可以一并加进去,只是中间同样用冒号来隔开。 135 | 136 | ## 批量处理 137 | 138 | io.ImageCollection() 这个函数省略第二个参数,就是批量读取。如果我们不是想批量读取,而是其它批量操作,如批量转换为灰度图,那又该怎么做呢?那就需要先定义一个函数,然后将这个函数作为第二个参数,如: 139 | 140 | ```py 141 | from skimage import data_dir,io,color 142 | def convert_gray(f): 143 | rgb=io.imread(f) 144 | return color.rgb2gray(rgb) 145 | 146 | str=data_dir+'/*.png' 147 | coll = io.ImageCollection(str,load_func=convert_gray) 148 | io.imshow(coll[10]) 149 | ``` 150 | 151 | ## 视频处理 152 | 153 | 这种批量操作对视频处理是极其有用的,因为视频就是一系列的图片组合: 154 | 155 | ```py 156 | from skimage import data_dir,io,color 157 | class AVILoader: 158 | video_file = 'myvideo.avi' 159 | def __call__(self, frame): 160 | return video_read(self.video_file, frame) 161 | avi_load = AVILoader() 162 | 163 | frames = range(0, 1000, 10) # 0, 10, 20, ...ic =io.ImageCollection(frames, load_func=avi_load) 164 | ``` 165 | 166 | 这段代码的意思,就是将 myvideo.avi 这个视频中每隔 10 帧的图片读取出来,放在图片集合中。得到图片集合以后,我们还可以将这些图片连接起来,构成一个维度更高的数组,连接图片的函数为: 167 | 168 | ```py 169 | skimage.io.concatenate_images(ic) 170 | ``` 171 | 172 | 带一个参数,就是以上的图片集合,如: 173 | 174 | ```py 175 | from skimage import data_dir,io,color 176 | coll = io.ImageCollection('d:/pic/*.jpg') 177 | mat=io.concatenate_images(coll) 178 | ``` 179 | 180 | 使用 concatenate_images(ic)函数的前提是读取的这些图片尺寸必须一致,否则会出错。我们看看图片连接前后的维度变化: 181 | 182 | ```py 183 | from skimage import data_dir,io,color 184 | coll = io.ImageCollection('d:/pic/*.jpg') 185 | print(len(coll)) #连接的图片数量 186 | print(coll[0].shape) #连接前的图片尺寸,所有的都一样 187 | mat=io.concatenate_images(coll) 188 | print(mat.shape) #连接后的数组尺寸 189 | 190 | 2 191 | (870, 580, 3) 192 | (2, 870, 580, 3) 193 | ``` 194 | 195 | 可以看到,将 2 个 3 维数组,连接成了一个 4 维数组。如果我们对图片进行批量操作后,想把操作后的结果保存起来,也是可以办到的。例:把系统自带的所有 png 示例图片,全部转换成 256256 的 jpg 格式灰度图,保存在 d:/data/文件夹下。改变图片的大小,我们可以使用 tranform 模块的 resize()函数: 196 | 197 | ```py 198 | from skimage import data_dir,io,transform,color 199 | import numpy as np 200 | def convert_gray(f): 201 | rgb=io.imread(f) #依次读取rgb图片 202 | gray=color.rgb2gray(rgb) #将rgb图片转换成灰度图 203 | dst=transform.resize(gray,(256,256)) #将灰度图片大小转换为256*256 204 | return dst str=data_dir+'/*.png' 205 | coll = io.ImageCollection(str,load_func=convert_gray) 206 | for i in range(len(coll)): 207 | io.imsave('d:/data/'+np.str(i)+'.jpg',coll[i]) #循环保存图片 208 | ``` 209 | -------------------------------------------------------------------------------- /scikit-image/像素处理.md: -------------------------------------------------------------------------------- 1 | # 图像像素的访问与裁剪 2 | 3 | 图片读入程序中后,是以 numpy 数组存在的。因此对 numpy 数组的一切功能,对图片也适用。对数组元素的访问,实际上就是对图片像素点的访问。彩色图片访问方式为:`img[i,j,c]`,i 表示图片的行数,j 表示图片的列数,c 表示图片的通道数(RGB 三通道分别对应 0,1,2)。坐标是从左上角开始。 4 | 5 | 灰度图片访问方式为:`gray[i,j]`,譬如输出小猫图片的 G 通道中的第 20 行 30 列的像素值: 6 | 7 | ```py 8 | from skimage import io,data 9 | img=data.chelsea() 10 | pixel=img[20,30,1] 11 | print(pixel) 12 | ``` 13 | 14 | 譬如显示红色单通道图片: 15 | 16 | ```py 17 | from skimage import io,data 18 | img=data.chelsea() 19 | R=img[:,:,0] 20 | io.imshow(R) 21 | ``` 22 | 23 | ## 像素值修改 24 | 25 | 除了对像素进行读取,也可以修改像素值。譬如对小猫图片随机添加椒盐噪声: 26 | 27 | ```py 28 | from skimage import io,data 29 | import numpy as np 30 | img=data.chelsea() 31 | 32 | #随机生成5000个椒盐 33 | rows,cols,dims=img.shape 34 | for i in range(5000): 35 | x=np.random.randint(0,rows) 36 | y=np.random.randint(0,cols) 37 | img[x,y,:]=255 38 | io.imshow(img) 39 | ``` 40 | 41 | 这里用到了 numpy 包里的 random 来生成随机数,randint(0,cols)表示随机生成一个整数,范围在 0 到 cols 之间。 42 | 用 img[x,y,:]=255 这句来对像素值进行修改,将原来的三通道像素值,变为 255。通过对数组的裁剪,就可以实现对图片的裁剪。对小猫图片进行裁剪 43 | 44 | ```py 45 | from skimage import io,data 46 | img=data.chelsea() 47 | roi=img[80:180,100:200,:] 48 | io.imshow(roi) 49 | ``` 50 | 51 | 对多个像素点进行操作,使用数组切片方式访问。切片方式返回的是以指定间隔下标访问 该数组的像素值。下面是有关灰度图像的一些例子: 52 | 53 | ```bash 54 | img[i,:] = im[j,:] # 将第 j 行的数值赋值给第 i 行 55 | img[:,i] = 100 # 将第 i 列的所有数值设为 100 56 | img[:100,:50].sum() # 计算前 100 行、前 50 列所有数值的和 57 | img[50:100,50:100] # 50~100 行,50~100 列(不包括第 100 行和第 100 列) 58 | img[i].mean() # 第 i 行所有数值的平均值 59 | img[:,-1] # 最后一列 60 | img[-2,:] (or im[-2]) # 倒数第二行 61 | ``` 62 | 63 | 最后我们再看两个对像素值进行访问和改变的例子,将 lena 图片进行二值化,像素值大于 128 的变为 1,否则变为 0 64 | 65 | ```go 66 | from skimage import io,data,color 67 | img=data.lena() 68 | img_gray=color.rgb2gray(img) 69 | rows,cols=img_gray.shape 70 | for i in range(rows): 71 | for j in range(cols): 72 | if (img_gray[i,j]<=0.5): 73 | img_gray[i,j]=0 74 | else: 75 | img_gray[i,j]=1 76 | io.imshow(img_gray) 77 | ``` 78 | 79 | 使用了 color 模块的 rgb2gray() 函数,将彩色三通道图片转换成灰度图。转换结果为 float64 类型的数组,范围为[0,1] 之间。将彩色三通道图片转换成灰度图,最后变成 unit8, float 转换为 unit8 是有信息损失的。 80 | 81 | ```py 82 | img_path = 'data/dpclassifier/newtrain/test/1_0.png' 83 | import Image as img 84 | import os 85 | from matplotlib import pyplot as plot 86 | from skimage import io,transform, img_as_ubyte 87 | img_file1 = img.open(img_path) 88 | img_file1.show() 89 | img_file2 = io.imread(img_path) 90 | io.imshow(img_file2) 91 | print(type(img_file1),img_file1.mode, type(img_file2),img_file2.shape, img_file2.dtype,img_file2.max(),img_file2.min(),img_file2.mean()) 92 | 93 | img_file22=skimage.color.rgb2gray(img_file2) 94 | print(type(img_file22),img_file22.shape,img_file22.dtype,img_file22.max(),img_file22.min(),img_file22.mean() ) 95 | dst=img_as_ubyte(img_file22) 96 | print(type(dst),dst.shape,dst.dtype, dst.max(), dst.min(), dst.mean()) 97 | 98 | (, 'RGB', , (420, 512, 3), dtype('uint8'), 255, 0, 130.9983863467262) 99 | (, (420, 512), dtype('float64'), 1.0, 0.0, 0.5137191621440242) 100 | (, (420, 512), dtype('uint8'), 255, 0, 130.9983863467262) 101 | ``` 102 | 103 | 先对 R 通道的所有像素值进行判断,如果大于 170,则将这个地方的像素值变为[0,255,0], 即 G 通道值为 255,R 和 B 通道值为 0。 104 | 105 | ```py 106 | from skimage import io,data 107 | img=data.chelsea() 108 | reddish = img[:, :, 0] >170 109 | img[reddish] = [0, 255, 0] 110 | io.imshow(img) 111 | ``` 112 | 113 | # 图像数据类型及颜色空间转换 114 | 115 | ## 数据类型 116 | 117 | 在 skimage 中,一张图片就是一个简单的 numpy 数组,数组的数据类型有很多种,相互之间也可以转换。这些数据类型及取值范围如下表所示: 118 | 119 | ```s 120 | Data type Range 121 | uint8 0 to 255 122 | uint16 0 to 65535 123 | uint32 0 to 232 124 | float -1 to 1 or 0 to 1 125 | int8 -128 to 127 126 | int16 -32768 to 32767 127 | int32 -231 to 231 - 1 128 | ``` 129 | 130 | 一张图片的像素值范围是[0,255], 因此默认类型是 unit8, 可用如下代码查看数据类型: 131 | 132 | ```py 133 | from skimage import io,data 134 | img=data.chelsea() 135 | print(img.dtype.name) 136 | ``` 137 | 138 | 在上面的表中,特别注意的是 float 类型,它的范围是[-1,1]或[0,1]之间。一张彩色图片转换为灰度图后,它的类型就由 unit8 变成了 float。 139 | 140 | - unit8 转 float 141 | 142 | ```py 143 | from skimage import data,img_as_float 144 | img=data.chelsea() 145 | print(img.dtype.name) 146 | dst=img_as_float(img) 147 | print(dst.dtype.name) 148 | ``` 149 | 150 | - float 转 uint8 151 | 152 | ```py 153 | from skimage import img_as_ubyte 154 | import numpy as np 155 | img = np.array([0, 0.5, 1], dtype=float) 156 | print(img.dtype.name) 157 | dst=img_as_ubyte(img) 158 | print(dst.dtype.name) 159 | ``` 160 | 161 | float 转为 unit8,有可能会造成数据的损失,因此会有警告提醒。除了这两种最常用的转换以外,其实有一些其它的类型转换,如下表: 162 | 163 | ```s 164 | Function name Description 165 | img_as_float Convert to 64-bit floating point. 166 | img_as_ubyte Convert to 8-bit uint. 167 | img_as_uint Convert to 16-bit uint. 168 | img_as_int Convert to 16-bit int. 169 | ``` 170 | 171 | ## 颜色空间 172 | 173 | 如前所述,除了直接转换可以改变数据类型外,还可以通过图像的颜色空间转换来改变数据类型。常用的颜色空间有灰度空间、rgb 空间、hsv 空间和 cmyk 空间。颜色空间转换以后,图片类型都变成了 float 型。 174 | 175 | 所有的颜色空间转换函数,都放在 skimage 的 color 模块内。 176 | 177 | - 例:rgb 转灰度图: 178 | 179 | ```py 180 | from skimage import io,data,color 181 | img=data.lena() 182 | gray=color.rgb2gray(img) 183 | io.imshow(gray) 184 | ``` 185 | 186 | 其它的转换,用法都是一样的,列举常用的如下: 187 | 188 | ```py 189 | skimage.color.rgb2grey(rgb) 190 | skimage.color.rgb2hsv(rgb) 191 | skimage.color.rgb2lab(rgb) 192 | skimage.color.gray2rgb(image) 193 | skimage.color.hsv2rgb(hsv) 194 | skimage.color.lab2rgb(lab) 195 | ``` 196 | 197 | 实际上,上面的所有转换函数,都可以用一个函数来代替: 198 | 199 | ```py 200 | skimage.color.convert_colorspace(arr, fromspace, tospace) 201 | ``` 202 | 203 | 表示将 arr 从 fromspace 颜色空间转换到 tospace 颜色空间。 204 | 205 | - 例:rgb 转 hsv 206 | 207 | ```py 208 | from skimage import io,data,color 209 | img=data.lena() 210 | hsv=color.convert_colorspace(img,'RGB','HSV') 211 | io.imshow(hsv) 212 | ``` 213 | 214 | 在 color 模块的颜色空间转换函数中,还有一个比较有用的函数是 skimage.color.label2rgb(arr), 可以根据标签值对图片进行着色。以后的图片分类后着色就可以用这个函数。 215 | 216 | - 例:将 lena 图片分成三类,然后用默认颜色对三类进行着色 217 | 218 | ```py 219 | from skimage import io,data,color 220 | import numpy as np 221 | img=data.lena() 222 | gray=color.rgb2gray(img) 223 | rows,cols=gray.shape 224 | labels=np.zeros([rows,cols]) 225 | for i in range(rows): 226 | for j in range(cols): 227 | if(gray[i,j]<0.4): 228 | labels[i,j]=0 229 | elif(gray[i,j]<0.75): 230 | labels[i,j]=1 231 | else: 232 | labels[i,j]=2 233 | dst=color.label2rgb(labels) 234 | io.imshow(dst) 235 | ``` 236 | -------------------------------------------------------------------------------- /header.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 101 | 366 |
367 |

368 | Computer Graphics and Visualization 369 |

370 |

371 | 计算机图形、视觉与数据可视化 372 |

373 |
374 | 375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 | 391 | 392 |
393 |
394 |
-------------------------------------------------------------------------------- /scikit-image/绘制与转化.md: -------------------------------------------------------------------------------- 1 | # 图像绘制 2 | 3 | 实际上前面我们就已经用到了图像的绘制,如: 4 | 5 | ```py 6 | io.imshow(img) 7 | ``` 8 | 9 | 这一行代码的实质是利用 matplotlib 包对图片进行绘制,绘制成功后,返回一个 matplotlib 类型的数据。因此,我们也可以这样写: 10 | 11 | ```py 12 | import matplotlib.pyplot as plt 13 | plt.imshow(img) 14 | ``` 15 | 16 | imshow()函数格式为: 17 | 18 | ```py 19 | matplotlib.pyplot.imshow(X, cmap=None) 20 | ``` 21 | 22 | 其中 X 是要绘制的图像或数组。cmap 是颜色图谱(colormap), 默认绘制为 RGB(A)颜色空间。其它可选的颜色图谱如下列表: 23 | 24 | ```s 25 | 颜色图谱 描述 26 | autumn 红-橙-黄 27 | bone 黑-白,x线 28 | cool 青-洋红 29 | copper 黑-铜 30 | flag 红-白-蓝-黑 31 | gray 黑-白 32 | hot 黑-红-黄-白 33 | hsv hsv颜色空间,红-黄-绿-青-蓝-洋红-红 34 | inferno 黑-红-黄 35 | jet 蓝-青-黄-红 36 | magma 黑-红-白 37 | pink 黑-粉-白 38 | plasma 绿-红-黄 39 | prism 红-黄-绿-蓝-紫-...-绿模式 40 | spring 洋红-黄 41 | summer 绿-黄 42 | viridis 蓝-绿-黄 43 | winter 蓝-绿 44 | ``` 45 | 46 | 用的比较多的有 gray, jet 等,如: 47 | 48 | ```py 49 | plt.imshow(image,plt.cm.gray) 50 | plt.imshow(img,cmap=plt.cm.jet) 51 | ``` 52 | 53 | 在窗口上绘制完图片后,返回一个 AxesImage 对象。要在窗口上显示这个对象,我们可以调用 show()函数来进行显示,但进行练习的时候(ipython 环境中),一般我们可以省略 show() 函数,也能自动显示出来。 54 | 55 | ```py 56 | from skimage import io,data 57 | img=data.astronaut() 58 | dst=io.imshow(img) 59 | print(type(dst)) 60 | io.show() 61 | ``` 62 | 63 | 可以看到,类型是'matplotlib.image.AxesImage'。显示一张图片,我们通常更愿意这样写: 64 | 65 | ```py 66 | import matplotlib.pyplot as plt 67 | from skimage import io,data 68 | img=data.astronaut() 69 | plt.imshow(img) 70 | plt.show() 71 | ``` 72 | 73 | # matplotlib 多窗口 74 | 75 | matplotlib 是一个专业绘图的库,相当于 matlab 中的 plot,可以设置多个 figure 窗口,设置 figure 的标题,隐藏坐标尺,甚至可以使用 subplot 在一个 figure 中显示多张图片。一般我们可以这样导入 matplotlib 库: 76 | 77 | ```py 78 | import matplotlib.pyplot as plt 79 | ``` 80 | 81 | 也就是说,我们绘图实际上用的是 matplotlib 包的 pyplot 模块。用 figure 函数和 subplot 函数分别创建主窗口与子图,分开并同时显示宇航员图片的三个通道: 82 | 83 | ```py 84 | from skimage import data 85 | import matplotlib.pyplot as plt 86 | img=data.astronaut() 87 | plt.figure(num='astronaut',figsize=(8,8)) #创建一个名为astronaut的窗口,并设置大小 88 | 89 | plt.subplot(2,2,1) #将窗口分为两行两列四个子图,则可显示四幅图片 90 | plt.title('origin image') #第一幅图片标题 91 | plt.imshow(img) #绘制第一幅图片 92 | 93 | plt.subplot(2,2,2) #第二个子图 94 | plt.title('R channel') #第二幅图片标题 95 | plt.imshow(img[:,:,0],plt.cm.gray) #绘制第二幅图片,且为灰度图 96 | plt.axis('off') #不显示坐标尺寸 97 | 98 | plt.subplot(2,2,3) #第三个子图 99 | plt.title('G channel') #第三幅图片标题 100 | plt.imshow(img[:,:,1],plt.cm.gray) #绘制第三幅图片,且为灰度图 101 | plt.axis('off') #不显示坐标尺寸 102 | 103 | plt.subplot(2,2,4) #第四个子图 104 | plt.title('B channel') #第四幅图片标题 105 | plt.imshow(img[:,:,2],plt.cm.gray) #绘制第四幅图片,且为灰度图 106 | plt.axis('off') #不显示坐标尺寸 107 | 108 | plt.show() #显示窗口 109 | ``` 110 | 111 | 在图片绘制过程中,我们用 matplotlib.pyplot 模块下的 figure() 函数来创建显示窗口,该函数的格式为: 112 | 113 | ```py 114 | matplotlib.pyplot.figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None) 115 | ``` 116 | 117 | 所有参数都是可选的,都有默认值,因此调用该函数时可以不带任何参数,其中: 118 | 119 | - num: 整型或字符型都可以。如果设置为整型,则该整型数字表示窗口的序号。如果设置为字符型,则该字符串表示窗口的名称。用该参数来命名窗口,如果两个窗口序号或名相同,则后一个窗口会覆盖前一个窗口。 120 | - figsize: 设置窗口大小。是一个 tuple 型的整数,如 figsize=(8,8) 121 | - dpi: 整形数字,表示窗口的分辨率。 122 | - facecolor: 窗口的背景颜色。 123 | - edgecolor: 窗口的边框颜色。 124 | 125 | 用 figure() 函数创建的窗口,只能显示一幅图片,如果想要显示多幅图片,则需要将这个窗口再划分为几个子图,在每个子图中显示不同的图片。我们可以使用 subplot() 函数来划分子图,函数格式为: 126 | 127 | ```py 128 | matplotlib.pyplot.subplot(nrows, ncols, plot_number) 129 | ``` 130 | 131 | nrows: 子图的行数。ncols: 子图的列数。plot_number: 当前子图的编号。如 `plt.subplot(2,2,1)` 则表示将 figure 窗口划分成了 2 行 2 列共 4 个子图,当前为第 1 个子图。我们有时也可以用这种写法: 132 | 133 | ```py 134 | plt.subplot(221) 135 | ``` 136 | 137 | 两种写法效果是一样的。每个子图的标题可用 title()函数来设置,是否使用坐标尺可用 axis()函数来设置,如: 138 | 139 | ```py 140 | plt.subplot(221) 141 | plt.title("first subwindow") 142 | plt.axis('off') 143 | ``` 144 | 145 | ## subplots 146 | 147 | 用 subplots 来创建显示窗口与划分子图,除了上面那种方法创建显示窗口和划分子图,还有另外一种编写方法也可以,如下例: 148 | 149 | ```py 150 | import matplotlib.pyplot as plt 151 | from skimage import data,color 152 | 153 | img = data.immunohistochemistry() 154 | hsv = color.rgb2hsv(img) 155 | 156 | fig, axes = plt.subplots(2, 2, figsize=(7, 6)) 157 | ax0, ax1, ax2, ax3 = axes.ravel() 158 | 159 | ax0.imshow(img) 160 | ax0.set_title("Original image") 161 | 162 | ax1.imshow(hsv[:, :, 0], cmap=plt.cm.gray) 163 | ax1.set_title("H") 164 | 165 | ax2.imshow(hsv[:, :, 1], cmap=plt.cm.gray) 166 | ax2.set_title("S") 167 | 168 | ax3.imshow(hsv[:, :, 2], cmap=plt.cm.gray) 169 | ax3.set_title("V") 170 | 171 | for ax in axes.ravel(): 172 | ax.axis('off') 173 | 174 | fig.tight_layout() #自动调整subplot间的参数 175 | ``` 176 | 177 | 直接用 subplots()函数来创建并划分窗口。注意,比前面的 subplot()函数多了一个 s,该函数格式为: 178 | 179 | ```py 180 | matplotlib.pyplot.subplots(nrows=1, ncols=1) 181 | ``` 182 | 183 | nrows: 所有子图行数,默认为 1。ncols: 所有子图列数,默认为 1。返回一个窗口 figure, 和一个 tuple 型的 ax 对象,该对象包含所有的子图,可结合 ravel()函数列出所有子图,如: 184 | 185 | ```py 186 | fig, axes = plt.subplots(2, 2, figsize=(7, 6)) 187 | ax0, ax1, ax2, ax3 = axes.ravel() 188 | ``` 189 | 190 | 创建了 2 行 2 列 4 个子图,分别取名为 ax0,ax1,ax2 和 ax3, 每个子图的标题用 set_title()函数来设置,如: 191 | 192 | ```py 193 | ax0.imshow(img) 194 | ax0.set_title("Original image") 195 | ``` 196 | 197 | 如果有多个子图,我们还可以使用 tight_layout()函数来调整显示的布局,该函数格式为: 198 | 199 | ```py 200 | matplotlib.pyplot.tight_layout(pad=1.08, h_pad=None, w_pad=None, rect=None) 201 | ``` 202 | 203 | 所有的参数都是可选的,调用该函数时可省略所有的参数。 204 | 205 | - pad: 主窗口边缘和子图边缘间的间距,默认为 1.08 206 | - h_pad, w_pad: 子图边缘之间的间距,默认为 pad_inches 207 | - rect: 一个矩形区域,如果设置这个值,则将所有的子图调整到这个矩形区域内。 208 | 209 | 一般调用为: 210 | 211 | ```py 212 | plt.tight_layout() #自动调整subplot间的参数 213 | ``` 214 | 215 | ## 其它方法绘图并显示 216 | 217 | 除了使用 matplotlib 库来绘制图片,skimage 还有另一个子模块 viewer,也提供一个函数来显示图片。不同的是,它利用 Qt 工具来创建一块画布,从而在画布上绘制图像。 218 | 219 | ```py 220 | from skimage import data 221 | from skimage.viewer import ImageViewer 222 | img = data.coins() 223 | viewer = ImageViewer(img) 224 | viewer.show() 225 | ``` 226 | 227 | 最后总结一下,绘制和显示图片常用到的函数有: 228 | 229 | ```py 230 | 函数名 功能 调用格式 231 | figure 创建一个显示窗口 plt.figure(num=1,figsize=(8,8) 232 | imshow 绘制图片 plt.imshow(image) 233 | show 显示窗口 plt.show() 234 | subplot 划分子图 plt.subplot(2,2,1) 235 | title 设置子图标题(与subplot结合使用) plt.title('origin image') 236 | axis 是否显示坐标尺 plt.axis('off') 237 | subplots 创建带有多个子图的窗口 fig,axes=plt.subplots(2,2,figsize=(8,8)) 238 | ravel 为每个子图设置变量 ax0,ax1,ax2,ax3=axes.ravel() 239 | set_title 设置子图标题(与axes结合使用) ax0.set_title('first window') 240 | tight_layout 自动调整子图显示布局 plt.tight_layout() 241 | ``` 242 | 243 | # 图像的形变与缩放 244 | 245 | 图像的形变与缩放,使用的是 skimage 的 transform 模块,函数比较多,功能齐全。 246 | 247 | ## 改变图片尺寸 resize 248 | 249 | 函数格式为: 250 | 251 | ```py 252 | skimage.transform.resize(image, output_shape) 253 | ``` 254 | 255 | 其中 image 是需要改变尺寸的图片,output_size 是新的图片尺寸。 256 | 257 | ```py 258 | from skimage import transform,data 259 | import matplotlib.pyplot as plt 260 | img = data.camera() 261 | dst=transform.resize(img, (80, 60)) 262 | plt.figure('resize') 263 | plt.subplot(121) 264 | plt.title('before resize') 265 | plt.imshow(img,plt.cm.gray) 266 | plt.subplot(122) 267 | plt.title('before resize') 268 | plt.imshow(dst,plt.cm.gray) 269 | plt.show() 270 | ``` 271 | 272 | 将 camera 图片由原来的 512x512 大小,变成了 80x60 大小。从下图中的坐标尺,我们能够看出来: 273 | 274 | ![缩放图片示范](https://s1.ax1x.com/2020/06/15/N9kKMV.png) 275 | 276 | ## 按比例缩放 rescale 277 | 278 | 函数格式为: 279 | 280 | ```py 281 | skimage.transform.rescale(image, scale[, ...]) 282 | ``` 283 | 284 | scale 参数可以是单个 float 数,表示缩放的倍数,也可以是一个 float 型的 tuple,如[0.2,0.5],表示将行列数分开进行缩放: 285 | 286 | ```py 287 | from skimage import transform,data 288 | img = data.camera() 289 | print(img.shape) #图片原始大小 290 | print(transform.rescale(img, 0.1).shape) #缩小为原来图片大小的0.1 291 | print(transform.rescale(img, [0.5,0.25]).shape) #缩小为原来图片行数一半,列数四分之一 292 | print(transform.rescale(img, 2).shape) #放大为原来图片大小的2倍 293 | ``` 294 | 295 | 结果为: 296 | 297 | ```py 298 | (512, 512) 299 | (51, 51) 300 | (256, 128) 301 | (1024, 1024) 302 | ``` 303 | 304 | ## 旋转 rotate 305 | 306 | ```py 307 | skimage.transform.rotate(image, angle[, ...],resize=False) 308 | ``` 309 | 310 | angle 参数是个 float 类型数,表示旋转的度数,resize 用于控制在旋转时,是否改变大小,默认为 False。 311 | 312 | ```py 313 | from skimage import transform,data 314 | import matplotlib.pyplot as plt 315 | img = data.camera() 316 | print(img.shape) #图片原始大小 317 | img1=transform.rotate(img, 60) #旋转90度,不改变大小 318 | print(img1.shape) 319 | img2=transform.rotate(img, 30,resize=True) #旋转30度,同时改变大小 320 | print(img2.shape) plt.figure('resize') 321 | plt.subplot(121)plt.title('rotate 60') 322 | plt.imshow(img1,plt.cm.gray) 323 | plt.subplot(122) 324 | plt.title('rotate 30') 325 | plt.imshow(img2,plt.cm.gray) 326 | plt.show() 327 | ``` 328 | 329 | 显示结果: 330 | 331 | ![](https://s1.ax1x.com/2020/06/15/N9kdsK.png) 332 | 333 | ## 图像金字塔 334 | 335 | 以多分辨率来解释图像的一种有效但概念简单的结构就是图像金字塔。图像金字塔最初用于机器视觉和图像压缩,一幅图像的金字塔是一系列以金字塔形状排列的分辨率逐步降低的图像集合。金字塔的底部是待处理图像的高分辨率表示,而顶部是低分辨率的近似。当向金字塔的上层移动时,尺寸和分辨率就降低。 336 | 337 | 在此,我们举一个高斯金字塔的应用实例,函数原型为: 338 | 339 | ```py 340 | skimage.transform.pyramid_gaussian(image, downscale=2) 341 | ``` 342 | 343 | downscale 控制着金字塔的缩放比例: 344 | 345 | ```py 346 | import numpy as np 347 | import matplotlib.pyplot as plt 348 | from skimage import data,transform 349 | image = data.astronaut() #载入宇航员图片 350 | rows, cols, dim = image.shape #获取图片的行数,列数和通道数 351 | pyramid = tuple(transform.pyramid_gaussian(image, downscale=2)) #产生高斯金字塔图像#共生成了log(512)=9幅金字塔图像,加上原始图像共10幅,pyramid[0]-pyramid[1] 352 | composite_image = np.ones((rows, cols + cols / 2, 3), dtype=np.double) #生成背景composite_image[:rows, :cols, :] = pyramid[0] #融合原始图像 353 | i_row = 0 354 | for p in pyramid[1:]: 355 | n_rows, n_cols = p.shape[:2] 356 | composite_image[i_row:i_row + n_rows, cols:cols + n_cols] = p #循环融合9幅金字塔图像 357 | i_row += n_rows 358 | 359 | plt.imshow(composite_image) 360 | plt.show() 361 | ``` 362 | 363 | ![](https://s1.ax1x.com/2020/06/15/N9kDde.png) 364 | 365 | ![](https://s1.ax1x.com/2020/06/15/N9kcRI.png) 366 | 367 | 上右图,就是 10 张金字塔图像,下标为 0 的表示原始图像,后面每层的图像行和列变为上一层的一半,直至变为 1。除了高斯金字塔外,还有其它的金字塔,如: 368 | 369 | ```py 370 | skimage.transform.pyramid_laplacian(image, downscale=2) 371 | ``` 372 | 373 | ![](https://s1.ax1x.com/2020/06/15/N9kWsf.png) 374 | 375 | # 对比度与亮度调整 376 | 377 | 图像亮度与对比度的调整,是放在 skimage 包的 exposure 模块里面。 378 | 379 | ## gamma 调整 380 | 381 | 原理:I=Ig,对原图像的像素,进行幂运算,得到新的像素值。公式中的 g 就是 gamma 值。如果 gamma>1, 新图像比原图像暗;如果 gamma<1,新图像比原图像亮。函数格式为: 382 | 383 | ```py 384 | skimage.exposure.adjust_gamma(image, gamma=1) 385 | ``` 386 | 387 | gamma 参数默认为 1,原像不发生变化 。 388 | 389 | ```py 390 | from skimage import data, exposure, img_as_float 391 | import matplotlib.pyplot as plt 392 | image = img_as_float(data.moon()) 393 | gam1= exposure.adjust_gamma(image, 2) #调暗 394 | gam2= exposure.adjust_gamma(image, 0.5) #调亮plt.figure('adjust_gamma',figsize=(8,8)) 395 | plt.subplot(131)plt.title('origin image') 396 | plt.imshow(image,plt.cm.gray)plt.axis('off') 397 | plt.subplot(132) 398 | plt.title('gamma=2') 399 | plt.imshow(gam1,plt.cm.gray) 400 | plt.axis('off') 401 | plt.subplot(133) 402 | plt.title('gamma=0.5') 403 | plt.imshow(gam2,plt.cm.gray) 404 | plt.axis('off') 405 | plt.show() 406 | ``` 407 | 408 | ![](https://s1.ax1x.com/2020/06/15/N9EmuV.png) 409 | 410 | ## log 对数调整 411 | 412 | 这个刚好和 gamma 相反,原理:I=log(I)。 413 | 414 | ```py 415 | from skimage import data, exposure, img_as_float 416 | import matplotlib.pyplot as plt 417 | image = img_as_float(data.moon()) 418 | gam1= exposure.adjust_log(image) #对数调整 419 | plt.figure('adjust_gamma',figsize=(8,8)) 420 | plt.subplot(121)plt.title('origin image') 421 | plt.imshow(image,plt.cm.gray) 422 | plt.axis('off') 423 | plt.subplot(122) 424 | plt.title('log') 425 | plt.imshow(gam1,plt.cm.gray) 426 | plt.axis('off') 427 | plt.show() 428 | ``` 429 | 430 | ![](https://s1.ax1x.com/2020/06/15/N9EMEF.png) 431 | 432 | ## 判断图像对比度是否偏低 433 | 434 | 函数:is_low_contrast(img),返回一个 bool 型值: 435 | 436 | ```py 437 | from skimage import data, exposure 438 | image =data.moon() 439 | result=exposure.is_low_contrast(image) 440 | print(result) 441 | ``` 442 | 443 | 输出为 False。 444 | 445 | ## 调整强度 446 | 447 | 函数: 448 | 449 | ```bash 450 | skimage.exposure.rescale_intensity(image, in_range='image', out_range='dtype') 451 | ``` 452 | 453 | in_range 表示输入图片的强度范围,默认为'image', 表示用图像的最大/最小像素值作为范围 454 | out_range 表示输出图片的强度范围,默认为'dype', 表示用图像的类型的最大/最小值作为范围 455 | 默认情况下,输入图片的[min,max]范围被拉伸到[dtype.min, dtype.max],如果 dtype=uint8, 那么 dtype.min=0, dtype.max=255 456 | 457 | ```python 458 | import numpy as np 459 | from skimage import exposure 460 | image = np.array([51, 102, 153], dtype=np.uint8) 461 | mat=exposure.rescale_intensity(image) 462 | print(mat) 463 | ``` 464 | 465 | 输出为[ 0 127 255] 466 | 即像素最小值由 51 变为 0,最大值由 153 变为 255,整体进行了拉伸,但是数据类型没有变,还是 uint8 467 | 前面我们讲过,可以通过 img_as_float()函数将 unit8 类型转换为 float 型,实际上还有更简单的方法,就是乘以 1.0 468 | 469 | ```py 470 | import numpy as np 471 | image = np.array([51, 102, 153], dtype=np.uint8) 472 | print(image*1.0) 473 | ``` 474 | 475 | 即由[51,102,153]变成了[ 51. 102. 153.],而**float 类型的范围是[0,1]**,因此对 float 进行 rescale_intensity 调整后,范围变为 [0,1],而不是[ 0,255]: 476 | 477 | ```python 478 | import numpy as np 479 | from skimage import exposure 480 | image = np.array([51, 102, 153], dtype=np.uint8) 481 | tmp=image*1.0 482 | mat=exposure.rescale_intensity(tmp) 483 | print(mat) 484 | ``` 485 | 486 | 结果为 [ 0. 0.5 1. ],如果原始像素值不想被拉伸,只是等比例缩小,就使用 in_range 参数,如: 487 | 488 | ```python 489 | import numpy as np 490 | from skimage import exposure 491 | image = np.array([51, 102, 153], dtype=np.uint8) 492 | tmp=image*1.0 493 | mat=exposure.rescale_intensity(tmp,in_range=(0,255)) 494 | print(mat) 495 | ``` 496 | 497 | 输出为:[ 0.2 0.4 0.6],即原像素值除以 255,如果参数 in_range 的[main,max]范围要比原始像素值的范围[min,max] 大或者小,那就进行裁剪,如: 498 | 499 | ```bash 500 | mat=exposure.rescale_intensity(tmp,in_range=(0,102)) 501 | print(mat) 502 | ``` 503 | 504 | 输出[ 0.5 1. 1. ],即原像素值除以 102,超出 1 的变为 1,如果一个数组里面有负数,现在想调整到正数,就使用 out_range 参数。如: 505 | 506 | ```python 507 | import numpy as np 508 | from skimage import exposure 509 | image = np.array([-10, 0, 10], dtype=np.int8) 510 | mat=exposure.rescale_intensity(image, out_range=(0, 127)) 511 | print(mat) 512 | ``` 513 | 514 | 输出 [0 63 127]。 515 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International 2 | Public License 3 | 4 | By exercising the Licensed Rights (defined below), You accept and agree 5 | to be bound by the terms and conditions of this Creative Commons 6 | Attribution-NonCommercial-ShareAlike 4.0 International Public License 7 | ("Public License"). To the extent this Public License may be 8 | interpreted as a contract, You are granted the Licensed Rights in 9 | consideration of Your acceptance of these terms and conditions, and the 10 | Licensor grants You such rights in consideration of benefits the 11 | Licensor receives from making the Licensed Material available under 12 | these terms and conditions. 13 | 14 | 15 | Section 1 -- Definitions. 16 | 17 | a. Adapted Material means material subject to Copyright and Similar 18 | Rights that is derived from or based upon the Licensed Material 19 | and in which the Licensed Material is translated, altered, 20 | arranged, transformed, or otherwise modified in a manner requiring 21 | permission under the Copyright and Similar Rights held by the 22 | Licensor. For purposes of this Public License, where the Licensed 23 | Material is a musical work, performance, or sound recording, 24 | Adapted Material is always produced where the Licensed Material is 25 | synched in timed relation with a moving image. 26 | 27 | b. Adapter's License means the license You apply to Your Copyright 28 | and Similar Rights in Your contributions to Adapted Material in 29 | accordance with the terms and conditions of this Public License. 30 | 31 | c. BY-NC-SA Compatible License means a license listed at 32 | creativecommons.org/compatiblelicenses, approved by Creative 33 | Commons as essentially the equivalent of this Public License. 34 | 35 | d. Copyright and Similar Rights means copyright and/or similar rights 36 | closely related to copyright including, without limitation, 37 | performance, broadcast, sound recording, and Sui Generis Database 38 | Rights, without regard to how the rights are labeled or 39 | categorized. For purposes of this Public License, the rights 40 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 41 | Rights. 42 | 43 | e. Effective Technological Measures means those measures that, in the 44 | absence of proper authority, may not be circumvented under laws 45 | fulfilling obligations under Article 11 of the WIPO Copyright 46 | Treaty adopted on December 20, 1996, and/or similar international 47 | agreements. 48 | 49 | f. Exceptions and Limitations means fair use, fair dealing, and/or 50 | any other exception or limitation to Copyright and Similar Rights 51 | that applies to Your use of the Licensed Material. 52 | 53 | g. License Elements means the license attributes listed in the name 54 | of a Creative Commons Public License. The License Elements of this 55 | Public License are Attribution, NonCommercial, and ShareAlike. 56 | 57 | h. Licensed Material means the artistic or literary work, database, 58 | or other material to which the Licensor applied this Public 59 | License. 60 | 61 | i. Licensed Rights means the rights granted to You subject to the 62 | terms and conditions of this Public License, which are limited to 63 | all Copyright and Similar Rights that apply to Your use of the 64 | Licensed Material and that the Licensor has authority to license. 65 | 66 | j. Licensor means the individual(s) or entity(ies) granting rights 67 | under this Public License. 68 | 69 | k. NonCommercial means not primarily intended for or directed towards 70 | commercial advantage or monetary compensation. For purposes of 71 | this Public License, the exchange of the Licensed Material for 72 | other material subject to Copyright and Similar Rights by digital 73 | file-sharing or similar means is NonCommercial provided there is 74 | no payment of monetary compensation in connection with the 75 | exchange. 76 | 77 | l. Share means to provide material to the public by any means or 78 | process that requires permission under the Licensed Rights, such 79 | as reproduction, public display, public performance, distribution, 80 | dissemination, communication, or importation, and to make material 81 | available to the public including in ways that members of the 82 | public may access the material from a place and at a time 83 | individually chosen by them. 84 | 85 | m. Sui Generis Database Rights means rights other than copyright 86 | resulting from Directive 96/9/EC of the European Parliament and of 87 | the Council of 11 March 1996 on the legal protection of databases, 88 | as amended and/or succeeded, as well as other essentially 89 | equivalent rights anywhere in the world. 90 | 91 | n. You means the individual or entity exercising the Licensed Rights 92 | under this Public License. Your has a corresponding meaning. 93 | 94 | 95 | Section 2 -- Scope. 96 | 97 | a. License grant. 98 | 99 | 1. Subject to the terms and conditions of this Public License, 100 | the Licensor hereby grants You a worldwide, royalty-free, 101 | non-sublicensable, non-exclusive, irrevocable license to 102 | exercise the Licensed Rights in the Licensed Material to: 103 | 104 | a. reproduce and Share the Licensed Material, in whole or 105 | in part, for NonCommercial purposes only; and 106 | 107 | b. produce, reproduce, and Share Adapted Material for 108 | NonCommercial purposes only. 109 | 110 | 2. Exceptions and Limitations. For the avoidance of doubt, where 111 | Exceptions and Limitations apply to Your use, this Public 112 | License does not apply, and You do not need to comply with 113 | its terms and conditions. 114 | 115 | 3. Term. The term of this Public License is specified in Section 116 | 6(a). 117 | 118 | 4. Media and formats; technical modifications allowed. The 119 | Licensor authorizes You to exercise the Licensed Rights in 120 | all media and formats whether now known or hereafter created, 121 | and to make technical modifications necessary to do so. The 122 | Licensor waives and/or agrees not to assert any right or 123 | authority to forbid You from making technical modifications 124 | necessary to exercise the Licensed Rights, including 125 | technical modifications necessary to circumvent Effective 126 | Technological Measures. For purposes of this Public License, 127 | simply making modifications authorized by this Section 2(a) 128 | (4) never produces Adapted Material. 129 | 130 | 5. Downstream recipients. 131 | 132 | a. Offer from the Licensor -- Licensed Material. Every 133 | recipient of the Licensed Material automatically 134 | receives an offer from the Licensor to exercise the 135 | Licensed Rights under the terms and conditions of this 136 | Public License. 137 | 138 | b. Additional offer from the Licensor -- Adapted Material. 139 | Every recipient of Adapted Material from You 140 | automatically receives an offer from the Licensor to 141 | exercise the Licensed Rights in the Adapted Material 142 | under the conditions of the Adapter's License You apply. 143 | 144 | c. No downstream restrictions. You may not offer or impose 145 | any additional or different terms or conditions on, or 146 | apply any Effective Technological Measures to, the 147 | Licensed Material if doing so restricts exercise of the 148 | Licensed Rights by any recipient of the Licensed 149 | Material. 150 | 151 | 6. No endorsement. Nothing in this Public License constitutes or 152 | may be construed as permission to assert or imply that You 153 | are, or that Your use of the Licensed Material is, connected 154 | with, or sponsored, endorsed, or granted official status by, 155 | the Licensor or others designated to receive attribution as 156 | provided in Section 3(a)(1)(A)(i). 157 | 158 | b. Other rights. 159 | 160 | 1. Moral rights, such as the right of integrity, are not 161 | licensed under this Public License, nor are publicity, 162 | privacy, and/or other similar personality rights; however, to 163 | the extent possible, the Licensor waives and/or agrees not to 164 | assert any such rights held by the Licensor to the limited 165 | extent necessary to allow You to exercise the Licensed 166 | Rights, but not otherwise. 167 | 168 | 2. Patent and trademark rights are not licensed under this 169 | Public License. 170 | 171 | 3. To the extent possible, the Licensor waives any right to 172 | collect royalties from You for the exercise of the Licensed 173 | Rights, whether directly or through a collecting society 174 | under any voluntary or waivable statutory or compulsory 175 | licensing scheme. In all other cases the Licensor expressly 176 | reserves any right to collect such royalties, including when 177 | the Licensed Material is used other than for NonCommercial 178 | purposes. 179 | 180 | 181 | Section 3 -- License Conditions. 182 | 183 | Your exercise of the Licensed Rights is expressly made subject to the 184 | following conditions. 185 | 186 | a. Attribution. 187 | 188 | 1. If You Share the Licensed Material (including in modified 189 | form), You must: 190 | 191 | a. retain the following if it is supplied by the Licensor 192 | with the Licensed Material: 193 | 194 | i. identification of the creator(s) of the Licensed 195 | Material and any others designated to receive 196 | attribution, in any reasonable manner requested by 197 | the Licensor (including by pseudonym if 198 | designated); 199 | 200 | ii. a copyright notice; 201 | 202 | iii. a notice that refers to this Public License; 203 | 204 | iv. a notice that refers to the disclaimer of 205 | warranties; 206 | 207 | v. a URI or hyperlink to the Licensed Material to the 208 | extent reasonably practicable; 209 | 210 | b. indicate if You modified the Licensed Material and 211 | retain an indication of any previous modifications; and 212 | 213 | c. indicate the Licensed Material is licensed under this 214 | Public License, and include the text of, or the URI or 215 | hyperlink to, this Public License. 216 | 217 | 2. You may satisfy the conditions in Section 3(a)(1) in any 218 | reasonable manner based on the medium, means, and context in 219 | which You Share the Licensed Material. For example, it may be 220 | reasonable to satisfy the conditions by providing a URI or 221 | hyperlink to a resource that includes the required 222 | information. 223 | 3. If requested by the Licensor, You must remove any of the 224 | information required by Section 3(a)(1)(A) to the extent 225 | reasonably practicable. 226 | 227 | b. ShareAlike. 228 | 229 | In addition to the conditions in Section 3(a), if You Share 230 | Adapted Material You produce, the following conditions also apply. 231 | 232 | 1. The Adapter's License You apply must be a Creative Commons 233 | license with the same License Elements, this version or 234 | later, or a BY-NC-SA Compatible License. 235 | 236 | 2. You must include the text of, or the URI or hyperlink to, the 237 | Adapter's License You apply. You may satisfy this condition 238 | in any reasonable manner based on the medium, means, and 239 | context in which You Share Adapted Material. 240 | 241 | 3. You may not offer or impose any additional or different terms 242 | or conditions on, or apply any Effective Technological 243 | Measures to, Adapted Material that restrict exercise of the 244 | rights granted under the Adapter's License You apply. 245 | 246 | 247 | Section 4 -- Sui Generis Database Rights. 248 | 249 | Where the Licensed Rights include Sui Generis Database Rights that 250 | apply to Your use of the Licensed Material: 251 | 252 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 253 | to extract, reuse, reproduce, and Share all or a substantial 254 | portion of the contents of the database for NonCommercial purposes 255 | only; 256 | 257 | b. if You include all or a substantial portion of the database 258 | contents in a database in which You have Sui Generis Database 259 | Rights, then the database in which You have Sui Generis Database 260 | Rights (but not its individual contents) is Adapted Material, 261 | including for purposes of Section 3(b); and 262 | 263 | c. You must comply with the conditions in Section 3(a) if You Share 264 | all or a substantial portion of the contents of the database. 265 | 266 | For the avoidance of doubt, this Section 4 supplements and does not 267 | replace Your obligations under this Public License where the Licensed 268 | Rights include other Copyright and Similar Rights. 269 | 270 | 271 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 272 | 273 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 274 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 275 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 276 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 277 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 278 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 279 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 280 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 281 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 282 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 283 | 284 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 285 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 286 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 287 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 288 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 289 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 290 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 291 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 292 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 293 | 294 | c. The disclaimer of warranties and limitation of liability provided 295 | above shall be interpreted in a manner that, to the extent 296 | possible, most closely approximates an absolute disclaimer and 297 | waiver of all liability. 298 | 299 | 300 | Section 6 -- Term and Termination. 301 | 302 | a. This Public License applies for the term of the Copyright and 303 | Similar Rights licensed here. However, if You fail to comply with 304 | this Public License, then Your rights under this Public License 305 | terminate automatically. 306 | 307 | b. Where Your right to use the Licensed Material has terminated under 308 | Section 6(a), it reinstates: 309 | 310 | 1. automatically as of the date the violation is cured, provided 311 | it is cured within 30 days of Your discovery of the 312 | violation; or 313 | 314 | 2. upon express reinstatement by the Licensor. 315 | 316 | For the avoidance of doubt, this Section 6(b) does not affect any 317 | right the Licensor may have to seek remedies for Your violations 318 | of this Public License. 319 | 320 | c. For the avoidance of doubt, the Licensor may also offer the 321 | Licensed Material under separate terms or conditions or stop 322 | distributing the Licensed Material at any time; however, doing so 323 | will not terminate this Public License. 324 | 325 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 326 | License. 327 | 328 | 329 | Section 7 -- Other Terms and Conditions. 330 | 331 | a. The Licensor shall not be bound by any additional or different 332 | terms or conditions communicated by You unless expressly agreed. 333 | 334 | b. Any arrangements, understandings, or agreements regarding the 335 | Licensed Material not stated herein are separate from and 336 | independent of the terms and conditions of this Public License. 337 | 338 | 339 | Section 8 -- Interpretation. 340 | 341 | a. For the avoidance of doubt, this Public License does not, and 342 | shall not be interpreted to, reduce, limit, restrict, or impose 343 | conditions on any use of the Licensed Material that could lawfully 344 | be made without permission under this Public License. 345 | 346 | b. To the extent possible, if any provision of this Public License is 347 | deemed unenforceable, it shall be automatically reformed to the 348 | minimum extent necessary to make it enforceable. If the provision 349 | cannot be reformed, it shall be severed from this Public License 350 | without affecting the enforceability of the remaining terms and 351 | conditions. 352 | 353 | c. No term or condition of this Public License will be waived and no 354 | failure to comply consented to unless expressly agreed to by the 355 | Licensor. 356 | 357 | d. Nothing in this Public License constitutes or may be interpreted 358 | as a limitation upon, or waiver of, any privileges and immunities 359 | that apply to the Licensor or You, including from the legal 360 | processes of any jurisdiction or authority. --------------------------------------------------------------------------------