问题描述
编辑:我决定将这个问题分成两部分,因为它实际上是两个问题:1。如何在MATLAB(这个问题)和
因为MATLAB将图像存储为矩阵,极坐标我不完全匹配矩阵的'bins'。因此,我们目前使用插值算法将极坐标放入方阵中。但是,这非常慢。我看到两种方法可以解决这个问题:
- 让MATLAB直接将数据点绘制为极坐标。
一些基本信息:
输入矩阵大小:512×960
当前输出矩阵大小:1024×1024
问题解决了(除了一个小缺陷),部分原因是KM Shihab Uddin指出了我正确的方向。不幸的是,使用冲浪意味着不断地在图中绘制图像,这也很慢。
因此,对于每个X和Y组合,我在X和Y值中都有单独的矩阵和灰度值(在一个名为C的矩阵中)。
我发现pcolor只是从顶部观察冲浪。所以我使用以下代码绘制我的图表。
冲浪(X,Y,C * 255)
查看([0,0,500])
然而,这给了我一个完全黑色的图像。这是因为在我的情况下,surf(和pcolor)在径向上创建了960个网格线。解决方案是使用:
surf(X,Y,img2 * 255,'EdgeColor','none')
查看([0,0,500])
现在我有一个近乎完美的形象,就像我有之前。只有在我的960个径向线中,一个是白色的,所以我仍然必须解决这个问题。但是,我觉得这是函数surf的技术细节,回答这部分并不属于这个问题。
edit: I decided to split this question into two parts, because it were really two questions: 1. how to make a polar surface plot in MATLAB (this question) and 2. how to put fit polar data points into a coarse (and non-polar) matrix
I have a matrix that contains certain grey values (values between zero and one). These points are stored in a rectangular matrix, but really the data points are acquired by rotating the detector. This means that I actually have polar coordinates (I know the polar coordinates for every single pixel in my starting matrix).
I want to make a polar plot of the data points. I have the example of this below.
Because MATLAB stores images as matrices, the polar coordinates I have do not exactly match the 'bins' of the matrix. Therefore, we currently use an interpolation algorithm to put the polar coordinates into a square matrix. However, this is extremely slow. I see two methods to solve this issue:
- let MATLAB directly plot the data points as polar.
Some basic information:
Input matrix size: 512×960
Current output matrix size: 1024×1024
The question was solved (apart from a minor flaw), partially because K.M. Shihab Uddin pointed me in the right direction. Unfortunately, using surf means continuously really plotting the image in a figure, and this is slow as well.
So I have X and Y values both in separate matrices and greyscale values (in a matrix called C) for every X and Y combination.
I found out that pcolor is just surf with a viewpoint from the top. So I used the following code to plot my graph.
surf(X,Y,C*255)
view([0,0,500])
However, this gave me a completely black image. This is because surf (and pcolor) create 960 grid lines radially in my case. The solution is to use:
surf(X,Y,img2*255,'EdgeColor','none')
view([0,0,500])
Now I have an almost perfect image, like I had before. Only, of my 960 radial lines, one is left white, so I still have to solve that. However, I feel this is a technical detail of the function surf, and answering this part does not belong in this question.
这篇关于Matlab:极坐标灰度图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!