{"id":28194458,"url":"https://github.com/selcuksert/edge-detection","last_synced_at":"2025-05-16T13:12:17.833Z","repository":{"id":291365736,"uuid":"974452764","full_name":"selcuksert/edge-detection","owner":"selcuksert","description":"A high-performance Java application that implements edge detection using the Sobel operator and TornadoVM","archived":false,"fork":false,"pushed_at":"2025-05-04T06:13:47.000Z","size":5886,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-04T07:18:31.684Z","etag":null,"topics":["edge-detection","hardware-acceleration","image-processing","java","sobel-operator","tornadovm"],"latest_commit_sha":null,"homepage":"https://medium.com/@selcuk.sert/accelerating-java-with-tornadovm-14e3c8b2695f","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/selcuksert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-28T19:56:46.000Z","updated_at":"2025-05-04T06:13:50.000Z","dependencies_parsed_at":"2025-05-04T07:28:46.869Z","dependency_job_id":null,"html_url":"https://github.com/selcuksert/edge-detection","commit_stats":null,"previous_names":["selcuksert/edge-detection"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selcuksert%2Fedge-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selcuksert%2Fedge-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selcuksert%2Fedge-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/selcuksert%2Fedge-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/selcuksert","download_url":"https://codeload.github.com/selcuksert/edge-detection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254535795,"owners_count":22087400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["edge-detection","hardware-acceleration","image-processing","java","sobel-operator","tornadovm"],"created_at":"2025-05-16T13:12:12.346Z","updated_at":"2025-05-16T13:12:17.822Z","avatar_url":"https://github.com/selcuksert.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Edge Detection with Sobel Method\n\nA high-performance Java application that implements edge detection using the Sobel operator. This project showcases the power of modern Java features by implementing both standard CPU processing and hardware-accelerated processing using [TornadoVM](https://www.tornadovm.org/).\n\n![snapshot](/docs/snapshot.png)\n\nThe project is implemented as a PoC for Medium article [Accelerating Java with TornadoVM](https://medium.com/@selcuk.sert/accelerating-java-with-tornadovm-14e3c8b2695f).\n\n## Overview\n\nThis application provides edge detection functionality using the Sobel operator with two different implementation approaches:\n- Standard CPU-based processing (`SobelStandard`)\n- Hardware-accelerated processing using TornadoVM (`SobelTornado`)\n\nThe application features a JavaFX-based GUI for easy interaction and real-time image processing visualization.\n\n## Prerequisites\n\n- Java Development Kit (JDK) 21 or later\n- Maven 3.x\n- TornadoVM 1.1.0 runtime\n- Graphics card supporting OpenCL (for TornadoVM acceleration)\n\n## Installing TornadoVM\n\n[Instructions](https://tornadovm.readthedocs.io/en/latest/installation.html#installation-configuration) from the official site can be used.\n\nAs an example for existing Eclipse Temurin JDK 21 on a macOS:\n\n1. Clone TornadoVM repo and run installation script:\n   ```shell\n   cd /usr/local/share/\n   git clone https://github.com/beehive-lab/TornadoVM.git\n   cd TornadoVM\n   ./bin/tornadovm-installer --jdk temurin-jdk-21 --javaHome $JAVA_HOME --backend opencl\n   ```\n2. The following prompt should be displayed on console:\n   ```text\n   ###########################################################################\n   Tornado build success\n   Updating PATH and TORNADO_SDK to tornado-sdk-....\n   Commit  : ....\n   ###########################################################################\n   ------------------------------------------\n          TornadoVM installation done        \n   ------------------------------------------\n   Creating source file ......................\n   ........................................[ok]\n   ```\n3. Append the following line to `~/.zshrc` for environment settings:\n   ```text\n   # Set TornadoVM variables\n   source /usr/local/share/TornadoVM/setvars.sh\n   ```\n4. On a new terminal shell list accelerator devices available to TornadoVM:\n   ```shell\n   tornado --devices\n   ```\n   An output like this should be displayed:\n   ```text\n   Number of Tornado drivers: 1\n   Driver: OpenCL\n   Total number of OpenCL devices  : 3\n   Tornado device=0:0  (DEFAULT)\n   OPENCL --  [Apple] -- Intel(R) UHD Graphics 630\n   Global Memory Size: 1,5 GB\n   Local Memory Size: 64,0 KB\n   Workgroup Dimensions: 3\n   Total Number of Block Threads: [256]\n   Max WorkGroup Configuration: [256, 256, 256]\n   Device OpenCL C version: OpenCL C 1.2\n   \n   Tornado device=0:1\n   OPENCL --  [Apple] -- AMD Radeon Pro 5500M Compute Engine\n   Global Memory Size: 4,0 GB\n   Local Memory Size: 64,0 KB\n   Workgroup Dimensions: 3\n   Total Number of Block Threads: [256]\n   Max WorkGroup Configuration: [256, 256, 256]\n   Device OpenCL C version: OpenCL C 1.2\n   \n   Tornado device=0:2\n   OPENCL --  [Apple] -- Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz\n   Global Memory Size: 32,0 GB\n   Local Memory Size: 32,0 KB\n   Workgroup Dimensions: 3\n   Total Number of Block Threads: [1024]\n   Max WorkGroup Configuration: [1024, 1, 1]\n   Device OpenCL C version: OpenCL C 1.2\n   ```\n5. Run TornadoVM unit tests with the following JVM parameters as a workaround if you are using Turkish locale ([issue](https://github.com/beehive-lab/TornadoVM/issues/605) filed to project):\n   ```shell\n   tornado-test -V --jvm=\"-Duser.country=US -Duser.language=en\"\n   ```\n   Run a specific example to test installation:\n      ```shell\n      tornado --jvm=\"-Duser.country=US -Duser.language=en\" -m tornado.examples/uk.ac.manchester.tornado.examples.compute.MonteCarlo\n      ```\n\n## Features\n\n- **Dual Implementation**: Choose between standard CPU processing or TornadoVM acceleration\n- **Modern Java Features**:\n    - Module system integration\n    - Latest JavaFX controls and features\n- **Real-time Processing**: Live preview of edge detection results\n- **Hardware Acceleration**: TornadoVM support for GPU/FPGA acceleration\n- **Configurable Parameters**: Adjust Sobel operator parameters in real-time\n- **Comprehensive Logging**: Detailed logging using SLF4J and Logback\n\n## Running the Application\n\n### Using IDE\n\nTo run a TornadoVM app, one should use output of `tornado --printJavaFlags` CLI command. The following lines should be modified as this project is a JavaFx app.\n\n* Install JavaFx runtime to your PC and prepend the lib path to module path setting:\n   ```text\n   --module-path [JAVA_FX_PATH/lib]:[TORNADO CLI COMMAND MODULE PATH]\n   ```\n\n* Add modules for JavaFX:\n   ``` text\n   --add-modules [TORNADO CLI COMMAND MODULES],javafx.controls,javafx.fxml\n   ```\n\n* Add the following as a workaround for host with Turkish locale\n   ``` text\n   -Duser.country=EN\n   -Duser.language=us\n   ```\n\nAn example VM option set:\n\n```text\n-server\n-XX:-UseCompressedOops\n-XX:+UnlockExperimentalVMOptions\n-XX:+EnableJVMCI\n-XX:-UseCompressedClassPointers\n--enable-preview\n-Djava.library.path=/usr/local/share/TornadoVM/bin/sdk/lib\n--module-path\n/usr/local/share/JavaFX/javafx-sdk-21.0.7/lib:/usr/local/share/TornadoVM/bin/sdk/share/java/tornado\n-Dtornado.load.api.implementation=uk.ac.manchester.tornado.runtime.tasks.TornadoTaskGraph\n-Dtornado.load.runtime.implementation=uk.ac.manchester.tornado.runtime.TornadoCoreRuntime\n-Dtornado.load.tornado.implementation=uk.ac.manchester.tornado.runtime.common.Tornado\n-Dtornado.load.annotation.implementation=uk.ac.manchester.tornado.annotation.ASMClassVisitor\n-Dtornado.load.annotation.parallel=uk.ac.manchester.tornado.api.annotations.Parallel\n--upgrade-module-path\n/usr/local/share/TornadoVM/bin/sdk/share/java/graalJars\n-XX:+UseParallelGC\n@/usr/local/share/TornadoVM/bin/sdk/etc/exportLists/common-exports\n@/usr/local/share/TornadoVM/bin/sdk/etc/exportLists/opencl-exports\n--add-modules\nALL-SYSTEM,tornado.runtime,tornado.annotation,tornado.drivers.common,tornado.drivers.opencl,javafx.controls,javafx.fxml\n-Dtornado.debug=False\n-Dtornado.printKernel=False\n-Dtornado.threadInfo=False\n-Duser.country=EN\n-Duser.language=us\n```\n\n## Implementation Details\n\n### Standard Implementation (CPU)\n- Implements classical Sobel operator algorithm\n\n### TornadoVM Implementation\n- Leverages GPU/FPGA acceleration\n- Parallel processing of image data\n- Dynamic hardware selection based on availability\n\n## Dependencies\n\n- **JavaFX** (21.0.5): UI framework\n- **TornadoVM** (1.1.0): Hardware acceleration\n- **ControlsFX** (11.2.1): Enhanced JavaFX controls\n- **SLF4J/Logback** (2.0.17/1.5.17): Logging framework\n- **JUnit** (5.10.2): Testing framework\n\n## Configuration\n\n### Logging\n- Log files are stored in the `logs` directory\n- Main log file: `data.log`\n- Configure logging levels in `logback.xml`\n\n### TornadoVM Settings\n- Default device selection: First available GPU\n- Fallback to CPU if no GPU is available\n- Configure TornadoVM settings through environment variables\n\n## Performance Considerations\n\n- GPU acceleration provides significant speedup for large images\n- Memory usage is optimized for both implementations\n\n## Troubleshooting\n\n### Common Issues\n\n1. **TornadoVM not detected**\n    - Ensure TornadoVM is properly installed\n    - Check OpenCL installation\n    - Verify GPU drivers are up to date\n\n2. **Performance Issues**\n    - Try switching between implementations\n    - Check system resource usage\n    - Verify image size constraints\n\n### Error Logging\n\nCheck the `logs/data.log` file for detailed error information and stack traces.\n\n## Future Enhancements\n\n- [ ] Add support for additional edge detection algorithms\n- [ ] Implement batch processing capability\n- [ ] Add more hardware acceleration options\n- [ ] Enhance UI with additional controls and features\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## Acknowledgments\n\n- [TornadoVM](https://www.tornadovm.org/) team for the acceleration framework\n- JavaFX community for UI components\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselcuksert%2Fedge-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fselcuksert%2Fedge-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fselcuksert%2Fedge-detection/lists"}