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

长春火车站到龙嘉机场怎么走久久建筑网和恒智天成那个软件好

长春火车站到龙嘉机场怎么走,久久建筑网和恒智天成那个软件好,网站推广工具推荐,手机制作网站主页软件直接给代码吧。 如果不需要svs格式#xff0c;需要的是tif的话#xff0c;可以直接用slideviewer或者caseviewer转成tif。 事先说明一下#xff0c;这个代码是采用一次性读取整个WSI后#xff0c;再转存为svs的方式。 所需要的内存需要满足一次性读取整个WSI的要求。 这个代…直接给代码吧。 如果不需要svs格式需要的是tif的话可以直接用slideviewer或者caseviewer转成tif。 事先说明一下这个代码是采用一次性读取整个WSI后再转存为svs的方式。 所需要的内存需要满足一次性读取整个WSI的要求。 这个代码也可以用来tif转svs。 from openslide import OpenSlide import pyvips import numpy as np from math import ceil import openslide import os import tifffile import cv2 from tqdm import tqdm import time import glob import copyTILE_SIZE 512gfi lambda img,ind : copy.deepcopy(img[ind[0]:ind[1], ind[2]:ind[3]])def find_file(path,depth_down,depth_up0,suffix.xml):ret []for i in range(depth_up,depth_down):_path os.path.join(path,*/*i*suffix)ret.extend(glob.glob(_path))ret.sort()return retdef up_to16_manifi(hw):return int(ceil(hw[0]/TILE_SIZE)*TILE_SIZE), int(ceil(hw[1]/TILE_SIZE)*TILE_SIZE)def gen_im(wsi, index):ind 0while True:temp_img gfi(wsi, index[ind])ind1yield temp_img def get_name_from_path(file_path:str, ret_all:boolFalse):dir, n os.path.split(file_path)n, suffix os.path.splitext(n)if ret_all:return dir, n, suffixreturn ndef gen_patches_index(ori_size, *, img_size224, stride 224,keep_last_size False):这个函数用来按照输入的size和patch大小生成每个patch所在原始的size上的位置keep_last_size表示当size不能整除patch的size的时候最后一个patch要不要保持输入的img_size返回一个np数组每个成员表示当前patch所在的x和y的起点和终点如[[x_begin,x_end,y_begin,y_end],...]height, width ori_size[:2]index []if heightimg_size or widthimg_size: print(input size is ({} {}), small than img_size:{}.format(height, width, img_size))return indexfor h in range(0, height1, stride):xe himg_sizeif himg_sizeheight:xe heighth xe-img_size if keep_last_size else hfor w in range(0, width1, stride):ye wimg_sizeif wimg_sizewidth:ye widthw ye-img_size if keep_last_size else windex.append(np.array([h, xe, w, ye]))if yewidth:breakif xeheight:breakreturn indexdef just_ff(path:str,*,fileFalse,floderTrue,create_floderFalse, infoTrue):Check the input path status. Exist or not.Args:path (str): _description_file (bool, optional): _description_. Defaults to False.floder (bool, optional): _description_. Defaults to True.create_floder (bool, optional): _description_. Defaults to False.info (bool, optional): _description_. Defaults to True.Returns:_type_: _description_if file:return os.path.isfile(path)elif floder:if os.path.exists(path):return Trueelse:if create_floder:try:os.makedirs(path) if info:print(rPath {} does not exists, but created .format(path))return Trueexcept ValueError:if info:print(rPath {} does not exists, and the creation failed .format(path))passelse:if info:print(rPath {} does not exists.format(path))return Falsedef just_dir_of_file(file_path:str, create_floder:boolTrue):_summary_Check the dir of the input file. If donot exist, creat it!Args:file_path (_type_): _description_create_floder (bool, optional): _description_. Defaults to True.Returns:_type_: _description__dir os.path.split(file_path)[0]return just_ff(_dir, create_floder create_floder)def split_path(root_path:str, input_path:str):path_split os.sepwhile(root_path[-1]path_split):root_path root_path[0:len(root_path)-1]ret_path input_path[len(root_path):len(input_path)]if len(ret_path) 0:return while(ret_path[0]path_split):ret_path ret_path[1:len(ret_path)]return ret_pathdef gen_pyramid_tiff(in_file, out_file, select_level0):select_level 决定了读取那一层。第0层是倍率最高的。svs_desc Aperio Image Library Fake\nABC |AppMag {mag}|Filename {filename}|MPP {mpp}label_desc Aperio Image Library Fake\nlabel {W}x{H}macro_desc Aperio Image Library Fake\nmacro {W}x{H}# 指定mpp值odata openslide.open_slide(in_file)# 获取当前图像的MPP# 如果不是这个字段可以找一下是哪个mpp float(odata.properties[mirax.LAYER_0_LEVEL_0_SECTION.MICROMETER_PER_PIXEL_X])#0.5# 指定缩放倍率mag 40#mpp 在0.25左右的是40X0.5左右的是20Xif mpp0.3:mag 20mpp mpp*2# 换算mpp值到分辨率resolution [10000 / mpp, 10000 / mpp, CENTIMETER]# 指定图像名字if odata.properties.get(aperio.Filename) is not None:filename odata.properties[aperio.Filename]else:filename get_name_from_path(in_file)print(floading {in_file})start time.time()# image_py openslide.open_slide(wsi_path)# pyvip 比openslide更快但如果没有用openslide也是可以的image_py pyvips.Image.openslideload(in_file, level select_level)image np.array(image_py)[...,0:3]print(ffinish loading {in_file}. costing time:{time.time()-start})# image np.array(image_py[20X])# 缩略图thumbnail_im np.zeros([762, 762, 3], dtypenp.uint8)thumbnail_im cv2.putText(thumbnail_im, thumbnail, (thumbnail_im.shape[1]//4, thumbnail_im.shape[0]//2), cv2.FONT_HERSHEY_PLAIN, 6, color(255, 0, 0), thickness3)# 标签图label_im np.zeros([762, 762, 3], dtypenp.uint8)label_im cv2.putText(label_im, label, (label_im.shape[1]//4, label_im.shape[0]//2), cv2.FONT_HERSHEY_PLAIN, 6, color(0, 255, 0), thickness3)# 宏观图macro_im np.zeros([762, 762, 3], dtypenp.uint8)macro_im cv2.putText(macro_im, macro, (macro_im.shape[1]//4, macro_im.shape[0]//2), cv2.FONT_HERSHEY_PLAIN, 6, color(0, 0, 255), thickness3)# tile 大小tile_hw np.int64([TILE_SIZE, TILE_SIZE])width, height image.shape[0:2]# 要需要的金字塔分辨率multi_hw np.int64([(width, height), (width//2, height//2), (width//4, height//4), (width//8, height//8),(width//16, height//16),(width//32, height//32),(width//64, height//64)])# 尝试写入 svs 格式with tifffile.TiffWriter(out_file, bigtiffTrue) as tif:thw tile_hw.tolist()# outcolorspace 要保持为默认的 YCbCr不能使用rgb否则颜色会异常# 95 是默认JPEG质量值域是 0-100值越大越接近无损compression [JPEG, 95, dict(outcolorspaceYCbCr)]# compression JPEGkwargs dict(subifds0, photometricrgb, planarconfigCONTIG, compressioncompression, dtypenp.uint8, metadataNone)for i, hw in enumerate(multi_hw):hw up_to16_manifi(hw)temp_wsi cv2.resize(image, (hw[1], hw[0]))new_x, new_y up_to16_manifi(hw)new_wsi np.ones((new_x, new_y, 3),dtypenp.uint8)*255new_wsi[0:hw[0], 0:hw[1],:] temp_wsi[...,0:3]index gen_patches_index((new_x, new_y),img_sizeTILE_SIZE,strideTILE_SIZE)gen gen_im(new_wsi, index)if i 0:desc svs_desc.format(magmag, filenamefilename, mppmpp)# tif.write(datagen, resolutionresolution, descriptiondesc, **kwargs)tif.write(datagen, shape(*hw, 3), tilethw[::-1], resolutionresolution, descriptiondesc, **kwargs)_hw up_to16_manifi(multi_hw[-2])thumbnail_im cv2.resize(image, (_hw[1], _hw[0]))[...,0:3]tif.write(datathumbnail_im, description, **kwargs)else:tif.write(datagen, shape(*hw, 3), tilethw[::-1], resolutionresolution, description, **kwargs)_hw up_to16_manifi(multi_hw[-2])macro_im cv2.resize(image, (_hw[1], _hw[0]))[...,0:3]tif.write(datamacro_im, subfiletype9, descriptionmacro_desc.format(Wmacro_im.shape[1], Hmacro_im.shape[0]), **kwargs)# mrxs所在的目录 DATA_DIR #保存目录 SAVE_DIR wsi_list find_file(DATA_DIR, 1, suffix.mrxs)for w_name in tqdm(wsi_list):t1 time.perf_counter()patient_name w_name.split(os.path.sep)[-2]wsi_name get_name_from_path(w_name)diff_path split_path(DATA_DIR, get_name_from_path(w_name, ret_allTrue)[0])save_path os.path.join(SAVE_DIR, diff_path, f{wsi_name}.svs)# 如果svs文件已经存在则跳过if just_ff(save_path,fileTrue):continuejust_dir_of_file(save_path)gen_pyramid_tiff(w_name, save_path)print(f{wsi_name}:,time.perf_counter() - t1)
http://www.pierceye.com/news/157565/

相关文章:

  • dz论坛网站创建页面wap网站建设方案 pdf
  • 网站建设项目报告总结报告seo关于网站搜索排名关键词的标准评定
  • 东莞电商网站建设wordpress注册验证邮箱
  • 网站建设名中国建设劳动学会是假网站吗
  • 一个优秀的个人网站百度极速版免费下载安装
  • 咋做211校徽加网站wordpress免费教程视频教程
  • 网站建设制作网络营销公司蛋糕店网站模板
  • a站网址东莞市网络seo推广价格
  • 莱州市双语网站seo白帽优化
  • 不忘初心网站建设深圳公租房官网
  • 网站点击率原因深圳做自适应网站制作
  • 上海个人建站小程序注册完成后如何制作
  • 微网站开发平台 开源大庆做网站公司
  • 长沙市住房和城乡建设局网站wordpress付费可见插件
  • 建设个人网站的参考网站及文献辽宁建设工程造价管理网站
  • 如何做360网站的排名新品发布会策划方案ppt
  • 网站后台登陆破解哪里有网站模板下载
  • 网站制作器软件下载建站备案
  • 网页模板下载网站站长素材音效网
  • 青岛网站建设要多少钱关键词优化是怎样收费的
  • 网站国际联网备案WordPress文章分页伪静态
  • 电子商务网站开发的任务书东莞seo关键词搜索关键词
  • 宁乡网站建设在哪小天才电话手表网站
  • 中文响应式网站搜搜网站提交
  • 华为官方网站手机商城首页大淘客网站商品做淘口令
  • 建站公司网站的关键词怎么设置
  • 上海二手房网站制作游戏需要什么技术
  • 湖州市城市建设档案馆网站电子商务网站怎么建
  • 网站超级外链做企业网站大约多少钱
  • 中国网站建设市场分析桂林公司网站搭建