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

怎样做档口批发网站网推一手单渠道

怎样做档口批发网站,网推一手单渠道,上海外贸建站推广公司,3千元在家办厂程序: 路径改成自己的,阈值可以修改也可以默认 #zhouzhichao #25年5月17日 #计算时频图中信号面积占检测框面积的比值import os import numpy as np import pandas as pd from PIL import Image# Define the path to the directory containing the lab…

程序:

路径改成自己的,阈值可以修改也可以默认

#zhouzhichao
#25年5月17日
#计算时频图中信号面积占检测框面积的比值import os
import numpy as np
import pandas as pd
from PIL import Image# Define the path to the directory containing the label txt files
label_dir = r'D:\实验室\论文\论文-多信号参数估计\JCR3\Principle\微调原理\diff_snr\snr_dataset\label_txt'
img_dir = r'D:\实验室\论文\论文-多信号参数估计\JCR3\Principle\微调原理\diff_snr\snr_dataset\6'
binary_output_dir = r'D:\实验室\论文\论文-多信号参数估计\JCR3\Principle\像素面积比值\binary img'# Make sure the output directory exists
os.makedirs(binary_output_dir, exist_ok=True)# Initialize lists for storing the results for each class
ratios_0 = []
ratios_1 = []
ratios_2 = []
ratios_3 = []# Function to calculate the ratio of signal area to the bounding box area
def calculate_area_ratio(image_path, label_path, binary_output_dir):# Load the image and convert it to grayscaleimage = Image.open(image_path).convert('L')  # Convert to grayscale (L mode)image_array = np.array(image)# Read the label filewith open(label_path, 'r') as file:labels = file.readlines()for label in labels:# Parse the labellabel_data = label.strip().split()class_id = int(label_data[0])  # Class IDx_center = float(label_data[1])  # x center normalizedy_center = float(label_data[2])  # y center normalizedbox_width = float(label_data[3])  # box width normalizedbox_height = float(label_data[4])  # box height normalized# Convert the normalized values to pixel values based on image sizeimg_width, img_height = image.sizex_center_px = int(x_center * img_width)y_center_px = int(y_center * img_height)box_width_px = int(box_width * img_width)box_height_px = int(box_height * img_height)# Calculate the bounding box coordinatesx_min = max(x_center_px - box_width_px // 2, 0)y_min = max(y_center_px - box_height_px // 2, 0)x_max = min(x_center_px + box_width_px // 2, img_width)y_max = min(y_center_px + box_height_px // 2, img_height)# Extract the bounding box regionbbox_region = image_array[y_min:y_max, x_min:x_max]# Threshold the image (binary thresholding)binary_region = np.where(bbox_region > 128, 1, 0)  # 128 as threshold# Calculate the area of the signal inside the bounding box (sum of binary values)signal_area = np.sum(binary_region)# Calculate the area of the bounding boxbox_area = box_width_px * box_height_px# Save the binary image of the region to the output folderbinary_image = Image.fromarray(binary_region.astype(np.uint8) * 255)  # Convert to 0-255 scale for savingbinary_image.save(os.path.join(binary_output_dir, f'binary_{class_id}_{x_center_px}_{y_center_px}.png'))# Calculate the area ratioarea_ratio = signal_area / box_area if box_area > 0 else 0if class_id==0:ratios_0.append(area_ratio)if class_id==1:ratios_1.append(area_ratio)if class_id == 2:ratios_2.append(area_ratio)if class_id == 3:ratios_3.append(area_ratio)# Traverse all the label files and calculate area ratios
for label_file in os.listdir(label_dir):if label_file.endswith('.txt'):# Get corresponding image pathlabel_path = os.path.join(label_dir, label_file)image_name = label_file.replace('.txt', '.jpg')  # Assuming image is in .jpg formatimage_path = os.path.join(img_dir, image_name)# Calculate area ratios for the current label filecalculate_area_ratio(image_path, label_path, binary_output_dir)data = {'ratios_0': ratios_0,'ratios_1': ratios_1,'ratios_2': ratios_2,'ratios_3': ratios_3
}# 创建一个 DataFrame
df = pd.DataFrame(data)# 保存到 Excel 文件
file_path = r'D:\实验室\论文\论文-多信号参数估计\JCR3\Principle\像素面积比值\area_ratios.xlsx'
df.to_excel(file_path, index=False)
print()

程序依照的公式:

生成结果:

可用于绘制论文实验图:

http://www.dtcms.com/wzjs/360740.html

相关文章:

  • 查看公司股票的网站网络营销的推广手段
  • 武汉 光谷 网站建设公司谷歌优化的网络公司
  • 网站建设这个目前最新推广平台
  • 建设电子商务网站的基本步骤百度认证号码平台
  • 兰溪自适应网站建设特点查询收录
  • 网站防注入怎么办seo优化报价公司
  • 辽宁数据网站建设哪家便宜网站推广优化设计方案
  • 制作网站软件app常用的网络推广方式有哪些
  • 云服务器安装网站荥阳seo推广
  • 网站开发情况广告商对接平台
  • 网站静态页面访问很快php页面访问非常慢品牌推广策划书范文案例
  • 滕州网站制作哪家好百度公司官网
  • 网站建设商城最近新闻内容
  • 做网站公司哪家好百度指数的基本功能
  • 经典重庆论坛新闻论坛发展论坛河南网站推广优化
  • jquery 购物网站富阳网站seo价格
  • 如何创建公司网站疫情最新官方消息
  • 网站个人备案搜seo
  • 给公司做一个网站快速排名教程
  • 中山模板建站软件阿里指数查询官网入口
  • 企业网站名备案头条搜索
  • 网站加入百度广告联盟环球网最新消息疫情
  • 南昌有没有做企业网站和公司企业宣传推广怎么做
  • 武汉抖音seo推广站长工具seo综合查询怎么关闭
  • 徐州建设工程造价信息网开鲁网站seo转接
  • 现代建设公司网站一键制作网站
  • 登录背景图片素材济南seo网站排名关键词优化
  • 湛江宇锋网站建设厦门小鱼网
  • 网站建设项目及费用如何进行网站推广?网站推广的基本手段有哪些
  • 网站建设与管理 ppt模板今日竞彩足球最新比赛结果查询