当前位置:网站首页>对灰度图像的三维函数显示
对灰度图像的三维函数显示
2022-07-25 17:15:00 【无水先生】
一、提要
如何看到一幅图像的三维灰度分布?有的时候,需要清楚看到图像灰度和坐标的关系。这样尽量直观理解图像的数据详情。本篇讲述如何将灰度图的灰度gray和row和col组成的三维直观图形。本文记述如何用python实现。
二、问题提出
给出原图,显然,此图的光照不均,如果想去除首先要看到其函数走向:

三、将原图处理的程序是:
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# @File : Plt3D.py
from matplotlib import pyplot as plot # 用来绘制图形
import numpy as np # 用来处理数据
from mpl_toolkits.mplot3d import Axes3D # 用来给出三维坐标系。
import cv2
def getZ( img, X, Y ):
gray = img[X,Y]
return gray
img = cv2.imread("paper.jpg",0)
height,width = img.shape[:2]
figure = plot.figure()
# 画出三维坐标系:
axes = Axes3D(figure)
X = np.arange(0, height, 1)
Y = np.arange(0, width, 1)
# 生成二维的底部网格线:
X, Y = np.meshgrid(X, Y)
# Z = 3 * (X) ** 2 + 2 * (Y) ** 2 + 5
# 绘制曲面:
axes.plot_surface(X, Y, getZ(img,X,Y), cmap='rainbow')
# 显示图形:
plot.show()四、代码关键
4.1 面区域生成
给定两个定义域,X,Y,那么,X和Y联合区域S需要产生:

X, Y = np.meshgrid(X, Y)
注意:这里假如X = 【2,3,4】,Y=【7.8.9.10】那么经过以上语句后,
X = [ [2 3 4], [2 3 4], [2 3 4] , [2 3 4] ]
Y = [ [ 7 7 7], [ 8 8 8], [ 9 9 9], [10 10 10] ]
- 灰度如何获取?
def getZ( img, X, Y ):
gray = img[X,Y]
return gray- 灰度 gray = getZ(img,X,Y):
[ [70 70 67], [69 69 67], [67 67 68], [66 68 69] ]
五、处理后生成三维的可视图形
- 绘制语句
axes.plot_surface(X, Y, getZ(img,X,Y), cmap='rainbow')
此函数显示三维的函数在三维坐标显示。

边栏推荐
- China's chip self-sufficiency rate has increased significantly, resulting in high foreign chip inventories and heavy losses. American chips can be said to have thrown themselves in the foot
- Rosen's QT journey 100 QML four standard dialog boxes (color, font, file, promotion)
- 霸榜COCO!DINO: 让目标检测拥抱Transformer
- [target detection] yolov5 Runtong voc2007 dataset (repair version)
- PostgreSQL里有只编译语句但不执行的方法吗?
- EasyUI drop-down box, add and put on and off shelves of products
- Why 4everland is the best cloud computing platform for Web 3.0
- Postdoctoral recruitment | West Lake University Machine Intelligence Laboratory recruitment postdoctoral / Assistant Researcher / scientific research assistant
- 【PHP伪协议】源码读取、文件读写、任意php命令执行
- postgreSQL 密码区分大小写 ,有参数控制吗?
猜你喜欢
![[knowledge atlas] practice -- Practice of question answering system based on medical knowledge atlas (Part3): rule-based problem classification](/img/4c/aeebbc9698f8d5c23ed6473c9aca34.png)
[knowledge atlas] practice -- Practice of question answering system based on medical knowledge atlas (Part3): rule-based problem classification

HCIP笔记十二天

Budget report ppt

基于redis6.2.4的redis cluster部署

win10如何删除微软拼音输入法

Mindoc makes mind map

备考过程中,这些“谣言”千万不要信!

What is the monthly salary of 10000 in China? The answer reveals the cruel truth of income

Rainbond插件扩展:基于Mysql-Exporter监控Mysql

气数已尽!运营 23 年,昔日“国内第一大电商网站”黄了。。。
随机推荐
【目标检测】YOLOv5跑通VOC2007数据集(修复版)
「数字安全」警惕 NFT的七大骗局
unity 最好用热更方案卧龙 wolong
Rebudget: balance efficiency and fairness in market-based multi-core resource allocation by reallocating the budget at run time
Jenkins' role based authorization strategy installation configuration
Rainbond插件扩展:基于Mysql-Exporter监控Mysql
第四章:操作符
Add batch delete
Frustrated Internet people desperately knock on the door of Web3
China's chip self-sufficiency rate has increased significantly, resulting in high foreign chip inventories and heavy losses. American chips can be said to have thrown themselves in the foot
Hcip notes 12 days
[OBS] Reprint: what about the serious delay of OBS live broadcast and Caton?
Starting from business needs, open the road of efficient IDC operation and maintenance
Enterprise live broadcast: witness focused products, praise and embrace ecology
pgsql有没有好用的图形化管理工具?
[OBS] frame loss and frame priority before transmission
Chapter 4: operators
搜狗批量推送软件-搜狗批量推送工具【2022最新】
After 20 years of agitation, the chip production capacity has started from zero to surpass that of the United States, which is another great achievement made in China
Rosen's QT journey 99 QML table control tableview