话不多讲,直接上程序,代码整理如下。
clear all;
close all;
clc;
II=imread(‘sfhhff.jpg’);
subplot(241);imshow(II);title(‘原始图像’);
TT=graythresh(II);
AA=im2bw(II,TT);%自适应阀值,并使用该阀值对图像进行二值变换
subplot(242);imshow(AA,[]);title(‘阈值图像’);
subplot(243);
surf(double(II(1:8:end,1:8:end))),zlim([0 255]);title(‘原始图像surf三维可视化’);
background=imopen(II,strel(‘disk’,15));
JJ=imsubtract(II,background);
% JJ=imsubtract(II,52);%减去任意常量值,从图像的变化开始可以比较
subplot(244);imshow(JJ);title(‘去背景后的图像’);
KK=imadd(JJ,80);
subplot(245);imshow(background);title(‘背景图像’);
% subplot(245);imshow(TT);title(‘调整对比度的图像’);
subplot(246);imshow(KK);title(‘调整对比度的图像1’);
Kkk=imadd(JJ,80);
subplot(246);imshow(Kkk);title(‘调整对比度的图像2’);
% JJjj=imadd(JJ,JJ);
% subplot(247);imshow(JJjj);title(‘调整对比度的图像3’);
% jjj=imsubtract(AA,8);
% subplot(248);imshow(jjj);
CCS=immultiply(KK,1.5);%图像扩大像素,缩小也可<1
subplot(247);imshow(CCS);title(‘图像放缩像素’);
% BLL=imdivide(II,0.3);%除以任意比例后像素
% subplot(248);imshow(BLL);title(‘去除比例图’);
BLL=imdivide(JJ,0.3);%乘除均可
subplot(248);imshow(BLL);title(‘像素比例图’);
结果如下:
可以根据需要,自行修改任意参数调整。