matlab程序代码 关于医学图像分割处理 边缘检测 阈值法

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

matlab程序代码关于医学图像分割处理边缘检测阈值法

图像分割程序:% 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 image; color 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算子

边缘检测图像 ');

相关文档
最新文档