首页 > 解决方案 > 在iOS中将从图库中选择的图像转换为灰度

问题描述

我正在编写一个程序来将从照片库中选择的图像转换为 iOS 中的灰度,但是当我测试它时,imageView 只显示黑暗。我的代码有什么问题?

这是我的代码的一部分。而且我很确定我的 toGray 函数没有任何问题,我用它通过 Open CV 将图像转换为灰度。

func didSelectPhoto(_ image: UIImage?) {
    if let image = image {
        self.setupElementsVisibility(true)
        let gray =  OpenCVWrapper.toGray(image)
        self.imageContainer.image = gray

    } else {
        self.setupElementsVisibility(true)
    }
    self.dismiss(animated: true, completion: nil)
}

标签: swiftopencv3.0

解决方案


推荐阅读