• 大小: 1KB
    文件类型: .m
    金币: 2
    下载: 2 次
    发布日期: 2021-06-15
  • 语言: Matlab
  • 标签: matlab  

资源简介

基于matlab,读取图像文件并,并计算其图像对比度。 计算公式采用:各中心像素灰度值与周围8近邻像素灰度值之差的平方之和再除以差的个数。 注:直接运行,选取路径即可输出计算结果,十分方便。适用于大量图片待计算时使用。

资源截图

代码片段和文件信息

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%计算图像对比度
%中心像素灰度值与周围8近邻像素灰度值之差的平方之和,除以以上之差的个数。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear;
clc;
format long;
[filenamepathname] = uigetfile({‘*.jpg;*.bmp;*.png‘}‘打开待测对比度的图像‘);
if filename == 0
    return;
end
pic = imread([pathnamefilename]);
[mnl] = size(pic);%求原始图像的行数m和列数n
if l>=2
    pic = rgb2gray(pic); 

评论

共有 条评论