Python和MATLAB和R对比敏感度函数导图

news2024/9/23 7:26:39

🎯要点

  1. 深度学习网络两种选择的强制选择对比度检测
  2. 贝叶斯自适应估计对比敏感度函数
  3. 空间观察对比目标
  4. 量化视觉皮质感知差异
  5. 亮度、红/绿值、蓝/黄值色彩空间改变OpenCV图像对比度
  6. 对比敏感度函数模型
  7. 空间对比敏感度估计
  8. 眼球运动医学研究
  9. 空间时间颜色偏心率对比敏感度函数模型

在这里插入图片描述

JavaScript人眼颜色对比差异

  • sRGB:sRGB 是一种三刺激色彩模型,是 Web 的标准,用于大多数计算机显示器。它使用与高清电视标准 Rec709 相同的原色和白点。sRGB 与 Rec709 的区别仅在于传输曲线,通常称为伽马。
  • 伽马:这是用于存储和传输各种图像编码方法的曲线。它通常类似于人类视觉的感知曲线。在数字中,伽马的作用是赋予图像较暗区域更多权重,以便由更多位定义它们,从而避免出现诸如“带状”之类的伪影。
  • 亮度:(记为 L 或 Y):光的线性测量或表示(即无伽马曲线)。测量单位通常是 cd/m2。表示单位是 Y,如 CIEXYZ,通常为 0(黑色)至 100(白色)。亮度具有光谱加权,基于人类对不同波长光的感知。但是,亮度在明暗度方面是线性的 - 也就是说,如果 100 个光子测量值为 10,那么 20 个光子就是 200 个光子。
  • L* (又名 Lstar):感知亮度,由 CIELAB 定义 ( L ∗ a ∗ b ∗ ) \left.L^* a^* b^*\right) Lab) 其中亮度与光量呈线性关系, L ⋆ L ^{\star} L 基于感知,因此在光量方面是非线性的,其曲线旨在匹配人眼的明视觉(伽马约为 ∧ 0.43 { }^{\wedge} 0.43 0.43 )。

亮度 vs L : ∗ 0 L:^* 0 L0 和 100 在光亮(写为 Y Y Y 或 L )和亮度(写为 L ∗ L^* L )方面是相同的,但在中间它们却非常不同。我们确定的中间灰色位于 L ∗ L^* L 的中间 50 处,但这与亮度 (Y) 中的 18.4 相关。在 sRGB 中,这是 #777777 或 46.7 % 46.7 \% 46.7%

对比度:定义两个 L 或两个 Y 值之间差异的术语。对比有多种方法和标准。一种常见的方法是韦伯对比,即 Δ L / L \Delta L / L ΔL/L。对比度通常以比率 (3:1) 或百分比 (70%) 表示。

对于紫色测试示例,我使用十六进制 #9d5fb0(代表 R:157、G:95、B:176),对于绿色测试示例,我使用十六进制 #318261(代表 R:49、G:130、B:97)。

 function HexToRGB(hex) {
      hex = String(hex);
      if(hex.length==3){hex='#'+hex.substr(0, 1)+hex.substr(0, 1)+hex.substr(1, 1)+hex.substr(1, 1)+hex.substr(2, 1)+hex.substr(2, 1);}
      if(hex.length==4){hex='#'+hex.substr(1, 1)+hex.substr(1, 1)+hex.substr(2, 1)+hex.substr(2, 1)+hex.substr(3, 1)+hex.substr(3, 1);}
      if(hex.length==6){hex='#'+hex;}
      let R = parseInt(hex.substr(1, 2),16);
      let G = parseInt(hex.substr(3, 2),16);
      let B = parseInt(hex.substr(5, 2),16);
      console.log("rgb from "+hex+" = "+[R,G,B]);   
      return [R,G,B];
    }

最常见的灰度程序平均方法是:
灰度 = round ⁡ ( ( R + G + B ) / 3 ) 灰度=\operatorname{round}((R+G+B) / 3) 灰度=round((R+G+B)/3)

  function RGBToGRAY(rgb) {
      let avg = parseInt((rgb[0]+rgb[1]+rgb[2])/3);
      return [avg,avg,avg];
    }

这会将紫色变成 #8f8f8f 因为平均值 = 143,将绿色变成#5c5c5c,因为平均值 = 92。92 和 143 之间的差异太大,会错误地通过我预期的测试。

现在,正如之前所解释的,我们应该使其呈线性并应用 gamma 2.2 校正。
R ′ ∧ 2.2 = R lin ⁡ G ′ ∧ 2.2 = G lin ⁡ B ′ ∧ 2.2 = B lin ⁡ R^{\prime \wedge} 2.2=R \operatorname{lin} G^{\prime \wedge} 2.2=G \operatorname{lin} B^{\prime \wedge} 2.2=B \operatorname{lin} R2.2=RlinG2.2=GlinB2.2=Blin

  function linearFromRGB(rgb) {

      let R = rgb[0]/255.0; 
      let G = rgb[1]/255.0; 
      let B = rgb[2]/255.0; 

      let gamma = 2.2;
      R = Math.pow(R, gamma); 
      G = Math.pow(G, gamma); 
      B = Math.pow(B, gamma); 
      let linear = [R,G,B];
      console.log('linearized rgb = '+linear);  
      return linear;
    }

紫色的伽马校正线性结果现在为 R : 0.3440 、 G : 0.1139 、 B : 0.4423 R:0.3440、G:0.1139、B:0.4423 R0.3440G0.1139B0.4423,绿色的结果为 R : 0.0265 、 G : 0.2271 、 B : 0.1192 R:0.0265、G:0.2271、B:0.1192 R0.0265G0.2271B0.1192。现在通过应用系数获得亮度 L 或(XYZ 比例的 Y)如下:
Y =  Rlin*  0.2126  + Glin*  0.7152 +  Blin*  0.0722 Y=\text { Rlin* } 0.2126 \text { + Glin* } 0.7152+\text { Blin* } 0.0722 Y= Rlin* 0.2126 + Glin* 0.7152+ Blin* 0.0722

   function luminanceFromLin(rgblin) {
      let Y = (0.2126 * (rgblin[0])); 
      Y = Y + (0.7152 * (rgblin[1])); 
      Y = Y + (0.0722 * (rgblin[2]));
      console.log('luminance from linear = '+Y);       
      return Y;
    }

现在两个 Y(或 L)值之间的感知对比度:
 (L较亮 - L较暗) / (L较亮 + 0.1)  \text { (L较亮 - L较暗) / (L较亮 + 0.1) }  (L较亮 - L较暗) / (L较亮 + 0.1) 

 function perceivedContrast(Y1,Y2){
      let C = ((Math.max(Y1,Y2)-Math.min(Y1,Y2))/(Math.max(Y1,Y2)+0.1));
      console.log('perceived contrast from '+Y1+','+Y2+' = '+C); 
      return C;      
    }

现在所有上述功能合并为一步输入/输出

function perceivedContrastFromHex(hex1,hex2){
      let lin1 = linearFromRGB(HexToRGB(hex1));
      let lin2 = linearFromRGB(HexToRGB(hex2));
      let y1 = luminanceFromLin(lin1);
      let y2 = luminanceFromLin(lin2);
      return perceivedContrast(y1,y2);
    }

测试

 var P = perceivedContrastFromHex('#318261','#9d5fb0');

    alert(P);
    // shows 0.034369592139888626
  var P = perceivedContrastFromHex('#000','#fff'); 

    alert(P);
    // shows 0.9090909090909091

完整解析代码

const Color_Parser = {
  version: '1.0.0.beta',
  name: 'Color_Parser',
  result: null, 
  loging: true,
  parseHex: function(_input) {
    if (this.loging) {
      console.log(this.name + ', input: ' + _input);
    }
    this.result = {};

    if (!_input) {
      this.result.error = true;
      console.log(this.name + ', error');
      return this.result;
    }

    this.result.hex = String(_input);
    if (this.result.hex.length == 3) {
      this.result.hex = '#' + this.result.hex.substr(0, 1) + this.result.hex.substr(0, 1) + this.result.hex.substr(1, 1) + this.result.hex.substr(1, 1) + this.result.hex.substr(2, 1) + this.result.hex.substr(2, 1);
    }
    if (this.result.hex.length == 4) {
      this.result.hex = '#' + this.result.hex.substr(1, 1) + this.result.hex.substr(1, 1) + this.result.hex.substr(2, 1) + this.result.hex.substr(2, 1) + this.result.hex.substr(3, 1) + this.result.hex.substr(3, 1);
    }
    if (this.result.hex.length == 6) {
      this.result.hex = '#' + this.result.hex;
    }
    if (this.loging) {
      console.log(this.name + ', added to result: ' + this.result.hex);
    }

    this.result.rgb = {
      r: null,
      g: null,
      b: null
    };
    this.result.rgb.r = parseInt(this.result.hex.substr(1, 2), 16);
    this.result.rgb.g = parseInt(this.result.hex.substr(3, 2), 16);
    this.result.rgb.b = parseInt(this.result.hex.substr(5, 2), 16);
    if (this.loging) {
      console.log(this.name + ', added to result: ' + this.result.rgb);
    }
 
    this.result.int = ((this.result.rgb.r & 0x0ff) << 16) | ((this.result.rgb.g & 0x0ff) << 8) | (this.result.rgb.b & 0x0ff);
    if (this.loging) {
      console.log(this.name + ', added to result: ' + this.result.int);
    }

    this.result.dec = {
      r: null,
      g: null,
      b: null
    };
    this.result.dec.r = this.result.rgb.r / 255.0; 
    this.result.dec.g = this.result.rgb.g / 255.0; 
    this.result.dec.b = this.result.rgb.b / 255.0; 
    if (this.loging) {
      console.log(this.name + ', added to result: ' + this.result.dec);
    }

    this.result.lin = {
      r: null,
      g: null,
      b: null
    };
    for (var i = 0, len = 3; i < len; i++) {
      if (this.result.dec[['r', 'g', 'b'][i]] <= 0.04045) {
        this.result.lin[['r', 'g', 'b'][i]] = this.result.dec[['r', 'g', 'b'][i]] / 12.92;
      } else {
        this.result.lin[['r', 'g', 'b'][i]] = Math.pow(((this.result.dec[['r', 'g', 'b'][i]] + 0.055) / 1.055), 2.4);
      }
    }
    if (this.loging) {
      console.log(this.name + ', added to result: ' + this.result.lin);
    }

    this.result.y = (0.2126 * (this.result.lin.r)); // red channel
    this.result.y += (0.7152 * (this.result.lin.g)); // green channel
    this.result.y += (0.0722 * (this.result.lin.b)); // blue channel
    if (this.loging) {
      console.log(this.name + ', added to result: ' + this.result.y);
    }

    this.result.invert = {
      r: null,
      g: null,
      b: null,
      hex: null
    };
    this.result.invert.r = (255 - this.result.rgb.r);
    this.result.invert.g = (255 - this.result.rgb.g);
    this.result.invert.b = (255 - this.result.rgb.b);        
    this.result.invert.hex = this.result.invert.b.toString(16); 
    if (this.result.invert.hex.length < 2) {
      this.result.invert.hex = '0' + this.result.invert.hex;
    }
    this.result.invert.hex = this.result.invert.g.toString(16) + this.result.invert.hex;
    if (this.result.invert.hex.length < 4) {
      this.result.invert.hex = '0' + this.result.invert.hex;
    }
    this.result.invert.hex = this.result.invert.r.toString(16) + this.result.invert.hex;
    if (this.result.invert.hex.length < 6) {
      this.result.invert.hex = '0' + this.result.invert.hex;
    }
    this.result.invert.hex = '#' + this.result.invert.hex;
    this.result.error = false;
    if (this.loging) {
      console.log(this.name + ', final output:');
    }
    if (this.loging) {
      console.log(this.result);
    }
    return this.result;
  }
}

👉更新:亚图跨际

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2068477.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

技术债务已接管经济

“技术债务”一词通常指软件开发过程中的捷径或次优方法。它表现为设计不良的代码、缺乏文档和过时的组件。虽然正确编写的代码和文档是永恒的&#xff0c;但组件和方法却不是。随着时间的推移&#xff0c;软件及其组件可能会成为技术债务。自 40 年前的 20 世纪 80 年代软件行…

Qt使用usbcan通信

一.usbcan环境搭建 可以参照我的这篇博客&#xff1a;USBCAN-II/II使用方法以及qt操作介绍 二.项目效果展示 三.项目代码 这部分代码仅仅展示了部分功能&#xff0c;仅供参考。 #include"ControlCAN.h" #include<QDebug> #include <windows.h> #incl…

位运算,CF 878A - Short Program

目录 一、题目 1、题目描述 2、输入输出 2.1输入 2.2输出 3、原题链接 二、解题报告 1、思路分析 2、复杂度 3、代码详解 一、题目 1、题目描述 2、输入输出 2.1输入 2.2输出 3、原题链接 878A - Short Program 二、解题报告 1、思路分析 顺序处理每个操作&…

数据结构(双向链表)代码详细注释

双向链表 1》双向链表的定义 双向链表也叫双链表&#xff0c;与单向链表不同的是&#xff0c;每一个节点有三个区域组成&#xff1a;两个指针域&#xff0c;一个数据域。 前指针域&#xff1a;存储前驱节点的内存地址 后指针域&#xff1a;存储后继节点的内存地址 数据域&…

Oracle归档日志满了,导致程序打不开,如何解决。

加油&#xff0c;新时代打工人&#xff01; 归档日志错误&#xff0c;登录不上&#xff0c;只能用system 角色登录&#xff0c; 错误提示 oracle 错误257 archiver error connect internal only until freed 解决cmd进入rman RMAN&#xff08;Recovery Manager&#xff09;是一…

喜报 | 麒麟信安“信创云桌面解决方案”在浙江省委党校应用实施,荣膺国家级示范案例

近日&#xff0c;国家工信部网络安全产业发展中心公布了2023年信息技术应用创新解决方案入围获奖名单&#xff0c;麒麟信安“信创云桌面解决方案”在浙江省委党校成功应用实施&#xff0c;获评国家工信部2023年信息技术应用创新解决方案党务政务领域应用示范案例。 据悉&#…

Python、R用RFM模型、机器学习对在线教育用户行为可视化分析|附数据、代码

全文链接&#xff1a;https://tecdat.cn/?p37409 分析师&#xff1a;Chunni Wu 随着互联网的不断发展&#xff0c;各领域公司都在拓展互联网获客渠道&#xff0c;为新型互联网产品吸引新鲜活跃用户&#xff0c;刺激用户提高购买力&#xff0c;从而进一步促进企业提升综合实力和…

Linux--进程管理和性能相关工具

文章目录 进程状态进程的基本状态其他更多态运行(Running或R)可中断睡眠(Interruptible Sleep 或 S)不可中断睡眠(Uninterruptible Sleep 或 D)停止(Stopped 或 T)僵尸(Zombie 或 Z) 状态转换 进程管理相关工具进程树pstreepstree -ppstree -T 进程信息psps输出属性查看进程的父…

C语言-从键盘输入一个字符串,将其中的小写字母全部转换成大写字母,然后输出到一个磁盘文件test中保存,输人的字符串以“!”结束

题目要求&#xff1a; 从键盘输入一个字符串,将其中的小写字母全部转换成大写字母,然后输出到一个磁盘文件test中保存,输人的字符串以"!”结束 1.实现程序&#xff1a; #define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> int main() {FILE* fp fopen("…

新160个crackme - 038-Eternal Bliss.3

运行分析 需要输入注册码 PE分析 VB程序&#xff0c;32位&#xff0c;无壳 静态分析&动态调试 使用VB Decompiler静态分析&#xff0c;找到关键函数入口点402AC4 ida跳转至402AC4&#xff0c;按F5反汇编&#xff0c;发现有407行代码&#xff0c;配合VB Decompiler得到的代码…

力扣面试经典算法150题:跳跃游戏 II

跳跃游戏 II 今天的题目是力扣面试经典150题中的数组的中等难度题&#xff1a;跳跃游戏II。 题目链接&#xff1a;https://leetcode.cn/problems/jump-game-ii/description/?envTypestudy-plan-v2&envIdtop-interview-150 题目描述 给定一个非负整数数组 nums&#xff0…

springboot框架中filter过滤器的urlPatterns的匹配源码

如下图所示&#xff0c;我使用WebFilter注解的方式定义了一个过滤器&#xff0c;同时定义了过滤器的过滤条件 urlPatterns为/*,可能很多人都知道filter的/*代表所有URL都匹配&#xff0c;但是源码在哪里呢 先打断点看一下调用链 然后跟着调用链慢慢点&#xff0c;看看哪里开始…

redis面试(二十)读写锁WriteLock

写锁WriteLock 和读锁一样&#xff0c;在这个地方执行自己的lua脚本&#xff0c;我们去看一下 和read没有多大的区别 KEYS[1] anyLock ARGV[1] 30000 ARGV[2] UUID_01:threadId_01:write hget anyLock mode&#xff0c;此时肯定是没有的&#xff0c;因为根本没这个锁 …

LangGPT结构化提示词编写实践 #书生大模型实战营#

1.闯关任务&#xff1a; 背景问题&#xff1a;近期相关研究发现&#xff0c;LLM在对比浮点数字时表现不佳&#xff0c;经验证&#xff0c;internlm2-chat-1.8b (internlm2-chat-7b)也存在这一问题&#xff0c;例如认为13.8<13.11。 任务要求&#xff1a;利用LangGPT优化提示…

电脑如何恢复删除的照片?4种实用恢复办法

在日常生活中&#xff0c;我们经常会因为各种原因误删电脑中的照片&#xff0c;而这些照片往往承载着珍贵的回忆。那么&#xff0c;如果不小心删除了照片&#xff0c;我们该如何恢复呢&#xff1f;下面就为大家介绍几种实用的恢复方法。 一、使用回收站恢复 当我们在电脑上删…

【C++】单例模式的解析与应用

C单例模式&#xff1a;深入解析与实战应用 一、单例模式的基本概念二、C中单例模式的实现方式2.1 懒汉式&#xff08;线程不安全&#xff09;2.2 懒汉式&#xff08;线程安全&#xff09;2.3 饿汉式2.4 静态内部类&#xff08;C11及以后&#xff09; 三、单例模式的优缺点四、实…

基于Transformer进行乳腺癌组织病理学图像分类的方法比较

为了提高视觉变压器的精度和泛化能力,近年来出现了基于Poolingbased Vision Transformer (PiT)、卷积视觉变压器(CvT)、CrossFormer、CrossViT、NesT、MaxViT和分离式视觉变压器(SepViT)等新模型。 它们被用于BreakHis和IDC数据集上的图像分类,用于数字乳腺癌组织病理学。在B…

【机器学习】4. 相似性比较(二值化数据)与相关度(correlation)

SMC Simple Matching Coefficient 评估两组二进制数组相似性的参数 SMC (f11 f00) / (f01f10f11f00) 其中&#xff0c;f11表示两组都为1的组合个数&#xff0c;f10表示第一组为1&#xff0c;第二组为0的组合个数。 这样做会有一个缺点&#xff0c;假设是比较稀疏的数据&…

readpaper在读论文时候的默认规定

红色代表主旨思想 蓝色代表专业名词解析

如何为你的SEO策略找到竞争对手的关键词

你有没有想过你的竞争对手是如何总是设法保持领先一步的&#xff1f;或者他们似乎如何扼杀了您所在行业的大部分搜索流量&#xff1f;他们成功的秘诀可能比你想象的要简单——关键词。 在本文中&#xff0c;我们将解释如何使用 SE Ranking、Google Keyword Planner 和 Bing Ke…