5.22 图像预处理之图像转换

*图像线性变换

*Y=kX+B 这个是对灰度值之间的转换 k表示系数,B表示偏移,X表示变换之前的灰度值, Y表示变换之后的灰度值

read_image (Image, 'clip')

*线性变换
scale_image (Image, ImageScaled, 0.01, 0)

*将所有的灰度值拉伸到0-255范围
scale_image_max (ImageScaled, ImageScaleMax)

*图像直方图均衡化

equ_histo_image (Image, ImageEquHisto)

*图像增强
*黑的更黑,白的更白
emphasize (Image, ImageEmphasize, 7, 7, 1)

*黑的变白一点儿,白的变黑一点儿
illuminate (Image, ImageIlluminate, 101, 101, 0.7)

*黑变白,白变黑 Y=255-X
invert_image (Image, ImageInvert)

*图像的算术:加减乘除
add_image (Image, ImageInvert, ImageWhite, 1, 0)

add_image (Image, ImageInvert, ImageBlack, 0, 0)

sub_image (ImageBlack, Image, ImageSub, 1, 0)

sub_image (ImageWhite, Image, ImageSub1, 1, 0)

mult_image (Image, Image, ImageResult, 1, 0)

div_image (Image, Image, ImageResult1, 255, 0)

*采图转灰度图
read_image (Image1, 'cable2')

decompose3 (Image1, Red, Green, Blue)

compose3 (Red, Green, Blue, MultiChannelImage)

rgb1_to_gray (Image1, GrayImage)

*图像旋转 顺时针为负,逆时针为正
rotate_image (Image1, ImageRotate, -90, 'constant')

*图像镜像
mirror_image (Image1, ImageMirror, 'row')

*图像缩放
zoom_image_factor (Image1, ImageZoomed, 0.5, 0.5, 'constant')

zoom_image_size (ImageZoomed, ImageZoom, 512, 512, 'constant')

posted @ 2026-09-09 11:51  浮云1  阅读(5)  评论(0)    收藏  举报