当前位置: 首页 > wzjs >正文

网站品质wordpress 子网站重命名

网站品质,wordpress 子网站重命名,淘宝店铺交易,网站知识架构这个同样是图片素材处理的付费功能,这期演示如果通过技术实现给商品图换背景。 首先这是我用opencv画的背景图绘制背景图的代码 import cv2 import numpy as np import datetime import osdef create_product_background(width800, height800):# 创建渐变背景&#…

这个同样是图片素材处理的付费功能,这期演示如果通过技术实现给商品图换背景。
首先这是我用opencv画的背景图
在这里插入图片描述
绘制背景图的代码

import cv2
import numpy as np
import datetime
import osdef create_product_background(width=800, height=800):# 创建渐变背景(从浅灰到白色)background = np.zeros((height, width, 3), dtype=np.uint8)# 基础浅灰色背景background[:] = (240, 240, 240)# 添加垂直渐变效果for y in range(height):alpha = y / heightbackground[y, :] = background[y, :] * (1 - alpha) + np.array([255, 255, 255]) * alpha# 添加中心阴影效果(模拟产品放置区域)shadow = np.zeros((height, width), dtype=np.uint8)cv2.ellipse(shadow, (width//2, height//2), (300, 300), 0, 0, 360, 100, -1)background = cv2.addWeighted(background, 1.0, cv2.cvtColor(shadow, cv2.COLOR_GRAY2BGR), 0.3, 0)# 添加装饰性网格线(增强专业感)for i in range(0, width, 50):cv2.line(background, (i, 0), (i, height), (220, 220, 220), 1)for j in range(0, height, 50):cv2.line(background, (0, j), (width, j), (220, 220, 220), 1)return background# 保存背景图
def save_background(background, output_dir='output', prefix='product_bg'):os.makedirs(output_dir, exist_ok=True)current_time = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')output_path = os.path.join(output_dir, f'{prefix}_{current_time}.jpg')cv2.imwrite(output_path, background)print(f'背景图已保存到: {output_path}')# 使用示例
if __name__ == '__main__':bg = create_product_background()save_background(bg)
print('背景图已保存到output/product_background.jpg')

我用前面抠图程序抠好的图
在这里插入图片描述
图片合成,将抠好的商品图放到前面画的背景图中间

import os
import datetime
import cv2
import numpy as np
from PIL import Imagedef process_foreground(foreground):"""处理前景图,包括调整大小和边缘平滑"""# 调整前景图大小max_size = (500, 500)foreground.thumbnail(max_size, Image.LANCZOS)# 转换为OpenCV格式进行处理foreground_cv = np.array(foreground)if foreground.mode == 'RGBA':alpha = foreground_cv[:,:,3]alpha = cv2.GaussianBlur(alpha, (5,5), 0)foreground_cv[:,:,3] = alphaelse:foreground_cv = cv2.GaussianBlur(foreground_cv, (3,3), 0)return Image.fromarray(foreground_cv)def main():try:# 定义输入输出路径变量background_path = os.path.join('output', 'product_bg1.jpg')foreground_path = os.path.join('output', 'sku1.png')output_dir = 'output'# 获取当前时间并格式化current_time = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')output_filename = f'result_{current_time}.jpg'# 打开并验证图片background = Image.open(background_path)foreground = Image.open(foreground_path)# 处理前景图processed_foreground = process_foreground(foreground)# 合成图片background.paste(processed_foreground, (170, 150), processed_foreground)# 确保输出目录存在os.makedirs(output_dir, exist_ok=True)# 保存结果output_path = os.path.join(output_dir, output_filename)background.save(output_path)print(f'图片已保存到: {output_path}')except FileNotFoundError as e:print(f'错误: 文件未找到 - {e}')except Exception as e:print(f'错误: 处理图片时发生异常 - {e}')if __name__ == '__main__':main()

合成好的效果,商品的边缘可以进一步羽化使其看起来更自然一些。
在这里插入图片描述


文章转载自:

http://25APxA9z.LmwrL.cn
http://0t6mlV6P.LmwrL.cn
http://7kLyyfXw.LmwrL.cn
http://Q6KNMoVh.LmwrL.cn
http://Pd2BWkNV.LmwrL.cn
http://LS7OveKS.LmwrL.cn
http://OdasZKep.LmwrL.cn
http://sfQjwYjv.LmwrL.cn
http://O0fD0UTB.LmwrL.cn
http://oHUuqVOz.LmwrL.cn
http://ucy7F61X.LmwrL.cn
http://FHEnzUt3.LmwrL.cn
http://W7LKShjr.LmwrL.cn
http://fMtRrSsZ.LmwrL.cn
http://msI4b83i.LmwrL.cn
http://t4psvVUE.LmwrL.cn
http://d1y1kCyh.LmwrL.cn
http://mcp1Au6Q.LmwrL.cn
http://ZxZ4daSq.LmwrL.cn
http://IAuseEis.LmwrL.cn
http://yU5Hat7L.LmwrL.cn
http://3Ohgvn3V.LmwrL.cn
http://HmuSCC9Y.LmwrL.cn
http://3CoIleAK.LmwrL.cn
http://pzvtlVX0.LmwrL.cn
http://TZB5GKVm.LmwrL.cn
http://VI0c4n7i.LmwrL.cn
http://hTbVBSTf.LmwrL.cn
http://fe16hknq.LmwrL.cn
http://ex40yR8D.LmwrL.cn
http://www.dtcms.com/wzjs/664224.html

相关文章:

  • 北京网站推广怎么做搜索企业的软件
  • 有帮忙做ppt的网站或人吗免费网站托管
  • 国际空间站vs中国空间站免费素材网站mixkit
  • 政务网站建设依据国家网站皮肤样板
  • 西安网络营销学习网站做网站设计答辩问题
  • 云尚网站建设网站一级导航怎么做
  • 网站制作五个界面wordpress hotnews
  • 文登做网站的公司优化企业网站
  • 北京做网站的公司有哪些WordPress仿百度百家主题
  • 网站地图 wordpress动画设计与制作主要学什么
  • seo网站沙盒期如何选择网站改版公司
  • 做网站设计师工资多少网站建设 推广 公司
  • 网站建设作业建设淘宝网站的目的
  • 企业网站建设对企业的宣传作用1年网站
  • 网站建设要求说明制作视频剪辑
  • 网站建设前分析建设部网站
  • 济南产品网站建设外包东莞公司注册登记
  • 网站开发好要租服务器吗内容网站设计范例
  • 天津网站建设价位怎么在百度发布自己的文章
  • 网站建设项目团队组织结构图微企点做网站怎么样
  • 如何使用模板网站建设网页wordpress网站多层循环调用文章
  • 公司建立网站的好处一个外国人做汉字网站
  • 南京设计网站建设网站访问量咋做
  • 陕西宝陵建设集团网站电子商务网站的建设流程
  • 乐清建网站哪家好建e网室内设计网模型楼梯
  • 算命网站做竞价赚钱网络营销工作
  • 怎么搜 织梦的网站app定制多少钱
  • 网站上不去的原因网站有pc站和手机站
  • 沈阳网站开发集团国内个人网站
  • 用pc机做网站并让外网搜到wordpress在线教育插件