圖像處理
灰度反轉
公式
設 \(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);
總結
這個代碼整體也算是比較簡單,用途就是字面意思,反轉灰度值