有哪位兄弟知道怎么去除图像中的黑点吗,---帮帮忙

luoming 2002-12-15 12:57:10
如题
...全文
225 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Billy_Chen28 2003-01-27
  • 打赏
  • 举报
回复
procedure AnalyzeBlock(Bmp:TBitMap);
var
P1:PByteArray;
i,j,j1:Integer;
preSx,startx,starty,endx,endy,preL,length,jiange,lines:integer;
b:Byte;
Begin
Form2.ListBox2.Clear;
startx:=-1;//黑块横坐标
starty:=-1;//黑块纵坐标
endx:=-1;
length:=0;//黑块长度
jiange:=0;//黑点间隔,用于判断黑点是否干扰点
lines:=0;//黑块总数
for i:=0 to Bmp.Height-1 do
begin
P1:=Bmp.ScanLine[i];
j1:=0;
startx:=-1;
endx:=-1;
length:=0;
jiange:=0;
for j:=0 to Bmp.Width-1 do
begin
//寻找第一个黑点
if (P1[j1]=0) and (startx=-1) then
begin
startx:=j;
jiange:=0;
Inc(j1,3);
continue;
end;
//计算黑点的长度
if (P1[j1]=0) and (startx<>-1) then
begin
length:=length+1;
endx:=j;
jiange:=0;
Inc(j1,3);
continue;
end;
//计算白点长度
if (P1[j1]=255) and (startx<>-1) then
begin
jiange:=jiange+1;
end;

if jiange>9 then
begin
if length>18 then //找到了一个黑块
begin

break;
end
else
begin //干扰黑点
startx:=-1;
starty:=-1;
endx:=-1;
endy:=-1;
length:=0;
jiange:=0;
end;
end;
Inc(j1,3);
end;

if (length>18)and((abs(preL-length)>18) or (abs(preSx-startx)>50)) then
begin //增加黑块
Form2.ListBox2.Items.Add('('+inttostr(startx)+','+inttostr(endx)+','+inttostr(i)+')'+inttostr(length));
lines:=lines+1;
end;
preSx:=startx;preL:=length;
end;
Form2.ListBox2.Items.Add(inttostr(lines)+'行');
end;
c_hk 2003-01-27
  • 打赏
  • 举报
回复
中值滤波
邹工 2002-12-15
  • 打赏
  • 举报
回复
去掉黑点会有损图像.
取图像的一个小矩阵,取小矩阵的平均像素,替换掉该矩阵的中间一像素.
用这种方法扫描整幅图.
tonylk 2002-12-15
  • 打赏
  • 举报
回复
看一下图象处理相关书记中的“去噪声”。

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi GAME,图形处理/多媒体
社区管理员
  • GAME,图形处理/多媒体社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧