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

微网站建设的第一步是什么 标题嘉兴百度seo

微网站建设的第一步是什么 标题,嘉兴百度seo,做二手车的网站有哪些,如何建设一个好的企业网站目录💨💨💨 中心外扩的最佳RoI(裁图)根据两个坐标点求缩放偏移后的RoI自定义RGB2BGR颜色解析小函数滑窗切片(sliding window crops)VOC的颜色调色板 中心外扩的最佳RoI(裁图&#xf…

目录💨💨💨

    • 中心外扩的最佳RoI(裁图)
    • 根据两个坐标点求缩放+偏移后的RoI
    • 自定义RGB2BGR颜色解析小函数
    • 滑窗切片(sliding window crops)
    • VOC的颜色+调色板

中心外扩的最佳RoI(裁图)

指定中心点和裁图宽高,获得裁图位置xyxy坐标(最佳),便于在图像裁剪。

def get_best_crop_position_of_center(center_xy, img_w, img_h, crop_w, crop_h):pt = center_xyx0, y0 = max(0, pt[0] - crop_w // 2), max(0, pt[1] - crop_h // 2)  # 左上角 >= (0,0)x1, y1 = min(x0 + crop_w, img_w), min(y0 + crop_h, img_h)  # 右下角return [int(x1-crop_w), int(y1-crop_h), int(x1), int(y1)]

根据两个坐标点求缩放+偏移后的RoI

def get_xyxy_scale_shift(pt1, pt2, scale_xy=1.0, shift=0, imgW=0, imgH=0):"""给定两个坐标点,返回缩放+偏移后的RoI坐标:param pt1, pt2: 两个坐标点:param scale_xy: 缩放比例,还原到原图:param shift: 短边的放大偏移量(长边不变):param imgW: RoI坐标限宽:param imgH: RoI坐标限高"""x0, y0, x1, y1 = min(pt1[0], pt2[0]), min(pt1[1], pt2[1]), max(pt1[0], pt2[0]), max(pt1[1], pt2[1])  # 左上, 右下x0, y0, x1, y1 = round(x0 * scale_xy), round(y0 * scale_xy), round(x1 * scale_xy), round(y1 * scale_xy)  # 缩放,取整if x1 - x0 == y1 - y0:x0, x1 = x0 - shift, x1 + shifty0, y1 = y0 - shift, y1 + shiftelif x1 - x0 < y1 - y0:x0, x1 = x0 - shift, x1 + shiftelse:y0, y1 = y0 - shift, y1 + shiftif imgW > 0:x0 = min(max(0, x0), imgW)x1 = min(max(0, x1), imgW)if imgH > 0:y0 = min(max(0, y0), imgH)y1 = min(max(0, y1), imgH)return int(x0+0.5), int(y0+0.5), int(x1+0.5), int(y1+0.5)

上面函数可以应用在图像上画矩形框,

def draw_RoI(img: np.ndarray, pt1, pt2, scale_xy=1.0, shift=0, color=None, thickness=None):if color is None: color = (0,255,0)imgH, imgW = img.shape[:2]x0, y0, x1, y1 = get_xyxy_scale_shift(pt1, pt2, scale_xy, shift, imgW, imgH)cv2.rectangle(img, (x0, y0), (x1, y1), color, thickness)return x0, y0, x1, y1

自定义RGB2BGR颜色解析小函数

def rgb2bgr(rgb):if isinstance(rgb, (list, tuple)):rgb_list = []for val in rgb:if isinstance(val, str) and val.strip() != '':rgb_list.append(int(val.strip()))elif isinstance(val, int):rgb_list.append(val)return rgb_list[::-1]elif isinstance(rgb, str):bgr = [int(val.strip()) for val in rgb.split(',') if val.strip() != ''][::-1]return bgrelse:raise ValueError("error in converting RGB[" + str(rgb) + "] to BGR")

滑窗切片(sliding window crops)

指定横向和纵向的Windows数,自适应计算每个Window的宽和高,以及滑窗步长,居中对齐,返回每个Window的坐标。

def make_grids(img, grid_x, grid_y, dx=0, dy=0):"""make grids in x-axis and y-axis指定横向和纵向的Windows数,自适应计算每个Window的宽和高,居中对齐,返回每个Window的坐标Args:img: ndarraygrid_x: number of grids in x-axis,指定横向窗口数grid_y: number of grids in y-axis,指定纵向窗口数dx: shrinking size in x-axis,横向窗口间隔的一半dy: shrinking size in y-axis,纵向窗口间隔的一半Returns:[[grid_box]], wheregrid_box = (upleft_pt, downright_pt) = ((x0, y0), (x1, y1))"""grid_boxs = []h, w = img.shape[:2]left_pad, up_pad = (w % grid_x) // 2, (h % grid_y) // 2box_w, box_h = w // grid_x, h // grid_yfor hi in range(grid_y):row_boxs = [((left_pad+wi*box_w+dx, up_pad+hi*box_h+dy),(left_pad+(wi+1)*box_w-dx, up_pad+(hi+1)*box_h-dy))for wi in range(grid_x)]grid_boxs.append(row_boxs)return grid_boxsdef make_grids_sliding(img, grid_x, grid_y, box_w, box_h):"""指定横向和纵向的Windows数 以及窗口大小,有overlapping的滑窗,左右上下紧贴边Args:img: ndarraygrid_x: number of grids in x-axis,指定横向窗口数grid_y: number of grids in y-axis,指定纵向窗口数box_w: width of each box,窗口横向宽度box_h: height of each box,窗口纵向高度Returns:[[grid_box]], wheregrid_box = (upleft_pt, downright_pt) = ((x0, y0), (x1, y1))Examples:[:append]grid_boxs = make_grids_sliding(srcImg, 4, 3, 1280, 1280)for idy, row_boxs in enumerate(grid_boxs):for idx, ((x0, y0), (x1, y1)) in enumerate(row_boxs):cv2.circle(srcImg, ((x0+x1)//2, (y0+y1)//2), 20, color, -1)[:extend]grid_boxs = make_grids_sliding(srcImg, 4, 3, 1280, 1280)for (x0, y0), (x1, y1) in grid_boxs:cv2.circle(srcImg, ((x0+x1)//2, (y0+y1)//2), 20, color, -1)"""grid_boxs = []h, w = img.shape[:2]# box_h, box_w = min(h, box_h), min(w, box_w)  # 保证:窗口大小 <= 原图大小lt_x0y0, rd_x0y0 = (0, 0), (max(0, w-box_w), max(0, h-box_h))  # 左上角窗口、右下角窗口的左上角坐标x0linspace = [int(x0) for x0 in np.linspace(lt_x0y0[0], rd_x0y0[0], grid_x)]y0linspace = [int(y0) for y0 in np.linspace(lt_x0y0[1], rd_x0y0[1], grid_y)]for y0 in y0linspace:row_boxs = [((x0, y0), (x0+box_w, y0+box_h))for x0 in x0linspace]  # 左上角、右下角grid_boxs.extend(row_boxs)  # .appendreturn grid_boxsif __name__ == '__main__':srcImg = np.zeros((2000, 2000, 3), dtype=np.uint8)grid_boxs = make_grids_sliding(srcImg, 2, 2, 1280, 1280)print(grid_boxs)# 在crop_srcImg上滑动窗口裁图,将grid_boxs从crop_srcImg映射回srcImgpx0, py0 = 10, 10for idy, row_boxs in enumerate(grid_boxs):(x0, y0), (x1, y1) = row_boxsgrid_boxs[idy] = ((x0 + px0, y0 + py0), (x1 + px0, y1 + py0))print(grid_boxs)

VOC的颜色+调色板

通过位运算,巧妙地生成有梯度(相差128个灰度值)的RGB颜色表,相比打表可快多了。


def create_pascal_label_colormap():"""PASCAL VOC 分割数据集的类别标签颜色映射label colormap返回:可视化分割结果的颜色映射ColormapExamples:colormap = create_pascal_label_colormap()color = colormap[idx].tolist()  # [b, g, r]# 分割结果label.shape=(1024,1024),渲染图vis.shape=(1024,1024,3)vis = colormap[label]"""colormap = np.zeros((256, 3), dtype=int)ind = np.arange(256, dtype=int)for shift in reversed(range(8)):for channel in range(3):colormap[:, channel] |= ((ind >> channel) & 1) << shiftind >>= 3return colormap
http://www.dtcms.com/wzjs/155697.html

相关文章:

  • 中小企业建网站哪个好百度手机极速版
  • 网站关停怎么做近期国际新闻
  • 有哪些做兼职的设计网站贵阳百度快照优化排名
  • 公司网站制作步骤流程图深圳搜索引擎优化推广
  • 阿里个人网站南宁百度seo公司
  • 长沙最好网站建设建一个自己的网站
  • 企业社交网站定制防恶意点击软件
  • 德国网站的后缀名今日头条新闻最新疫情
  • bootstrap设计的精美网站百度怎么推广自己的视频
  • 深圳建设网站哪家好沈阳关键词优化报价
  • wordpress支付功能seo排名怎么做
  • 长沙专业做网站公司网址怎么注册
  • 包头网站作风建设年自评材料中国十大知名网站
  • 网络公司网站设计方案ppt免费p站推广网站入口
  • 微信小程序后端开发流程厦门网站推广优化哪家好
  • 潍坊网站建设工作室短视频seo推广
  • 网站建设与维护实训总结网络推广的方式和途径有哪些
  • edm营销优化大师如何删掉多余的学生
  • 查询网站备案密码是什么情况江苏seo网络
  • 公司网站建设是什么意思如何自己做网站
  • 网站开发者排名网页设计案例
  • wordpress 站外搜索阐述网络营销策略的内容
  • 青龙网站建设网络营销的公司有哪些
  • 网站psd切图做响应式效果网络营销公司经营范围
  • 微网站ui多少钱学seo如何入门
  • 建网站用营业执照吗google下载
  • 模板网站可以优化吗整站外包优化公司
  • 做海报创客贴同类网站微信引流的十个方法
  • 广东企业网站seo报价推广代理平台登录
  • 互联网兼职做网站维护媒体发布平台