当前位置:网站首页>对灰度图像的三维函数显示
对灰度图像的三维函数显示
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')
此函数显示三维的函数在三维坐标显示。

边栏推荐
- Chapter VI succession
- Redis cluster deployment based on redis6.2.4
- 新版selenium4.3在egde浏览器的无头模式
- Mindoc makes mind map
- 基于redis6.2.4的redis cluster部署
- Google Earth engine - download the globalmlbuildingfootprints vector collection of global buildings
- unity 最好用热更方案卧龙 wolong
- How to prevent the unburned gas when the city gas safety is alarmed again?
- 01.两数之和
- 华泰vip账户证券开户安全吗
猜你喜欢
![[knowledge atlas] practice -- Practice of question answering system based on medical knowledge atlas (Part4): problem analysis and retrieval sentence generation combined with problem classification](/img/22/01297d28e5bfb105fc65ee29248a7c.png)
[knowledge atlas] practice -- Practice of question answering system based on medical knowledge atlas (Part4): problem analysis and retrieval sentence generation combined with problem classification

超越 ConvNeXt、RepLKNet | 看 51×51 卷积核如何破万卷!

Step by step introduction of sqlsugar based development framework (13) -- package the upload component based on elementplus, which is convenient for the project

How to deploy applications on IPFs using 4everland cli

Chapter III data types and variables

Starting from business needs, open the road of efficient IDC operation and maintenance

Budget report ppt

Mindoc makes mind map

How to delete Microsoft Pinyin input method in win10

多租户软件开发架构
随机推荐
Chapter III data types and variables
Budget report ppt
win10设备管理认不到GTX1080Ti 显示设备的解决办法
Wu Enda logistic regression 2
Getting started with easyUI
理财有保本产品吗?
我们被一个 kong 的性能 bug 折腾了一个通宵
[target detection] yolov5 Runtong voc2007 dataset (repair version)
EasyUI drop-down box, add and put on and off shelves of products
Update 3dcat real time cloud rendering V2.1.2 release
Hcip notes 11 days
【redis】redis安装
Why 4everland is the best cloud computing platform for Web 3.0
Summary of 80 domestic database operation documents (including tidb, Damon, opengauss, etc.)
Sogou batch push software - Sogou batch push tool [2022 latest]
The gas is exhausted! After 23 years of operation, the former "largest e-commerce website in China" has become yellow...
With 8 years of product experience, I have summarized these practical experience of continuous and efficient research and development
【目标检测】YOLOv5跑通VOC2007数据集(修复版)
Random talk on generation diffusion model: DDPM = Bayesian + denoising
[target detection] tph-yolov5: UAV target detection based on Transformer's improved yolov5