首页 文章 精选 留言 我的

精选列表

搜索[异步方法],共10000篇文章
优秀的个人博客,低调大师

Numpy处理图片方法

在进行图像领域的深度学习的时候经常需要对图片进行处理,包括图像的翻转,压缩,截取等,一般都是用Numpy来处理。处理起来也很方便。 In[3] 导入需要的包 import numpy as np import matplotlib.pyplot as plt from PIL import Image 读入图片 image = Image.open('./work/vehicle1.jpg') image = np.array(image) 查看数据形状,其形状是[H, W, 3], 其中H代表高度, W是宽度,3代表RGB三个通道 image.shape (437, 700, 3) In[4] 原始图片 plt.imshow(image) ​ In[7] 垂直方向翻转 这里使用数组切片的方式来完成, 相当于将图片最后一行挪到第一行, 倒数第二行挪到第二行,..., 第一行挪到倒数第一行 对于行指标,使用::-1来表示切片, 负数步长表示以最后一个元素为起点,向左走寻找下一个点 对于列指标和RGB通道,仅使用:表示该维度不改变 image2 = image[::-1, :, :] plt.imshow(image2) ​ In[8] 水平方向翻转 image3 = image[:, ::-1, :] plt.imshow(image3) ​ In[5] 180度方向翻转 image31 = image[::-1, ::-1, :] plt.imshow(image31) ​ In[9] 保存图片 im3 = Image.fromarray(image3) im3.save('im3.jpg') In[10] 高度方向裁剪 H, W = image.shape[0], image.shape[1] 注意此处用整除,H_start必须为整数 H1 = H // 2 H2 = H image4 = image[H1:H2, :, :] plt.imshow(image4) ​ In[11] 宽度方向裁剪 W1 = W//6 W2 = W//3 * 2 image5 = image[:, W1:W2, :] plt.imshow(image5) ​ In[13] 两个方向同时裁剪 image5 = image[H1:H2, \ W1:W2, :] plt.imshow(image5) ​ In[14] 调整亮度 image6 = image * 0.5 plt.imshow(image6.astype('uint8')) ​ In[15] 调整亮度 image7 = image * 2.0 由于图片的RGB像素值必须在0-255之间, 此处使用np.clip进行数值裁剪 image7 = np.clip(image7, \ a_min=None, a_max=255.) plt.imshow(image7.astype('uint8')) ​ In[16] 高度方向每隔一行取像素点 image8 = image[::2, :, :] plt.imshow(image8) ​ In[17] 宽度方向每隔一列取像素点 image9 = image[:, ::2, :] plt.imshow(image9) ​ In[18] 间隔行列采样,图像尺寸会减半,清晰度变差 image10 = image[::2, ::2, :] plt.imshow(image10) image10.shape (219, 350, 3) ​

优秀的个人博客,低调大师

C#隐藏方法

不能删除基类的任何成员,但可以用与基类成员相同的成员来屏蔽基类成员 屏蔽数据成员:派生类中声明名称和类型相同的成员 屏蔽函数成员:在派生类中声明新的带有函数签名的成员 让编译器知道:添加new关键字,否则会警告 pet------------------------------------petpublic sting name;---------------------public string name;public void PrintName();---------------public void PrintName(); -----------------------------------------------------------Dog---------------------------------------new public void PrintName();

优秀的个人博客,低调大师

Hbase 使用方法

列出所有table¶ hbase(main):> list 新增table¶ A . 直接增加一個表 t2 hbase(main):> create 't2' B . 增加一個擁有 'f1','f2','fn' 為 column family 的表: t1 hbase(main):> create 't1','f1','f2','fn' 查詢 Table 欄位¶ hbase(main):> describe 't1' 執行結果參考 hbase(main):> describe 't1' DESCRIPTION ENABLED {NAME => 't1', FAMILIES => [{NAME => 'f1', COMPRESSION => 'NONE', VERS true IONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => ' false', BLOCKCACHE => 'true'}, {NAME => 'f2', COMPRESSION => 'NONE', V ERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY = > 'false', BLOCKCACHE => 'true'}, {NAME => 'fn', COMPRESSION => 'NONE' , VERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMOR Y => 'false', BLOCKCACHE => 'true'}]} 加入cell-value¶ 需先擁有表 t1 與column-family: f1 並且加入一個 column-quantifier c1 hbase(main):> put 't1', 'r1', 'f1', 'v1' hbase(main):> put 't1', 'r1', 'f1:c1', 'v2' hbase(main):> put 't1', 'r2', 'f2', 'v3' hbase(main):> put 't1', 'r2', 'f2:c2', 'v4' Table: 't1' row-key 'f1' 'f2' 'fn' column-family * 'c1' * 'c2' * column-quantifier r1 v1 v2 r2 v3 v4 列出cell-value¶ A . 列出一列(row) hbase(main):> get 't1', 'r1' 執行結果參考 COLUMN CELL f1: timestamp=1285737082689, value=v1 f1:c1 timestamp=1285737085874, value=v2 Table: 't1' row-key 'f1' 'f2' 'fn' column-family * 'c1' * 'c2' * column-quantifier r1 v1 v2 r2 v3 v4 B . 列出一個 cell 的值 hbase(main):> get 't1', 'r1', {COLUMN => 'f1:c1'} 執行結果參考 COLUMN CELL f1:c1 timestamp=1285737085874, value=v2 Table: 't1' row-key 'f1' 'f2' 'fn' column-family * 'c1' * 'c2' * column-quantifier r1 v1 v2 r2 v3 v4 刪除 cell-value¶ hbase(main):> deleteall 't1','r1' 執行結果:會把 row-key 是 'r1' 的所有紀錄。此時資料表 't1' 會變成如下表所示。 hbase(main):> scan 't1' ROW COLUMN+CELL r2 column=f2:, timestamp=1285737091644, value=v3 r2 column=f2:c2, timestamp=1285737094157, value=v4 Table: 't1' row-key 'f1' 'f2' 'fn' column-family * 'c1' * 'c2' * column-quantifier r2 v3 v4 加入column family¶ hbase(main):> disable 't1' hbase(main):> alter 't1', {NAME => 'f3'} hbase(main):> enable 't1' 執行結果:多了一個 column-family 'f3' 可以用 describe 指令查詢,結果示意如下表: hbase(main):021:0> describe 't1' DESCRIPTION ENABLED {NAME => 't1', FAMILIES => [{NAME => 'f1', COMPRESSION => 'NONE', VERS true IONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => ' false', BLOCKCACHE => 'true'}, {NAME => 'f2', COMPRESSION => 'NONE', V ERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY = > 'false', BLOCKCACHE => 'true'}, {NAME => 'f3', VERSIONS => '3', COMP RESSION => 'NONE', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMOR Y => 'false', BLOCKCACHE => 'true'}, {NAME => 'fn', COMPRESSION => 'NO NE', VERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_ME MORY => 'false', BLOCKCACHE => 'true'}]} Table: 't1' row-key 'f1' 'f2' 'f3' 'fn' column-family * 'c1' * 'c2' * * column-quantifier r2 v3 v4 刪除column family¶ hbase(main):> disable 't1' hbase(main):> alter 't1', {NAME => 'f1', METHOD => 'delete'} hbase(main):> enable 't1' 執行結果:會移除 column family 為 'f1' 的所有欄位,可用 describe 指令確認,結果如下表所示。 hbase(main):053:0> describe 't1' DESCRIPTION ENABLED {NAME => 't1', FAMILIES => [{NAME => 'f2', COMPRESSION => 'NONE', VERS true IONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => ' false', BLOCKCACHE => 'true'}, {NAME => 'f3', COMPRESSION => 'NONE', V ERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY = > 'false', BLOCKCACHE => 'true'}, {NAME => 'fn', COMPRESSION => 'NONE' , VERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMOR Y => 'false', BLOCKCACHE => 'true'}]} 1 row(s) in 0.0200 seconds Table: 't1' row-key 'f2' 'f3' 'fn' column-family * 'c2' * * column-quantifier r2 v3 v4 節點狀態¶ hbase(main):> status 刪除整張table¶ hbase(main):> truncate 't1' 執行完 truncate 後,所有 't1' 的內容都會被移除。但此時,下 list 還會有 't1' 這個表格存在。 hbase(main):> disable 't1' hbase(main):> drop 't1' 要完整移除 't1' 資料表,必須使用 disable 先將 't1' 停用,再用 drop 指令把 't1' 完全刪除。 转自:http://trac.nchc.org.tw/cloud/wiki/NCHCCloudCourse100929_2_USE 本文转自茄子_2008博客园博客,原文链接:http://www.cnblogs.com/xd502djj/p/3401078.html,如需转载请自行联系原作者。

优秀的个人博客,低调大师

视频静音的方法

所谓静音,就是没有声音,把音量调到最小不就好了。所以,只要调节音量就行。那么,这样就很简单了,系统给我们提供了属性啊。 在AVPlayer中,有属性 @property (nonatomic) float volume NS_AVAILABLE(10_7, 7_0); 看注释: /* Indicates the current audio volume of the player; 0.0 means "silence all audio", 1.0 means "play at the full volume of the current item". iOS note: Do not use this property to implement a volume slider for media playback. For that purpose, use MPVolumeView, which is customizable in appearance and provides standard media playback behaviors that users expect. This property is most useful on iOS to control the volume of the AVPlayer relative to other audio output, not for volume control by end users. */ 所以: 关: self.avPlayer.volume = 0.0; 开: self.avPlayer.volume = 1.0;

优秀的个人博客,低调大师

python学习方法

#/usr/bin/envpython #-*-coding=utf-8-*- #@author:wklken@yeah.net #@version:0.1 #@date:2012-08-25 #@desc:python学习线路 step defread(book=<<AByteofPython>>)#网上先过一遍 if没兴趣: return else: if没编程基础: <<HeadFirstPython>> ifneedpy2.x: <<Python核心技术>> elifpy2.xandpy3k: <<LearningPython>> ifyouwant:#可选 <<PythonTutorial>> ifyouhavemoretimeandenergy: <<可爱的Python>> <<ProgrammingPython>> print"Info:基本入门了" ifyouwantgofarther: ifTrue:#强烈建议 <<DiveIntoPython>> <<Python源码剖析>> <<Python高级编程>>#这个,没读过,自己判定吧 if工作需要: <<Python网络编程>>#网络编程 <<Python在Unix和Linux系统管理中的应用>>#系统管理相关 <<TheDjangoBook>>#web,用到django框架的 <<Djangoweb开发指南>>#同上 <<集体智慧编程>>#算法工程师,or个人爱好 <<Python自然语言处理>> ifyouwanttosearchforsomethinguseful: <<PythonstandardLibrary>> <<Pythoncookbook>> or 向Python女神推荐这些年我追过的经典书籍 or Linux运维人员如何学习python编程 or Python|绝不乱入的靠谱书单 以看过的书例子为总结 本文转自 liqius 51CTO博客,原文链接:http://blog.51cto.com/szgb17/1844823,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册