【发布时间】:2019-05-27 08:38:02
【问题描述】:
我只想增加/减少所选区域(白线之间的区域)的图像高度,如图所示,而不是该区域的外部。
这与应用中执行的功能相同Manly - Body Muscle Editor Pro
我怎样才能做到这一点?任何帮助表示赞赏。
【问题讨论】:
标签: ios swift xcode image image-processing
我只想增加/减少所选区域(白线之间的区域)的图像高度,如图所示,而不是该区域的外部。
这与应用中执行的功能相同Manly - Body Muscle Editor Pro
我怎样才能做到这一点?任何帮助表示赞赏。
【问题讨论】:
标签: ios swift xcode image image-processing
我从未为 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()
【讨论】: