PythonMagick镜头校正

时间:2018-01-25 10:51:22

标签: python imagemagick

我在Python中使用ImageMagick需要帮助,我有一个使用MagickNet应用镜头校正的C#代码,序列如下:

using ImageMagick;

// Step 0: Loading the image
var img = new MagickImage("input.JPG");
img.Quality = 100;
img.FilterType = FilterType.Lagrange;

Step 0

// Step 1: Increase the canvas size
img.Extent(new MagickGeometry(new Percentage(125), new Percentage(125)), Gravity.Center);

Step 1

// Step 2: Apply barrel distortion correction
img.Distort(DistortMethod.Barrel, new[] { -0.92578, 1.3845, -2.09958 });

Step 2

// Step 3: Fix the perspective
img.Distort(DistortMethod.Perspective, new double[] { 1072, 1512, 0, 0, 3404, 1524, w, 0, 3100, 2220, w, h, 1484, 2344, 0, h });

Step 3

// Step 4: Crop and sharpen
img.Extent(2300, 1000);
img.AdaptiveSharpen();

Step 4

基本上它的作用是纠正Go Pro Hero 5相机产生的眼鱼效应。那么,我现在的问题是我如何在Python中做同样的事情:

import PythonMagick

img = PythonMagick.Image(r"input.jpg")

img.quality(100)
img.filterType = PythonMagick.FilterTypes.LagrangeFilter

# Steps here

img.write(r"output.jpg")

我无法在任何ImageMagick包装器中找到函数或类似名称。

0 个答案:

没有答案