PythonMagick透镜校正

2024-09-29 19:32:20 发布

您现在位置:Python中文网/ 问答频道 /正文

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

using ImageMagick;

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

Step 0

^{pr2}$

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包装内的函数或类似名称。在


Tags: the代码imgnewinputstepimagemagick镜头

热门问题