Jump to content

Example:Hough transform/C: Difference between revisions

m
Fixed syntax highlighting.
(Transfer example from task:Hough transform)
m (Fixed syntax highlighting.)
 
Line 1:
==={{Programming-example-page|Hough transform|language=C}}===
{{trans|Tcl}}
 
(Tested only with the pentagon image given)
<langsyntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
Line 118:
 
return EXIT_SUCCESS;
}</langsyntaxhighlight>
 
Output image (but with white background):
Line 125:
<br style="clear:both" />
 
=== Alternative version ===
 
[[file:penta-hugh.png|thumb]][[file:hugh-lines-in.png|thumb]][[file:hugh-lines-out.png|thumb]]
This code is a little to long to my liking, because I had to put some ad hoc stuff that should be better served by libraries. But you don't want to see libpng code here, trust me.
<langsyntaxhighlight Clang="c">#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Line 380:
/* not going to free memory we used: OS can deal with it */
return 0;
}</langsyntaxhighlight>
This program takes a pnm file (binary, either P5 or P6) and does the transformation, then dump output onto stdout. Sample images below are output from the pentagram; sample lines with added noise; output of processing that. Both output were with 1.5 gamma.
9,483

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.