资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

python伪彩图函数 matlab绘制伪彩图

python matplotlib.pyplot.imshow 函数画二维颜色图

matplotlib.pyplot.imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, vmin=None, vmax=None, origin=None, extent=None, *, filternorm=True, filterrad=4.0, resample=None, url=None, data=None, **kwargs)

发展壮大离不开广大客户长期以来的信赖与支持,我们将始终秉承“诚信为本、服务至上”的服务理念,坚持“二合一”的优良服务模式,真诚服务每家企业,认真做好每个细节,不断完善自我,成就企业,实现共赢。行业涉及隧道混凝土搅拌车等,在成都网站建设公司成都全网营销推广、WAP手机网站、VI设计、软件开发等项目上具有丰富的设计经验。

From:

改以下参数可以对图片效果进行调整:

举个栗子:

divmod在python中是什么意思?

divmod在python中是内置函数。

divmod函数是Python的内置函数,它可以把除数和余数运算结果结合起来,返回一个包含商和余数的元组(a // b,a % b)。divmod()是python标准库的一部分,该库以两个数字作为参数,并将其除法的商和余数作为元组给出。它在许多数学应用中很有用,例如检查数字的可除性并确定数字是否为质数。

在下面的示例中,查看整数和浮点数的情况。在divmod()它们的应用上,我们得到一个结果元组,该元组也可以包含整数和浮点值。#with integers

print("5 and 2 give:",divmod(5,2))

print("25 and 5 give:",divmod(25,5))

# with Floats

print("5.6 and 2 give:",divmod(5.6,2))

print("11.3 and 9.2 give:",divmod(11.3,9.2))

输出结果

运行上面的代码给我们以下结果-5 and 2 give: (2, 1)

python opencv image 怎么变成伪彩色

OpenCV 生成 伪彩色图像

opencv中没有易用的伪彩色图像生成函数,这里提供一个改造过的函数,利用自定义colorbar 将灰度图像转换成为伪彩色图像,优点在于提供了对于颜色的直观可操控性,转换方便。

函数代码如下:

[cpp] view plain copy 在CODE上查看代码片派生到我的代码片

//function : Pseudo color - enhanced

//author : Xin Yang, Shenzhen Univ., School of medicine

//email : xinyang@szu.edu.cn

//date : 2015.01.23

void C_Assistant::Gray2PseudoColor(IplImage* src ,IplImage *dst)

{

if(dst != NULL)

{

cvReleaseImage(dst);

dst = NULL;

}

dst = cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 3);

IplImage *R, *G,*B;

//Load referred color bar

std::string HeatMapPath = "..\\ColorBar.png";

IplImage* heatmap = cvLoadImage(HeatMapPath.c_str());

//we split the heatmap along the 3 channels

R = cvCreateImage(cvGetSize(heatmap), heatmap-depth,1);

G = cvCloneImage(R);

B = cvCloneImage(R);

cvSplit(heatmap,B,G,R,NULL);

for(int x=0; xsrc-width; x++)

{

for(int y=0;ysrc-height; y++)

{

//memory access to the destination color image (faster than splitting the 3 channels...)

unsigned char *data = ((unsigned char*)(dst-imageData + dst-widthStep*y ))[x*3];

//read the intensity value in the grayscale image

unsigned char gray = src-imageData[src-widthStep*y + x*src-nChannels];

//remember, OpenCV store images as BGR internally !

//So access [2] for Red, [1] for Green et [3] for Blue

float ColorIndex = gray/255.0*heatmap-height;

if(ColorIndex = heatmap-height) ColorIndex = heatmap-height - 1;

data[2] = cvGet2D(R, ColorIndex, 1).val[0]; //Red channel

data[1] = cvGet2D(G, ColorIndex, 1).val[0]; //Green channel

data[0] = cvGet2D(B, ColorIndex, 1).val[0]; //Blue channel

}

}

//Clear

if(heatmap != NULL)

{

cvReleaseImage(heatmap);

heatmap = NULL;

}

}

参考可用的colorbar如下,也可以自己生成来替换。

python函数图的绘制

pre

import numpy as np

import matplotlib.pyplot as plt

from matplotlib.patches import Polygon

def func(x):

return -(x-2)*(x-8)+40

x=np.linspace(0,10)

y=func(x)

fig,ax = plt.subplots()

plt.plot(x,y,'r',linewidth=2)

plt.ylim(ymin=20)

a=2

b=9

ax.set_xticks([a,b])

ax.set_xticklabels(['$a$','$b$'])

ax.set_yticks([])

plt.figtext(0.9,0.05,'$x$')

plt.figtext(0.1,0.9,'$y$')

ix=np.linspace(a,b)

iy=func(ix)

ixy=zip(ix,iy)

verts=[(a,0)]+list(ixy)+[(b,0)]

poly = Polygon(verts,facecolor='0.9',edgecolor='0.5')

ax.add_patch(poly)

x_math=(a+b)*0.5

y_math=35

plt.text(x_math,y_math,r"$\int_a^b(-(x-2)*(x-8)+40)dx$",horizontalalignment='center',size=12)

plt.show()

/pre


当前文章:python伪彩图函数 matlab绘制伪彩图
链接分享:http://cdkjz.cn/article/dosciid.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220