alphtrmed.m
来自「这是个滤波的算法。开发环境是 matlab很好」· M 代码 · 共 57 行
M
57 行
%% Assignment # 3 & 4% DIP @ c@se Fall 2006% Alpha Trimmed Filter%% Program Initializationsclcclose allclear all%% Reading an Image and making basic maniulations%data=imread('cameraman.tif');data=imread('pears.png');figure,imshow(data);data=rgb2gray(data);data=im2double(data);% Filter takes double the size of maskmasksize=2;% Specifications of the filterd=4;figure,imshow(data)[ro col]=size(data);temp1=[];graber=0;akkumulator=[];%% Main Module for Alpha Trimmed Mean Filterfor i=1:ro; for j=1:col; for m=-masksize:masksize; for n=-masksize:masksize; if (i+m>0 && i+m<ro && j+n>0 && j+n<col && ... % To keep indices in limit masksize+m>0 && masksize+m<ro && ... masksize+n>0 && masksize+n<col) temp1=[temp1 data(i+m,j+n)]; end end end temp1=sort(temp1); lenth=length(temp1); for k=((d/2)-1):(lenth-(d/2)) akkumulator=[akkumulator temp1(k)]; end akkumulator=sum(akkumulator); reformedimage(i,j)=(akkumulator) / (25-d); akkumulator=[]; temp1=[]; endendfigure,imshow(reformedimage)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?