Home >Backend Development >PHP Problem >How to implement a simple image edge detection in php
This article will introduce to you how to implement a simple image edge detection in PHP. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Rough steps:
Scale the image to improve efficiency
Grayscale the image
Calculate edges based on brightness
The third step is the most critical. There are many methods used here to directly compare adjacent brightness.
How to use:
composer require lizhichao/one-img
$img_path = '1.jpg'; $img = new \OneImg\Border(); $img->setImg($img_path) ->scale(300, 300) ->outline() ->save(); //输出到浏览器
https://github.com/lizhichao/doImg
The above is the detailed content of How to implement a simple image edge detection in php. For more information, please follow other related articles on the PHP Chinese website!