我的项目有验证像素是否具有所需的可靠性,根据其分类将其作为边缘的方法。 然后,按如下方式绘制像素。
white-pixel doesn ' thavetherequiredreliability
blue-pixelhastherequiredreliabilityanditwasclassifiedasnotedge
red-pixelhastherequiredreliabilityanditwasclassifiedasanedge这是我的代码:
ef generate _ data _ reliability (class ification _ mean,data_uncertainty,x_axis_label,y_axis_label,
file_path,reliability(:
''''
3360 class ification _ mean 3360 givenasetofimages,howwasthemeanclassificationforeachpixel
3360 param data _ uncertainty 3360 theuncertaintyabouttheclassification
3360 paramx _ axis _ label 3360 thexaxislabelofthedata
33660 paramy _ axis _ label : theyaxislabelofthedata
33660 param plot _ title 3360 thetitleofthedata
3360 paramfile _ path : thenameofthefile
''''
plt.figure (
#0-中心
#1-不中断
r=0
b=0
w=0
has _ reliability=numpy.zeros ((data _ uncertainty.rows,data_uncertainty.cols ),float ) ) ) )。
for x,yin product (范围(data_uncertainty.cols ),范围(data_uncertainty.cols ) ) :
# itheuncertaintyisthentherequiredreliability,doesn't show it
if data _ uncertainty.data [ x ] [ y ] [ 1.0-reliability ] :
has_reliability[x][y]=0.5
w =1
else:
has _ reliability [ x ] [ y ]=class ification _ mean.data [ x ] [ y ]
if has _ reliability [ x ] [ y ]==1.0:
r =1
if has _ reliability [ x ] [ y ]==0.0:
b =1
print reliability,w r b,w,r,b
PLT.title(plot_title ) )。
PLT.imshow(has_reliability,extent=[0,classification_mean.cols,classification_mean.rows,0],cmap
PLT.xlabel(x_axis_label ) ) )。
PLT.ylabel(y_Axis_label ) )。
PLT.savefig(file_path'.png ' )。
plt.close (这是我收到的印刷品:
预微信
0.8 95100 10329 0 84771
0.9 95100 12380 0 82720
0.99 95100 18577 0 76523显示,随着所需可靠性的提高,像素数越少,可靠性越高(其中更多像素为白色,没有一个红色像素)。
但这是我得到的一集:
我不知道为什么,如果我有更少的像素和需要的可靠性,我就没有得到更多的白色像素,但是这些红色像素。 我不会改变我的对象,也不会惹怒他们。 hxdgb/p我在大约三个小时内遇到了这个问题。 我不知道哪里出了问题。
编辑:
在这个cmap中,0是蓝色,0.5是白色,1是红色,对吧? 我确信问题在于使用分色颜色映射,因此可能没有中心值。 例如,如果我发表的话,因为我没有红色的值,所以我的值在0.5和1之间变化。 然后,matplotlib会自动将我的最小值设置为红色,将我的最大值设置为蓝色。 但是你怎么能这样做? 我想选择这个理由,在方案中显示颜色。 0=蓝色,0.5=白色,1=红色(我的值始终为0、0.5或1 )。
任何援助我都非常感谢。
先谢谢你。