我在Python OpenCV中加载彩色图像并绘制相同的图像.然而,我得到的图像的颜色都混淆了.
这是代码:
import cv2
import numpy as np
from numpy import array, arange, uint8
from matplotlib import pyplot as plt
img = cv2.imread('lena_caption.png', cv2.IMREAD_COLOR)
bw_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
images = []
images.append(img)
images.append(bw_img)
titles = ['Original Image','BW Image']
for i in xrange(len(images)):
plt.subplot(1,2,i+1),plt.imshow(images[i],'gray')
plt.title(titles[i])
plt.xticks([]),plt.yticks([])
plt.show()
Run Code Online (Sandbox Code Playgroud)
这些索引到PHP数组的方法之间有什么区别(如果有的话):
$array[$index]
$array["$index"]
$array["{$index}"]
Run Code Online (Sandbox Code Playgroud)
我对性能和功能差异感兴趣.
(回应@Jeremy)我不确定这是对的.我运行了这段代码:
$array = array(100, 200, 300);
print_r($array);
$idx = 0;
$array[$idx] = 123;
print_r($array);
$array["$idx"] = 456;
print_r($array);
$array["{$idx}"] = 789;
print_r($array);
Run Code Online (Sandbox Code Playgroud)
得到了这个输出:
Array
(
[0] => 100
[1] => 200
[2] => 300
)
Array
(
[0] => 123
[1] => 200
[2] => 300
)
Array
(
[0] => 456
[1] => 200
[2] => 300
)
Array
(
[0] => 789
[1] => 200
[2] => 300
)
Run Code Online (Sandbox Code Playgroud) 我正在使用Mac和MacVim 7.3.
我有一个符号链接〜/ some/symlink,它是一个真实文件〜/ some/actual_file的链接.
当我"vim~/some/symlink"时,它会在vim中显示文件,其中vim的状态行名称为〜/ some/symlink,这是有道理的.
如何从vim中获取"真实"文件〜/ some/actual_file的完整路径?我希望vim状态行说〜/ some/actual_file而不是〜/ some/symlink.
我期望vim函数resolve()可以工作,给出它的帮助描述(粘贴在下面),但是resolve("〜/ some/symlink")返回〜/ some/symlink,所以没有帮助.
我错过了什么?谢谢!
resolve({filename}) *resolve()* *E655*
On MS-Windows, when {filename} is a shortcut (a .lnk file),
returns the path the shortcut points to in a simplified form.
On Unix, repeat resolving symbolic links in all path
components of {filename} and return the simplified result.
To cope with link cycles, resolving of symbolic links is
stopped after 100 iterations.
On other systems, return the simplified {filename}.
Run Code Online (Sandbox Code Playgroud) 我想在php中定义这样的东西:
$EL = "\n<br />\n";
Run Code Online (Sandbox Code Playgroud)
然后在我的网站上使用该变量作为"endline"标记,如下所示:
echo "Blah blah blah{$EL}";
Run Code Online (Sandbox Code Playgroud)
如何(在只有1个文件)定义$ EL一次,包括它在我的网站在每一页上,而不是必须使用(向后奇怪)引用它global $EL;的语句在每个页面的功能?
我想在我的vimrc文件中使用"map"映射一个键,如下所示:
map <C-I> :split ~/some/file
Run Code Online (Sandbox Code Playgroud)
该命令实际上工作正常.
我的问题是:如何从地图/分割线内的文件路径上调用vim函数(在本例中为"resolve()").这不起作用,但希望你明白这一点:
map <C-I> :split =resolve("~/some/file")
Run Code Online (Sandbox Code Playgroud)
也许它使用call()?我显然对vim脚本一般感到困惑.谢谢你的帮助!