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

曲靖住房和城乡建设局网站上海地铁最新公告

曲靖住房和城乡建设局网站,上海地铁最新公告,稿定设计手机版下载,天津app开发公司在这里以红色目标为例子#xff0c;我的背景里面有很多颜色#xff0c;但是我只想要红色的目标部分 #xff08;注#xff1a;这里的程序是将图片中的红色目标提取出来#xff0c;其余背景全是黑色#xff0c;如果想要其他颜色#xff0c;请根据阈值自行修改#xff09…在这里以红色目标为例子我的背景里面有很多颜色但是我只想要红色的目标部分 注这里的程序是将图片中的红色目标提取出来其余背景全是黑色如果想要其他颜色请根据阈值自行修改 首先运行下面程序将图片中的目标提取出来 from PIL import Image import numpy as npdef extract_red_channel(input_path, output_path):# Load the imageimage Image.open(input_path)# Convert image to RGBA (in case its not)image image.convert(RGBA)# Split the image into channelsred_channel, green_channel, blue_channel, alpha_channel image.split()# Create a new image with red channel and alpha channel# The numpy array is used to create a mask where the red channel is dominantred_data np.array(red_channel)green_data np.array(green_channel)blue_data np.array(blue_channel)# Define the threshold for red (values may need to be adjusted)red_threshold 100green_threshold 50blue_threshold 50# Create a mask where only the red pixels are keptmask (red_data red_threshold) (green_data green_threshold) (blue_data blue_threshold)# Apply the mask to the alpha channel to set non-red pixels to transparentalpha_data np.array(alpha_channel)alpha_data[~mask] 0 # Set alpha to zero where mask is False# Convert the numpy array back to an imagenew_alpha_channel Image.fromarray(alpha_data, L)# Merge the red channel and new alpha channel back into an imagered_image Image.merge(RGBA, (red_channel, green_channel, blue_channel, new_alpha_channel))# Save the imagered_image.save(output_path)# Define the input and output paths input_path example.png # Update this to the path of your source image output_path 2.png # Update this to your desired output path# Call the function to extract the red channel extract_red_channel(input_path, output_path)print(fExtracted red channel image saved to {output_path})然后在运行下面程序将png图片转为tif图片格式 from PIL import Image# 定义一个函数来转换图片格式 def convert_png_to_tif(png_file_path, tif_file_path):# 使用Pillow库打开PNG图片png_image Image.open(png_file_path)# 将图片保存为TIF格式png_image.save(tif_file_path, formatTIFF)# 示例用法 # 假设有一个名为example.png的PNG图片我们想将其转换为converted.tif # 请替换这里的文件路径为你自己的文件路径 png_file_path red.png tif_file_path 1.tif# 调用函数进行转换 convert_png_to_tif(png_file_path, tif_file_path)# 打印完成信息 print(图片转换完成。)
http://www.zqtcl.cn/news/542440/

相关文章:

  • 网站seo是什么谷歌海外广告投放
  • 江苏省 建设 注册中心网站首页淮南建筑网
  • 网站备案核wordpress页面菜单
  • 凤阳县城乡建设局网站设计本app下载
  • 网站建设实用教程网站后台制作表格
  • 微信官方网站注册新开的网页游戏平台
  • 福州专业建站网站代码的重点内容是什么
  • jsp网站架构网站设计的主要内容
  • html电子商务网站模板wordpress 随机阅读数
  • 湖南省军区强军网网站群建设项目免费网页托管
  • 网站背景图政协网站 两学一做专题研讨
  • 买域名建网站郑州做网站优化运营商
  • 建设宠物店网站114查询
  • 怎么查网站关键词排名微信与与网站建设
  • 湖州高端网站建设医疗网站源码
  • 有什么网站是做兼职的直播视频怎么录制
  • 扬州市网站建设工作室免费模板网站建设
  • 网站大全全部优秀网站设计流程
  • 授权网站系统网站标题如何修改
  • 商城网站大概多少钱考证培训机构报名网站
  • 马鞍山做网站怎么看网站谁做的
  • 网站建设捌金手指专业7网站如何设置广告
  • 做网站用什么浏览器好工程公司工作总结
  • 温州做网站哪家好为wordpress移动端
  • 温州平阳县企业网站搭建推荐建立网站的技术路径
  • php c2c网站开发的 书营销型网站sempk
  • 网站建设专业网站设计公司物格网陕西建省级执法人才库
  • 网站后台管理密码忘了建设网站简单吗
  • 做网站在哪里网站开发平台有哪些
  • 网站域名的建立推荐一个两学一做的网站