ios - 调整图像选定区域的大小

标签 ios swift xcode image image-processing

我只想增加/减少图像中所描绘的选定区域(白线之间的区域)的图像高度,而不是该区域的外部。

enter image description here

这与应用 Manly - Body Muscle Editor Pro 中执行的功能相同

我怎样才能做到这一点?感谢您的帮助。

最佳答案

我从未为 IOS 编写过代码,但我知道 OpenCV 也适用于 IOS。这里我使用了cv2.resize

import cv2
import numpy as np

img = cv2.imread("1.jpg")

print(img.shape)

h = img.shape[0]
w = img.shape[1]

part_to_resize = img[120:240,:]

old_height = 120 #240-120
new_height = 200

final_result = np.zeros((h-(240-120)+new_height,w,3),dtype='uint8')

final_result[0:119,:] = img[0:119,:]
final_result[120:320,:] =  cv2.resize(part_to_resize, (w, new_height))
final_result[321:h-old_height+new_height,:] = img[241:h,:]

cv2.imshow("final_result", final_result)
cv2.imshow("img", img)
cv2.waitKey()

enter image description here

关于ios - 调整图像选定区域的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53976838/

相关文章:

ios - 添加SceneDelegate并更新Info.plist后黑屏

ios - 如何在 Swift 中锁定单个 UIView 从旋转到横向?

ios - CCSprite 贴图大小

ios - iOS 云后端事件监听通论

ios - 在 UIPinchGestureRecognizer 中查找捏合或捏合

swift - 何时调用 WCSession 对象上的 activateSession()

android - 贴心的回调方法

ios - Xcode 无法加载配置文件

ios - 我对核心数据有些困惑?

iOS map 样式配置向上滑动?