Skip to content

About

Image binarization using otsu's method in cpp compiled to WASM for web.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

image-binarization-cpp-wasm

Image binarization using otsu's method on HTML ImageData in c++, compiled to WASM for the web.


See In action: Web Demo

  • note: Demo loads the .wasm file without the glue code.

Build

$ em++ img_processing.cpp -s ALLOW_MEMORY_GROWTH=1 -s STANDALONE_WASM -s EXPORTED_FUNCTIONS="['_otsuBinarize', '_malloc', '_free']" -Os -o img_processing.wasm

Note: when loading wasm with WebAssembly.instantiateStreaming on a local test server

  • The server must be configured to serve the .wasm file with the correct MIME type by sending the Content-Type: application/wasm header
  • Example: configured python http.server script:
import http.server, socketserver

PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler

Handler.extensions_map['.wasm'] = 'application/wasm'

with socketserver.TCPServer(("", PORT), Handler) as httpd:
    print("serving at port", PORT)
    httpd.serve_forever()

References

About

Image binarization using otsu's method in cpp compiled to WASM for web.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages