[数字图像处理](二)灰度图片的灰度反转

图像处理

灰度反转


公式

(g(x,y)) 为转换图像对应的 (x,y) 处的值, (f(x,y)) 为原灰度图像的值,L为灰度级数(一般为256)

(g(x,y) = L - 1 - f(x,y))

matlab实现

clc;
close all;
clear all;

imGray = imread('gray1.png');

% 直接变换
imVers = 256 - imGray - 1;
imVers = uint8(imVers);
subplot(1,1,1);
imshow(imVers);

总结

这个代码整体也算是比较简单,用途就是字面意思,反转灰度值

原文地址:https://www.cnblogs.com/hoppz/p/14634890.html