图像处理基础

图像处理基础1、灰度变换# 灰度变换# -*- coding: utf-8 -*-from PIL import Imagefrom numpy import *from pylab import *im = array(Image.open('1.jpg').convert('L'))print (int(im.min()), int(im.max()))im2 = 255...
摘要由CSDN通过智能技术生成

图像处理基础

编译环境:Jupyter Notebook (Anaconda3)

1、灰度变换

代码
# -*- coding: utf-8 -*-
from PIL import Image
from numpy import *
from pylab import *

im = array(Image.open('1.jpg').convert('L'))
print (int(im.min()), int(im.max()))

im2 = 255 - im  # invert image
print (int(im2.min()), int(im2.max()))

im3 = (100.0/255) * im + 100  # clamp to interval 100...200
print (int(im3.min()), int(im3.max()))

im4 = 255.0 * (im/255.0)**2  # squared
print (int(im4.min()), int(im4.max()))

figure()
gray()

subplot(2, 2, 1)
imshow(im)
axis('off')
title(r'$f(x)=x$')

subplot(2, 2, 2)
imshow(im2)
axis('off')
title(r'$f(x)=255-x$')

subplot(2, 2, 3)
imshow(im3)
axis('off')
title(r'$f(x)=\frac{100}{255}x+100$')

subplot(2, 2, 4)
imshow(im4)
axis('off')
title(r'$f(x)=255(\frac{x}{255})^2$')
show()
处理结果

在这里插入图片描述

结论

调整图像灰度值后保存,输出四组图像的最小灰度值和最大灰度值并输出图像

2.1、图像轮廓直方图

代码
# 图像轮廓和直方图
from PIL import Image
from pylab import *
# 读取图像到数组中
im = array(Image.open('1.jpg').convert('L'))
# 新建一个图像
fi
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值