September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
17
Task/Hough-transform/Zkl/hough-transform-1.zkl
Normal file
17
Task/Hough-transform/Zkl/hough-transform-1.zkl
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
const WHITE=0xffFFff, X=0x010101;
|
||||
fcn houghTransform(image,hx=460,hy=360){
|
||||
if(hy.isOdd) hy-=1; // hy argument must be even
|
||||
out:=PPM(hx,hy,WHITE);
|
||||
rMax:=image.w.toFloat().hypot(image.h);
|
||||
dr,dTh:=rMax/(hy/2), (0.0).pi/hx;
|
||||
|
||||
foreach y,x in (image.h,image.w){
|
||||
if(image[x,y]==WHITE) continue;
|
||||
foreach iTh in (hx){
|
||||
th,r:=dTh*iTh, th.cos()*x + th.sin()*y;
|
||||
iry:=hy/2 + (r/dr + 0.5).floor(); // y==0 is top
|
||||
if(out[iTh,iry]>0) out[iTh,iry]=out[iTh,iry] - X;
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
8
Task/Hough-transform/Zkl/hough-transform-2.zkl
Normal file
8
Task/Hough-transform/Zkl/hough-transform-2.zkl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fcn readPNG2PPM(fileName){
|
||||
p:=System.popen("convert \"%s\" ppm:-".fmt(fileName),"r");
|
||||
img:=PPM.readPPM(p);
|
||||
p.close();
|
||||
img
|
||||
}
|
||||
houghTransform(readPNG2PPM("pentagon.png"))
|
||||
.write(File("pentagon_hough.ppm","wb"));
|
||||
Loading…
Add table
Add a link
Reference in a new issue