du20150401 2016-01-22 05:23
浏览 260
已采纳

php - 如何使用imagick或其他库找到图像中边缘的坐标?

given an image composed of a plain black field with a single white rectangle inside it somewhere, how can i extract the coordinates of the rectangle ? i've googled and googled and found numerous articles on edge detection using hough lines, convolution, morphology, etc., but all of these actually edge the image or convert it in some way. i don't want to change the image, all i want to do is find where the edges are.

obviously, i could simply iterate over the entire width+height of the image and look at the pixel colours (as some posts suggest), but that seems horribly inefficient. is there no built-in algorithm ? it seems like this must be part of imagick somewhere, otherwise how could it actually find and draw the edges of internal images ? but i'm having trouble finding out how to get at it.

  • 写回答

2条回答 默认 最新

  • douxueke5653 2016-01-22 21:45
    关注
    $base = new Imagick(realpath('./trim.png'));
    $base->trimImage(0);
    // get the new image size
    $geometry = $base->getImageGeometry();
    // Retrieve the trim info
    $pageInfo = $base->getImagePage();
    

    A similar example is on the manual page: http://php.net/manual/en/imagick.trimimage.php#111332

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题