早教吧作业答案频道 -->英语-->
Hough变换对圆的检测运行一直出现Center251radius20InanassignmentA(:,matrix)=B,thenumbclc,clearallI=imread('e:\2.bmp');[m,n,l]=size(I);ifl>1I=rgb2gray(I);endBW=edge(I,'sobel');stepr=1;stepangle=0.1;minr=20;maxr
题目详情
Hough变换对圆的检测 运行一直出现Center 25 1 radius 20 In an assignment A(:,matrix) = B,the numb
clc,clear all
I = imread('e:\2.bmp');
[m,n,l] = size(I);
if l>1
I = rgb2gray(I);
end
BW = edge(I,'sobel');
step_r = 1;
step_angle = 0.1;
minr = 20;
maxr = 30;
thresh = 0.7;
[hough_space,hough_circle,para] = hough_circle(BW,step_r,step_angle,minr,maxr,thresh);
subplot(221),imshow(I),title('原图')
subplot(222),imshow(BW),title('边缘')
subplot(223),imshow(hough_circle),title('检测结果')
function [hough_space,hough_circle,para] = hough_circle(BW,step_r,step_angle,r_min,r_max,p)
% %%%%%%%%%%%%%%%%%%%%%%%%%%
% input
% BW:二值图像;
% step_r:检测的圆半径步长
% step_angle:角度步长,单位为弧度
% r_min:最小圆半径
% r_max:最大圆半径
% p:阈值,0,1之间的数
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% output
% hough_space:参数空间,h(a,b,r)表示圆心在(a,b)半径为r的圆上的点数
% hough_circl:二值图像,检测到的圆
% para:检测到的圆的圆心、半径
[m,n] = size(BW); %求出图像大小
size_r = round((r_max-r_min)/step_r)+1; %round 作用四舍五入 对圆半径步长四舍五入
size_angle = round(2*pi/step_angle); %
hough_space = zeros(m,n,size_r); %创建一个矩阵
[rows,cols] = find(BW); %返回矩阵BW中非零元素的行和列的索引值
ecount = size(rows); %rows 有多少个
% Hough变换
% 将图像空间(x,y)对应到参数空间(a,b,r)
% a = x-r*cos(angle)
% b = y-r*sin(angle)
for i=1:ecount
for r=1:size_r
for k=1:size_angle
a = round(rows(i)-(r_min+(r-1)*step_r)*cos(k*step_angle));
b = round(cols(i)-(r_min+(r-1)*step_r)*sin(k*step_angle));
if(a>0&a0&b=max_ow*p);
length = size(index);
hough_circle = false(m,n);
for i=1:ecount
for k=1:length
par3 = floor(index(k)/(m*n))+1;
par2 = floor((index(k)-(par3-1)*(m*n))/m)+1;
par1 = index(k)-(par3-1)*(m*n)-(par2-1)*m;
if((rows(i)-par1)^2+(cols(i)-par2)^2(r_min+(par3-1)*step_r)^2-5)
hough_circle(rows(i),cols(i)) = true;
end
end
end
% 打印检测结果
for k=1:length
par3 = floor(index(k)/(m*n))+1;
par2 = floor((index(k)-(par3-1)*(m*n))/m)+1;
par1 = index(k)-(par3-1)*(m*n)-(par2-1)*m;
par3 = r_min+(par3-1)*step_r;
fprintf(1,'Center %d %d radius %d\n',par1,par2,par3);
para(:,k) = [par1,par2,par3];
end
网上大家都是用这个程序,但是我的一直运行不了
每次都出现
Center 25 1 radius 20
In an assignment A(:,matrix) = B,the number of elements in the subscript of A and the number
of columns in B must be the same.
万分感激.
clc,clear all
I = imread('e:\2.bmp');
[m,n,l] = size(I);
if l>1
I = rgb2gray(I);
end
BW = edge(I,'sobel');
step_r = 1;
step_angle = 0.1;
minr = 20;
maxr = 30;
thresh = 0.7;
[hough_space,hough_circle,para] = hough_circle(BW,step_r,step_angle,minr,maxr,thresh);
subplot(221),imshow(I),title('原图')
subplot(222),imshow(BW),title('边缘')
subplot(223),imshow(hough_circle),title('检测结果')
function [hough_space,hough_circle,para] = hough_circle(BW,step_r,step_angle,r_min,r_max,p)
% %%%%%%%%%%%%%%%%%%%%%%%%%%
% input
% BW:二值图像;
% step_r:检测的圆半径步长
% step_angle:角度步长,单位为弧度
% r_min:最小圆半径
% r_max:最大圆半径
% p:阈值,0,1之间的数
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% output
% hough_space:参数空间,h(a,b,r)表示圆心在(a,b)半径为r的圆上的点数
% hough_circl:二值图像,检测到的圆
% para:检测到的圆的圆心、半径
[m,n] = size(BW); %求出图像大小
size_r = round((r_max-r_min)/step_r)+1; %round 作用四舍五入 对圆半径步长四舍五入
size_angle = round(2*pi/step_angle); %
hough_space = zeros(m,n,size_r); %创建一个矩阵
[rows,cols] = find(BW); %返回矩阵BW中非零元素的行和列的索引值
ecount = size(rows); %rows 有多少个
% Hough变换
% 将图像空间(x,y)对应到参数空间(a,b,r)
% a = x-r*cos(angle)
% b = y-r*sin(angle)
for i=1:ecount
for r=1:size_r
for k=1:size_angle
a = round(rows(i)-(r_min+(r-1)*step_r)*cos(k*step_angle));
b = round(cols(i)-(r_min+(r-1)*step_r)*sin(k*step_angle));
if(a>0&a0&b=max_ow*p);
length = size(index);
hough_circle = false(m,n);
for i=1:ecount
for k=1:length
par3 = floor(index(k)/(m*n))+1;
par2 = floor((index(k)-(par3-1)*(m*n))/m)+1;
par1 = index(k)-(par3-1)*(m*n)-(par2-1)*m;
if((rows(i)-par1)^2+(cols(i)-par2)^2(r_min+(par3-1)*step_r)^2-5)
hough_circle(rows(i),cols(i)) = true;
end
end
end
% 打印检测结果
for k=1:length
par3 = floor(index(k)/(m*n))+1;
par2 = floor((index(k)-(par3-1)*(m*n))/m)+1;
par1 = index(k)-(par3-1)*(m*n)-(par2-1)*m;
par3 = r_min+(par3-1)*step_r;
fprintf(1,'Center %d %d radius %d\n',par1,par2,par3);
para(:,k) = [par1,par2,par3];
end
网上大家都是用这个程序,但是我的一直运行不了
每次都出现
Center 25 1 radius 20
In an assignment A(:,matrix) = B,the number of elements in the subscript of A and the number
of columns in B must be the same.
万分感激.
▼优质解答
答案和解析
[hough_space,hough_circle,para] = hough_circle(BW,step_r,step_angle,minr,maxr,thresh);
运行这一句的时候显示 ? Undefined function or method 'hough_circle'
for input arguments of type 'double'.应该怎么改正啊 ?
运行这一句的时候显示 ? Undefined function or method 'hough_circle'
for input arguments of type 'double'.应该怎么改正啊 ?
看了Hough变换对圆的检测运行一...的网友还看了以下:
设函数fn(x)=xn+bx+c(n∈N+,b,c∈R)(1)设n≥2,b=1,c=-1,证明:设函 2020-03-30 …
设A为n(n>=2)阶方阵,证明当r(A)=n时,r(A*)=n当r(A)=2)阶方阵,证明当r( 2020-05-14 …
lim(n->无穷)p(1+r/n)^(nt)=lim(n->无穷)p[(1+r/n)^(n/r) 2020-06-14 …
1将参数方程x=1+2cosay=2sina化为普通方程,所得方程是?2集合M=((x,y)x^2 2020-07-09 …
在实数集中随机取一数m,则m为超越数的概率为多少?RT.我也觉得是1我想这么说明:π+n(n∈R) 2020-07-30 …
下列对应关系是从集合M到集合N的一一映射的是()A.M=N=R,f:x→y=-1x,x∈M,y∈N 2020-07-30 …
级数Σ[(-1)^n][n/2^n][(x-1)^2n]当n趋于无穷时lim|Un|^(1/n)= 2020-07-31 …
用数学归纳法证明1+r+r2+…+rn=1-rn+11-r(n∈N,r≠1),在验证n=0时,左端 2020-08-01 …
辗转相除法中包含重复操作的步骤,因此可以用循环结构来构造算法.算法步骤如下:第一步,给定两个正整数 2020-08-03 …
辗转相除法中包含重复操作的步骤,因此可以用循环结构来构造算法.算法步骤如下:第一步,给定两个正整数m 2020-12-31 …