如何使用Imagemagick进行四点扭曲 [英] How to do four point distort with Imagemagick

查看:185
本文介绍了如何使用Imagemagick进行四点扭曲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在图像上放置徽标。我有4(x,y)坐标。徽标应该放在这个区域之间,只有一些歪斜效应,如下所示。



解决方案

最好提供干净的单独输入图像(除了你的结果)和你的ImageMagick版本和平台。



然而,我把这两张图片裁剪成:







然后我顺时针测量G图像的角坐标左上角。



然后我按照类似的顺序(绿色,红色,粉红色,蓝色)测量彩色圆圈坐标。



然后我做了+扭曲视角并合成了两个图像。坐标序列是:inx1,iny1 outx1,outy1 .... inx4,iny4 outx4,outy4,其中G图像是in而袋图像是out。



这是unix ImageMagick 6语法中的命令。对于Windows,请删除\。对于ImageMagick 7,使用magick而不是convert

  convert bag.png \(G.png -virtual- pixel none + distort perspective0,0 75,280 116,0 155,311 116,119 141,367 0,119 64,329\)-layers flatten + repage result.png 



参考:


I want to place a logo on a image. I have 4 (x,y) coordinates. The logo should be placed between this area only with some skew effect as given below.

解决方案

It is always best to provide clean separate input imagery (in a addition to your result) and your ImageMagick version and platform.

Nevertheless, I cropped out the two images as:

Then I measured the corner coordinates of the G image clockwise from the top left corner.

Then I measured the colored circle coordinates in similar order (green, red, pink, blue).

Then I did the +distort perspective and composited the two images. The sequence of coordinates is: inx1,iny1 outx1,outy1 .... inx4,iny4 outx4,outy4, where the G image is the in and the bag image is the out.

Here is the command in unix ImageMagick 6 syntax. For Windows remove the \s. For ImageMagick 7, use "magick" rather than "convert"

convert bag.png \( G.png -virtual-pixel none +distort perspective "0,0 75,280  116,0 155,311  116,119 141,367  0,119 64,329" \) -layers flatten +repage result.png

Reference: http://www.imagemagick.org/Usage/distorts/#perspective

EDIT:

If you make the white background of the G image transparent, then it will look better.

convert bag.png \( G.png -fuzz 15% -transparent white -virtual-pixel none +distort perspective "0,0 75,280  116,0 155,311  116,119 141,367  0,119 64,329" \) -layers flatten +repage result2.png

这篇关于如何使用Imagemagick进行四点扭曲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆