当前位置:网站首页>Matlab low-level source code realizes the median filtering of the image (used to eliminate some miscellaneous points on the image)
Matlab low-level source code realizes the median filtering of the image (used to eliminate some miscellaneous points on the image)
2022-07-27 10:20:00 【Handwriting meets unexpectedly】
Theoretical basis
An image is often disturbed by various noises , The noise is often some isolated pixels , It is often random noise superimposed on the image , Make the image polluted like snowflakes , The gray level of the image should be relatively continuous , Generally, it will not suddenly become larger or smaller , This kind of noise can be suppressed by neighborhood .
N.N Median filtering algorithm , When gray image f China and Israel f(i,j) Centred N.N Screen the window (N It's odd ) The inner median gray scale is a when , Unconditionally will f(i,j)=a Handle ,N Given by the user .
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%N*N median filtering
%Author:Zhu
% Time :2022.3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;
image = imread("E:\\1.jpg");
image_matrix=image(:,:,1);
image_matrix=double(image_matrix);
[height,width,channels]=size(image);
% Enter the value , Set the window size ( The size must be odd )
maskWidth = 5;
maskHeight = 5;
% It's usually an odd number
maskCenterX=(maskWidth+1)/2;
maskCenterY=(maskHeight+1)/2;
% Find the median size in the array
maskValue=zeros(1,maskHeight*maskWidth);
% Sequence number in the middle of the array
middleNum = maskHeight*maskWidth/2+0.5;
for i=maskCenterY:1:height-maskHeight+maskCenterY
for j=maskCenterX:1:width-maskWidth+maskCenterX
% Calculate the pixel value
pixelResult = 0;
% Traverse the template area
for k=1:1:maskHeight
for p = 1:1:maskWidth
% Put the value into the array
maskValue((k-1)*maskHeight+p) = image_matrix(i-(maskHeight+1)/2+k,j-(maskWidth+1)/2+p);
end
end
% Find the value in the array , Bubble sorting method , Arrange the values from large to small
for num = 1:maskHeight*maskWidth
for xx = 1:maskHeight*maskWidth-1
if(maskValue(xx)<maskValue(xx+1))
temp = maskValue(xx);
maskValue(xx) = maskValue(xx+1);
maskValue(xx+1) = temp;
end
end
end
% Update the median to give the current pixel
image_matrix(i,j)= maskValue(middleNum);
end
end
image_out = uint8(image_matrix);
% Show
subplot(1,2,1);
imshow(image);
subplot(1,2,2);
imshow(image_out);
Realization effect

边栏推荐
- Oracle查看硬解析
- mount.nfs: access denied by server while mounting解决
- 文件上传漏洞绕过方法
- Snowflake vs. databricks who is better? The latest war report in 2022
- NVIDIA geforce experience login error: the verifier failed to load. Please check your browser settings, such as the advertisement interceptor (solution)
- Matlab-绘制日期和持续时间图
- 解决ORCLE-ORA-01122 01110 01210
- pytorch中对BatchNorm2d()函数的理解
- Matlab底层源代码实现图像的中值滤波(用于消除图像上一些杂点)
- There is no CUDA option in vs2019+cuda11.1 new project
猜你喜欢

安装CUDA失败的情况nsight visual studio edition失败

Practice and exploration of overseas site Seata of ant group

Acl2021 best paper released, from ByteDance

StyleGAN论文笔记+修改代码尝试3D点云生成

wind10配置adb命令

Pygame: alien invasion

Review of in vivo detection

Understanding and code implementation of Se (sequence and exception) module

pytorch的安装(非常详细)

Metaaploit-后渗透技知识
随机推荐
hdu5288(OO’s Sequence)
视觉SLAM十四讲笔记(一):第一讲+第二讲
How does data analysis solve business problems? Here is a super detailed introduction
sql注入
Stylegan paper notes + modify code to try 3D point cloud generation
matlab-绘制分叉与混沌分支图
wind10配置adb命令
FTP 服务器
Leetcode.1260. 2D grid migration____ In situ violence / dimensionality reduction + direct positioning of circular array
Anaconda安装(非常详细)
Matlab的不同进制转换
Shell综合应用案例,归档文件、发送消息
Shell variables, system predefined variables $home, $pwd, $shell, $user, custom variables, special variables $n, $, $*, [email protected],
vs2019社区版下载教程(详细)
Data visualization
Pygame: alien invasion
3D face reconstruction and dense alignment with position map progression network
Program translation and execution, from editing, preprocessing, compilation, assembly, linking to execution
邮件服务器
3D人脸重建:Joint 3D Face Reconstruction and Dense Alignment with position Map Regression Network