
% This is a program for extracting objects from an image. Written for vehicle number plate segmentation and extraction
% Authors : Jeny Rajan, Chandrashekar P S
% U can use attached test image for testing
% input - give the image file name as input. eg :- car3.jpg
clc
clear all
k=input('Enter the file name','s')% input imagecolor image
im=imread(k)
im1=rgb2gray(im)
im1=medfilt2(im1,[3 3])%Median filtering the image to remove noise%
BW = edge(im1,'sobel')%finding edges
[imx,imy]=size(BW)
msk=[0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0]
B=conv2(double(BW),double(msk))%Smoothing image to reduce the number of connected components
L = bwlabel(B,8)% Calculating connected components
mx=max(max(L))
% There will be mx connected components.Here U can give a value between 1 and mx for L or in a loop you can extract all connected components
% If you are using the attached car image, by giving 17,18,19,22,27,28 to L you can extract the number plate completely.
[r,c] = find(L==17)
rc = [r c]
[sx sy]=size(rc)
n1=zeros(imx,imy)
for i=1:sx
x1=rc(i,1)
y1=rc(i,2)
n1(x1,y1)=255
end % Storing the extracted image in an array
figure,imshow(im)
figure,imshow(im1)
figure,imshow(B)
figure,imshow(n1,[])
边缘检测:
I=imread('lena.jpg')
imshow(I)
title('原始图像'雹团)
BW1= edge(I,'Canny',0.00) %edge调用Canny为检测算子判别阈值为0.00
figure,imshow(BW1)
title( '阈值为0.00的Canny算子边缘检测图像 ')
BW2= edge(I,'Canny',0.05) %edge调用Canny为检测算子判别阈值源派橘为0.05
figure,imshow(BW2)
title( '阈值为0.05的Canny算子边缘检测图像')
BW20= edge(I,'Canny',0.1) %edge调用Canny为检测算子判别阈值为0.1
figure,imshow(BW20)
title( '阈值为0.1的Canny算子边缘检测图像')
BW21= edge(I,'Canny',0.2) %edge调用Canny为检测算子判别阈值为0.2
figure,imshow(BW21)
title( '阈值为0.2的Canny算子边缘检测图像 ')
BW22= edge(I,'Canny',0.3) %edge调用Canny为检测算子判别阈羡销值为0.3
figure,imshow(BW22)
title( '阈值为0.3的Canny算子边缘检测图像 ')
图像分割是前期的团茄宴工作重点,主要使用了现成的软件来完成图像分割任务:3DMed(中国科学院自动化医学图像处理研究所)。
该软件集成了6种分割算法插件,按照官方文档的说法,区域生长算法特别适合于分割小的结构如肿瘤和伤疤,下面是使用3DMed加载的原始29189000016.dcm图像:
下面是使用区域生长算法对肿瘤的分割结果:
其中Different Value和Change Value为控制区域增长的两个参数,通过实验发现选取2和10效果较好。
下面是分割后的保存结果:
3DMed中会自动将结果文件名保存为29189000016_segmented.dcm。
但是该算法需要人工交互获得种子节点,自动化程度不高。同时区域增长算法对噪声敏感,导致抽取出的区域有空洞或者无法正确抽取出感兴趣区域。
特征提取就是从分割的区域中提取出描述该区域特征的一些数据,这一步的工作使用了两种方法进行探索。
使用MATLAB进行常用的基本统计特征的提取,该方法可以提取出 一阶统计特征 (描述感兴趣区域内各提速参数的分布,通常是基于直方图进行分析),在MATLAB中简单的区域描绘如下:
l 周长:区域边界的长度, 即位于区域边界上的像素数目.
l 面积:, 区域中的像素总数.
l 致密性:(周长) 2/面积.
l 区域的质心.
l 灰度均值: 区域中所有像塌银素的平均值.
l 灰度中值: 区域中所有像素的排序中值.
l 包含区域的最小矩形.
l 最小或最大灰度级.
l 大于或小于均值的像素数.
l 欧拉数: 区域中的对象数减去这些对象的孔洞数。
MATLAB中的regionprops(L, properties)函数可以用来计算区域描绘特征:首先使用bwlabel(I, n)对图像I进行n(4或者8)连通标号,然后使用regionprops()进行统计计算。
Mazda是一个图像纹理分析的工具,可以自动对图像进行特征提取。下面是使用Mazda加载分割好的结果:
下面是对分割结果进行特征提取的结果:
对于Feature name的表示现在还没有完全搞明白,正在研究。
Mazda还可以进行 高阶统计量 的提取(就是进一步加入了过滤器),小波分析纳贺就是高阶统计量的一种,下面是小波分析的结果:
同时可以手动对Features进行feature selection,然后保存选择的结果。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)