文章目录

  • 一、出现原因
  • 二、坏点分类
  • 三、矫正方法
    • 动态矫正
      • 1.PINTO算法
      • 2.中值梯度滤波法
      • 3.DPC和demosaic结合法
      • 4.行检测法
  • 四、代码

一、出现原因

1.感光元件芯片自身工艺技术瑕疵造成以及长期使用造成的瑕疵;
2.光线采集存在缺陷;

二、坏点分类

1.hot pixel: 固定保持较高的像素值,一般呈现为画面高亮的点;
2.dead pixel: 固定保持较低的像素值,一般在画面中呈现为暗点;
3.noise pixel:信号强度随光照呈现的变化规律不符合正常的变化规律;

三、矫正方法

1.静态矫正:通常由sensor厂商在生产后进行标定,把所有坏点的坐标位置记录下来,然后矫正的时候直接通过查表得方式找到坏点进行矫正。(此种方法无法适应因长期使用造成的后期瑕疵情况)
2.动态矫正:就是在ISP算法中通过特殊得算法判断一个点是否为坏点,如果是坏点就行行矫正,否则原样输出;

动态矫正

1.PINTO算法


思想:坏点像素点比周围里亮或者暗
1.计算中心点与周围8个像素点的像素差值;
2.如果有正有负,则判断该点为正常点;
3.如果8个值全为正或者全为负值,则进行下一步判断;
4.如果8个差值的绝对值均大于阈值,则认为该点是坏点,用8个邻域像素的中位值代替该点,反之则判断该点为正常点。

算法缺点:对边缘处的坏点检测无效,因为边缘处也有较大的像素差值波动

2.中值梯度滤波法


该算法的作者针对三个通道都使用这一种窗口进行检测(Gr和Gb分开计算就是如图5*5的邻域)。思想:在边缘方向,坏点在该方向上的梯度是很高的。

具体步骤如下:

1.计算四个方向的梯度:
水平方向三个二阶梯度:Dh1 = |P1+P3-2P2|, Dh2 = |P4+P5-2Pc|,Dh3 = |P6+P8-2P7|;
数值方向三个二阶梯度:Dv1 = |P1+P6-2
P4|, Dv2 = |P2+P7-2Pc|,Dv3 = |P3+P8-2P5|;
45°三个二阶梯度:D45_1 = 2*|P4-P2|, D45_2 =|P3+P6-2Pc|, D45_3 = 2|P7-P5|;
135°三个二阶梯度: D135_1 = 2*|P2-P5|, D135_2 =|P1+P8-2Pc|, D135_3 = 2|P7-P4|;
2.取出各个方向梯度绝对值的中值median_Dh = median(Dh1,Dh2,Dh3),同理求出其他三个方向的中值;
3.求出四个中值的最小值作为边缘方向:min_grad = min(median_Dh,median_Dv,median_D45,median_D135);
4.如果最小梯度方向为水平或者竖直,若过Pc那个梯度的绝对值大于同方向的另外两个梯度绝对值和的4倍,则Pc为坏点;
5.如果是45°方向,则计算135°三个梯度绝对值两两之差的绝对值的和

如果D135_sum小于100,若此时D45_2>3x(D45_1+D45_3)且D135_2>3x(D135_1+D135_3),则Pc为坏点。如果D135_sum大于等于100,则D45_2>3x(D45_1+D45_3)就为坏点;
6.135°方向和45°相反的方向计算和判断即可;
7.为减少漏判,当Pc小于15且周围点都大于Pc40以上,则Pc为坏点。如果Pc大于230,且周围的点都下于Pc30以下,则该点为坏点;
8.边缘为水平方向,且判断为坏点,如过|P4-Pc|<|Pc-P5|则Pc更靠近P4,根据同一颜色通道亮度的渐变性可以推导出ouput=P4+(P2+P7-P1-P6)/2;否则ouput=P5+(P2+P7-P3-P8)/2;
9.如果为竖直方向可以参考水平方向求出;
10.边缘为45°,如果|P3-Pc|<|P6-Pc|则根据同一原则output=P3+(P4+P7-P2-p5)/2;否则为output=P6+(P2+P5-P7-p4)/2;
11.边缘为135°则按照45°的方式反过来计算即可。

3.DPC和demosaic结合法

先插值,变成RGB图像,再根据所估计的值和PINTO算法进行DPC

4.行检测法

根据单行或者多行数据进行检测和矫正,降低对硬件buffer的要求。

四、代码

PINTO算法代码参考https://blog.csdn.net/wtzhu_13/article/details/119077642

中值梯度滤波法

clc;clear;close all;
tic;
% --------global velue---------
expandNum = 2;
Th1 = 30;
Th2 = 40;
% --------raw parameters-------
filePath = '../images/HisiRAW_4208x3120_8bits_RGGB.raw';
bayerFormat = 'RGGB';
bayerBits = 8;
row = 4208;
col = 3120;
% -----------------------------rawData = readRaw(filePath, bayerBits, row, col);
[height, width, channel] = size(rawData);img_expand = expandRaw(rawData, expandNum);disImg = zeros(height, width);
for i = expandNum+1 : 2 : height+expandNumfor j = expandNum+1 : 2 : width+expandNum% R% get the pixel around the current R pixelaround_R_pixel = [img_expand(i-2, j-2) img_expand(i-2, j) img_expand(i-2, j+2) img_expand(i, j-2) img_expand(i, j+2) img_expand(i+2, j-2) img_expand(i+2, j) img_expand(i+2, j+2)];disImg(i-expandNum, j-expandNum) = gradJudgeDefectPixel(around_R_pixel, img_expand(i, j), Th1,Th2);% Gr% get the pixel around the current Gr pixelaround_Gr_pixel = [img_expand(i-2, j-1) img_expand(i-2, j+1)  img_expand(i-2, j+3) img_expand(i, j-1) img_expand(i, j+3) img_expand(i+2, j-1) img_expand(i-2, j+1) img_expand(i-2, j+3)];disImg(i-expandNum, j-expandNum+1) = gradJudgeDefectPixel(around_Gr_pixel, img_expand(i, j+1), Th1,Th2);% B% get the pixel around the current B pixelaround_B_pixel = [img_expand(i-1, j-1) img_expand(i-1, j+1) img_expand(i-1, j+3) img_expand(i+1, j-1) img_expand(i+1, j+3) img_expand(i+3, j-1) img_expand(i+3, j+1) img_expand(i+3, j+3)];disImg(i-expandNum+1, j-expandNum+1) = gradJudgeDefectPixel(around_B_pixel, img_expand(i+1, j+1), Th1,Th2);% Gb% get the pixel around the current Gb pixelaround_Gb_pixel = [img_expand(i-1, j-2) img_expand(i-1, j) img_expand(i-1, j+2) img_expand(i+1, j-2) img_expand(i+1, j+2) img_expand(i+3, j-2) img_expand(i+3, j) img_expand(i+2, j+2)];disImg(i-expandNum+1, j-expandNum) = gradJudgeDefectPixel(around_Gb_pixel, img_expand(i+1, j), Th1,Th2);end
end
disImg = uint8(disImg);%uint8将每个像素限定在0-255内,非整数是四舍五入变成整数。
figure();
subplot(121);
imshow(rawData);title('org');
subplot(122);
imshow(disImg);title('corrected');
disp(['cost time:',num2str(toc)])
function correctP = gradJudgeDefectPixel(aroundP, currentP,Th1,Th2)
% gradJudgeDefectPixel.m    correct the curren pixel
%   Input:
%       aroundP     the pixel around the current pixel
%       currentP    the value of current pixel
%       Th1、Th2    the threshold of the defect pixel
%   Output:
%       correctP    the corrected value of the pixel% Note: % get the median value of the around listmedianV = median(aroundP);% get the difference between the around pixel and the current pixeldiff = aroundP - ones(1, numel(aroundP)) * currentP;if(currentP>230 && (nnz(diff < 0) ==  numel(aroundP)) && length(find((abs(diff)>Th1)==1)) == numel(aroundP))correctP = medianV;return;endif(currentP<15 && (nnz(diff > 0) ==  numel(aroundP)) && length(find((abs(diff)>Th2)==1)) == numel(aroundP))correctP = medianV;return;end%梯度Dh1 = abs(aroundP(1)+aroundP(3)-2*aroundP(2));Dh2 = abs(aroundP(4)+aroundP(5)-2*currentP);Dh3 = abs(aroundP(6)+aroundP(8)-2*aroundP(7));Dv1 = abs(aroundP(1)+aroundP(6)-2*aroundP(4));Dv2 = abs(aroundP(2)+aroundP(7)-2*currentP);Dv3 = abs(aroundP(3)+aroundP(8)-2*aroundP(5));D45_1 = abs(2*(aroundP(4)-aroundP(2))); D45_2 = abs(aroundP(3)+aroundP(6)-2*currentP); D45_3 = abs(2*(aroundP(7)-aroundP(5)));D135_1 = abs(2*(aroundP(2)-aroundP(5))); D135_2 = abs(aroundP(1)+aroundP(8)-2*currentP); D135_3 = abs(2*(aroundP(7)-aroundP(4)));%中值median_Dh = median([Dh1,Dh2,Dh3]);median_Dv = median([Dv1,Dv2,Dv3]);median_D45 = median([D45_1,D45_2,D45_3]);median_D135 = median([D135_1,D135_2,D135_3]);%最小梯度[~,index] = min([median_Dh,median_Dv,median_D45,median_D135]);switch indexcase 1if(Dh2>4*(Dh1+Dh3))%坏点if(abs(aroundP(4)-currentP)<abs(currentP-aroundP(5)))correctP = (aroundP(2)+aroundP(7)-aroundP(1)-aroundP(6))/2+aroundP(4);return;elsecorrectP = (aroundP(2)+aroundP(7)-aroundP(3)-aroundP(8))/2+aroundP(5);return;endend case 2if(Dv2>4*(Dv1+Dv3))%坏点if(abs(aroundP(2)-currentP)<abs(currentP-aroundP(7)))correctP = (aroundP(4)+aroundP(5)-aroundP(1)-aroundP(3))/2+aroundP(2);return;elsecorrectP = (aroundP(4)+aroundP(5)-aroundP(6)-aroundP(8))/2+aroundP(7);return;endend case 3D135_sum = abs(D135_1-D135_2)+abs(D135_1-D135_3)+abs(D135_1-D135_3);if(D135_sum<100)%坏点if(D45_2>3*(D45_1+D45_3) && D135_2>3*(D135_1+D135_3))if(abs(aroundP(3)-currentP)<abs(currentP-aroundP(6)))correctP = (aroundP(4)+aroundP(7)-aroundP(2)-aroundP(5))/2+aroundP(3);return;elsecorrectP = (aroundP(2)+aroundP(5)-aroundP(4)-aroundP(7))/2+aroundP(6);return;endendelseif(D45_2>3*(D45_1+D45_3))if(abs(aroundP(3)-currentP)<abs(currentP-aroundP(6)))correctP = (aroundP(4)+aroundP(7)-aroundP(2)-aroundP(5))/2+aroundP(3);return;elsecorrectP = (aroundP(2)+aroundP(5)-aroundP(4)-aroundP(7))/2+aroundP(6);return;endendendcase 4D45_sum = abs(D45_1-D45_2)+abs(D45_1-D45_3)+abs(D45_1-D45_3);if(D45_sum<100)%坏点if(D135_2>3*(D135_1+D135_3) && D45_2>3*(D45_1+D45_3))if(abs(aroundP(1)-currentP)<abs(currentP-aroundP(8)))correctP = (aroundP(5)+aroundP(7)-aroundP(2)-aroundP(4))/2+aroundP(1);return;elsecorrectP = (aroundP(2)+aroundP(4)-aroundP(5)-aroundP(7))/2+aroundP(8);return;endendelseif(D135_2>3*(D135_1+D135_3))if(abs(aroundP(1)-currentP)<abs(currentP-aroundP(8)))correctP = (aroundP(5)+aroundP(7)-aroundP(2)-aroundP(4))/2+aroundP(1);return;elsecorrectP = (aroundP(2)+aroundP(4)-aroundP(5)-aroundP(7))/2+aroundP(8);return;endendendend%不是断点correctP = currentP;
end

ISP——坏点矫正(Defective Pixel Correction,DPC)相关推荐

  1. ISP——DPC(Defective Pixel Correction)

    现象 造成坏点的原因 感光元件芯片自身工艺技术瑕疵造成: 光线采集存在缺陷: 制造商产品差异: 坏点分类 hot pixel: 固定保持较高的像素值,一般呈现为画面高亮的点: dead pixel: ...

  2. isp 图像算法(二)之dead pixel correction坏点矫正

    代码在git 相机中的坏点就是那些和周围不一样的点,就是那些数值极大或者极小值点,你可以理解一张曲面的山峰或者山谷,人群中也是一样,那些与大众不一样的人就是"坏人",衡量好坏用他与 ...

  3. ISP——黑电平矫正(Black Level correction, BLC)

    文章目录 一.产生原因 二.矫正方法 1.减去固定值法 2.ISO联动法 3.曲线拟合法 一.产生原因 1.暗电流:暗电流是目标物体无光照的条件下观测到的电流.意味着无光照情况下产生电压,不是纯黑. ...

  4. ISP(图像信号处理)学习笔记-DPC坏点校正

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/xiaoyouck/article/de ...

  5. ISP_DPC坏点矫正

    ISP_DPC坏点矫正 坏点介绍 图像坏点(Bad pixel) : 图像传感器上光线采集点(像素点)所形成的阵列存在工艺上的缺陷,或光信号进行转化为电信号的过程中出现错误,从而会造成图像上像素信息错 ...

  6. 伽马矫正(Gamma correction)

    在学习HOG描述子时,对图像进行预处理中使用了伽马矫正这个方法,这里对伽马矫正进行简要的介绍. 伽马矫正也称幂律变换,一般用于平滑的扩展暗调的细节.进行伽马矫正的原因是因为人类的眼睛在感知光线时,眼睛 ...

  7. DPC(Defect Pixel Correction)——坏点检测

    产生原因 校正方法 代码 PINTO算法 readRAW function rawData = readRaw(fileName, bitsNum, row, col) % readRaw.m get ...

  8. 图像处理_ISP_坏点矫正

    1 坏点介绍 图像坏点(Bad pixel) : 图像传感器上光线采集点(像素点)所形成的阵列存在工艺上的缺陷,或光信号进行转化为电信号的过程中出现错误,从而会造成图像上像素信息错误,导致图像中的像素 ...

  9. ISP中gamma矫正模块的FPGA设计和仿真

    pangpang最近耗费很久的时间写了一个ISP中的gamma矫正模块,写下本文记录一下. 目录 1.gamma矫正介绍 2.本文gamma矫正设计要求 3.设计过程 4.仿真验证 5.总结 1.ga ...

最新文章

  1. 1月4日链接篇:ASP.NET, ASP.NET AJAX, ASP.NET MVC, Visual Studio, IIS7
  2. Oracle 数据库连接失败问题
  3. gin-vue-blog自建博客
  4. php include file_包含与被包含(PHP include文件)
  5. python省市区三级联动_Django Admin实现三级联动的示例代码(省市区)
  6. SSH启动失败解决方法
  7. 交流电机数字控制系统_干货 | 简述伺服电机和步进电机的六大性能差异
  8. python对八大常见排序算法的总结和实现以及时间消耗分析
  9. 完整记录一则Oracle 11.2.0.4单实例打PSU补丁的过程
  10. python opencv 身份证照片识别,包含正面、反面(附完整代码,可直接使用)
  11. Centos7配置阿里YUM源
  12. 用python做乘法口诀表_如何用python编写乘法口诀表
  13. 如何确保数据的准确性
  14. Matplotlib 绘图 (二)
  15. 用matlab画脑图,思维导图怎么画,画出一副好看的流程图方法是什么
  16. 化工集团公司数字化转型有力抓手“数字化示范项目建设
  17. COMSOL中场路耦合(电路接口与电磁场接口)
  18. 计算机专业英语被动语态举例,高考英语各种时态被动语态总结
  19. 涨停缩量平台调整选股策略(附筛选python代码)
  20. 用pecl命令安装php扩展geoip

热门文章

  1. Windows获取模块基地址
  2. 云计算、社交网络和移动互联网------转自月光博客
  3. 织梦Dedecms主要文件夹目录及模板文件说明
  4. VPX高速信号处理板设计资料第240篇:4C6678_K7_DDR3_VPX高速信号处理板
  5. 用python实现判断9*9数独的正确性
  6. 我的形码输入法[C语言] 之一:输入法的字词编码
  7. Apache PdfBox 2.0.X 版本解析PDF文档(文字和图片)
  8. Herb Sutter简介
  9. python之文件操作、对.txt文本文件的操作(读、写、修改、复制、合并)、对json文本文件的操作、json字符串与字典的相互转换。
  10. STM32之BKP原理