通过鼠标选择所需检测点,然后将离检测点最近的外边缘框出。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 384520 2016-01-21 10:19 1.jpg
文件 429044 2016-01-21 10:20 10.jpg
文件 239889 2016-01-21 10:19 3.jpg
文件 239889 2016-01-21 10:19 5.jpg
文件 223057 2016-01-21 10:20 6.jpg
文件 384520 2016-01-21 10:20 9.jpg
文件 2468 2016-02-27 09:26 bianyuan.m
clear all
I = imread(‘1.jpg‘);
im = rgb2gray(I);
figure(1)
imshow(I‘border‘‘tight‘‘initialmagnification‘‘fit‘);
axis normal
% x=800;y=1000;
[yxbutton] = ginput(1);
thresh = graythresh(im);
im2 = im2bw(imthresh);
im = double(im);
u = (im/thresh).^2;
ft = find(im>thresh);
ma = max(im(:));
u(ft) = ((ma-im(ft))/(ma-thresh)).^2;
% imshow(uint8(im));
r = 4;
temp = u;
[hl] = size(im);
uc = 0.99;
if r>=2
for k = 1:r
for i = 1:h
for j = 1:l
if temp(ij) <= uc
temp(ij) = temp(ij).^2/uc;
else
temp(ij) = 1-(1-temp(ij).^2)/(1-uc);
end
end
end
end
end
X1 = thresh*sqrt(temp);
X1(ft) = ma-sqrt(temp(ft))*(ma-thresh);
X2 = X1-min(X1(:));
f = edge(uint8(X2)‘canny‘);
f = imfill(f‘hole‘);
str = strel(‘disk‘5);
ima = imdilate(fstr);
ima = imerode(imastr);
ima = bwareaopen(ima300);
x = fix(x);
y = fix(y);
if(ima(xy)==0)
ima = ~ima;
end
[Lm]= bwlabel(ima8);
ima_temp = zeros(hl);
mm = L(xy);
ft = find(L==mm);
ima_temp(ft) = 1;
ima_temp = imfill(ima_temp‘hole‘);
xx = bwperim(ima_temp);
count = 0;
xi = cell(1);
yi = cell(1);
for i=1:h
for j=1:l
if xx(ij)==1;
count = count+1;
xi{1}(count) = i;
yi{1}(count) = j;
end
end
end
xx = xi{1}(:);
yy = yi{1}(:);
imshow(I);
hold on
% xx = [xx(:);xx(1)];
plot([yy;yy(1)][xx;xx(1)]‘.r‘)
% if m~=0
% for ii=1:m
% rectangle(‘position‘status(ii).BoundingBox‘edgecolor‘‘r‘);
% end
% end
% for i = 1:500
% rectangle(‘Position‘[x-i/2y-i/2ii]‘curvature‘[00]‘edgecolor‘‘r‘);
% end
% px = fix(x);
% py_but = fix(y);
% py_top = fix(y);
% while(1)
% if f(pxpy_top)~=1
% py_top = py_top-1;
% elseif py_top ==0
% break;
% else
% break;
% end
% end
% while(1)
% if f(pxpy_but)~=1
% py_but = py_but-1;
% elseif py_but ==l
% break;
% else
% break;
% end
% end
% figure(1)
% imshow(ima);
% hold on
%
% plot(py_toppy_but‘r‘);
% a=cell(1);
% b =cell(1);
% count = 1;
% ed=[-1 -1;0 -1;1 -1;1 0;1 1;0 1;-1 1;-1 0]; %从左上角像素,逆时针搜索
% imgn=zeros(hl); %边界标记图像
% imgn(pxpy) = 2;
% while(1)
% a{1}(count) = px;
% b{1}(count) = py;
%
% for k = 1:8
% tmpi = a{1}(count)+ed(k1); %八邻域临时坐标
% tmpj = b{1}(count)+ed(k2);
% if f
% end
% count = count+1;
% end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 384520 2016-01-21 10:19 1.jpg
文件 429044 2016-01-21 10:20 10.jpg
文件 239889 2016-01-21 10:19 3.jpg
文件 239889 2016-01-21 10:19 5.jpg
文件 223057 2016-01-21 10:20 6.jpg
文件 384520 2016-01-21 10:20 9.jpg
文件 2468 2016-02-27 09:26 bianyuan.m
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)