Canny edge detector: Difference between revisions
Content added Content deleted
(Added Go) |
|||
Line 670: | Line 670: | ||
=={{header|Go}}== |
|||
{{libheader|Imger}} |
|||
The example image for this program is the color photograph of a steam engine taken from the Wikipedia article linked to in the task description. |
|||
After applying the Canny edge detector, the resulting image is similar to but not quite the same as the Wikipedia image, probably due to differences in the parameters used though a 5×5 Gaussian filter is used in both cases. |
|||
Note that on Linux the extension of the example image file name needs to be changed from .PNG to .png in order for the library used to recognize it. |
|||
<lang go>package main |
|||
import ( |
|||
ed "github.com/Ernyoke/Imger/edgedetection" |
|||
"github.com/Ernyoke/Imger/imgio" |
|||
"log" |
|||
) |
|||
func main() { |
|||
img, err := imgio.ImreadRGBA("Valve_original_(1).png") |
|||
if err != nil { |
|||
log.Fatal("Could not read image", err) |
|||
} |
|||
cny, err := ed.CannyRGBA(img, 15, 45, 5) |
|||
if err != nil { |
|||
log.Fatal("Could not perform Canny Edge detection") |
|||
} |
|||
err = imgio.Imwrite(cny, "Valve_canny_(1).png") |
|||
if err != nil { |
|||
log.Fatal("Could not write Canny image to disk") |
|||
} |
|||
}</lang> |
|||
=={{header|J}}== |
=={{header|J}}== |