【问题标题】:Resize selected area of image调整图像选定区域的大小
【发布时间】:2019-05-27 08:38:02
【问题描述】:

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

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

我怎样才能做到这一点?任何帮助表示赞赏。

【问题讨论】:

    标签: ios swift xcode image image-processing


    【解决方案1】:

    我从未为 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()
    

    【讨论】:

    • 谢谢!! iOS Swift/ObjC 中是否有任何示例?我已经在我的项目中成功配置了它,但还有更多信息,比如如何做?有人可以帮忙吗?
    猜你喜欢
    • 2011-11-26
    • 2014-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-24
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    相关资源
    最近更新 更多