- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
背景我正在编写一个程序来计算星系的表面亮度作为椭圆半径的函数。这首先涉及读取一个 .fits 文件,该文件存储在一个 numpy 数组中,这样 array[x][y] 将返回该 (x,y) 像素处的表面亮度值。
要计算表面亮度,我需要能够以某个最小尺寸将椭圆拟合到星系,并找到该椭圆内的表面亮度中值,然后增加椭圆的尺寸并找到每个环的表面亮度。不同大小的环将循环通过,直到表面亮度下降到与背景噪声的特定比率以下。
问题给定的椭圆参数包括位置角、x 和 y 像素的中心坐标以及 B/A 比率。我很难找到任何一种方法来让我将一个椭圆拟合到一个数组数组中。请帮助??
最佳答案
我想我可能在涉及劳厄衍射图案( Material 科学)的研究项目中处理过与您的问题类似的问题。我的任务是在给定每个峰的中心坐标的情况下,找出衍射图中每个峰的长度、宽度和倾斜角。我的解决方案是在峰值和阈值、过滤器等周围选择一个感兴趣的区域,这样子图像中只有一个峰值。然后我构建了一个函数来将这些参数拟合到生成的椭圆中:
from xml.etree.cElementTree import parse
import numpy as np
from os import listdir, getcwd
from scipy import ndimage
import h5py
import multiprocessing
import time
#from dicttoxml import dicttoxml
#from xml.dom.minidom import parseString
import sys
import cPickle as pickle
from threading import Thread
from skimage.measure import moments
def fitEllipse(data):
'''
Returns the length of the long and short axis and the angle measure
of the long axis to the horizontal of the best fit ellipsebased on
image moments.
usage: longAxis, shortAxis, angle = fitEllipse(N_by_M_image_as_array)
'''
# source:
# Kieran F. Mulchrone, Kingshuk Roy Choudhury,
# Fitting an ellipse to an arbitrary shape:
# implications for strain analysis, Journal of
# Structural Geology, Volume 26, Issue 1,
# January 2004, Pages 143-153, ISSN 0191-8141,
# <http://dx.doi.org/10.1016/S0191-8141(03)00093-2.>
# Lourena Rocha, Luiz Velho, Paulo Cezar P. Carvalho
# Image Moments-Based Structuring and Tracking of
# Objects, IMPA-Instituto Nacional de Matematica Pura
# e Aplicada. Estrada Dona Castorina, 110, 22460
# Rio de Janeiro, RJ, Brasil,
# <http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=1167130>
m = moments(data, 2) # super fast compated to anything in pure python
xc = m[1,0] / m[0,0]
yc = m[0,1] / m[0,0]
a = (m[2,0] / m[0,0]) - (xc**2)
b = 2 * ((m[1,1] / m[0,0]) - (xc * yc))
c = (m[0,2] / m[0,0]) - (yc**2)
theta = .5 * (np.arctan2(b, (a - c)))
w = np.sqrt(6 * (a + c - np.sqrt(b**2 + (a-c)**2)))
l = np.sqrt(6 * (a + c + np.sqrt(b**2 + (a-c)**2)))
return l, w, theta
我只是把它放在一起,以防它与您要找的东西相似。如果您需要更多解释,请随时发表评论。我使用的来源(数学)在评论中。
关于python - 从 numpy 数组计算椭圆内的像素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31163133/
为什么这个脚本不起作用?仅当页面宽度超过 915 像素时,我希望单击按钮时滚动页面 100 像素。我试图通过仅在宽度超过 915 像素时允许该函数运行来实现此目的,但它没有发生。怎么办? $(docu
我需要您帮助我建立一个网站。我是一个新手,已经得到了一个设计为 900 像素宽的主体,但他们给了我一个 1200 像素宽的图像。他们希望图像跨越整个 1200 像素的宽度,因此页面两侧基本上会有 30
我有一个在 y 轴上展开的 UIScrollview 并调用这个委托(delegate)方法: -(void)scrollViewDidScroll:(UIScrollView *)scrollVie
我有一个固定的标题这个标题在我滚动时改变高度和图像标志但是当我调整窗口大小时我希望图像保持比例但随着我缩小浏览器而变得更小标志只有在限制时缩小浏览器靠近图像,但我希望在调整浏览器大小时图像变小。 我该
在我的项目中,我使用 ArcGIS API for JavaScript https://developers.arcgis.com/javascript/但是对于(在这里插入非常大的坏词)我无法覆盖
有没有办法使用 jQuery,根据窗口滚动的距离做不同的事情? 这是我现在使用的代码; $(document).scroll(function() { // If scroll distanc
这基本上是 Jetpack Joyride 中运动的基本版本,但不是 Joyrider 以每秒 100 像素的速度下降,而是字母“x”从控制台的正中间以每秒 100 像素的速度下降和点击事件会导致它以
我像这样处理 MINMAXINFO: case WM_GETMINMAXINFO: { LPMINMAXINFO p_info = (LPMINMAXINFO)lPar
我对 javascript 有点陌生,我一直在查找 documentElement、clientWidth 和 clientHeight 并试图找出为什么它将我的 Canvas 设置为 300px x
我正在编写一些软件来读取 DICOM 文件,但我不确定如何处理具有未定义长度的标签。标准是这样说的 “如果值字段具有显式长度,则值长度字段应包含等于长度(以字节为单位)的值 值字段。否则,值字段 有一
我对 OpenGL 有点陌生,但我很确定我的问题在于所使用的像素格式,或者我的纹理是如何生成的...... 我正在使用 16 位 RGB5_A1 像素格式在平面 2D 四边形上绘制纹理,但在这个阶段我
有没有办法获取直播电视流,例如在像素级别上进行分析。 我的目标是检查直播电视流(例如使用java),例如广播电台 Logo 是否可见。 有机会通过 Google 电视观看此直播吗? 是否有机会通过笔记
我正在尝试构建一个函数,它以给定角度从特定坐标延伸,并循环遍历该线上的像素,直到遇到黑色像素. 如果角度为 180 度,这很容易实现。在这种情况下,搜索只会向下扩展,在每次迭代中将列坐标加 1。然而,
我已经研究了一段时间,但找不到任何解决方案。 这是我的代码 如果您将此代码复制并粘贴到本网站的 HTML 区域:http://jsfiddle.net/T3Nnu/3/ 如果您查看 Facebo
我有一个网页 - http://bit.ly/YHFX5B如果你看一下页脚,你会发现它后面有一些额外的白色像素/线条。我不明白他们是从哪里来的。 请告知他们可能来自哪里。 谢谢,丹 最佳答案 在 #f
如何在没有状态栏和操作栏的情况下获取屏幕高度(像素)或者如果有人告诉我如何获取状态栏和操作栏的高度,它也会有所帮助。我已经找到了屏幕高度,但它包括状态栏和操作栏.我将支持库 v7 用于操作栏。我在网上
Java 字符串根据宽度(像素)换行 在一些场景下,我们经常会通过判断字符串的长度,比如个数来实现换行,但是中文、英文、数字、其实在展示的时候同样长度的字符串,其实它的宽度是不一样的,这也是们我通
我创建了一个不错的简单可扩展列表。它应该像单选列表一样工作,您应该只能选择一个元素。我还没有实现这部分,因为我对列表的大小有疑问: class ExpandableListRadio extends
我使用以下代码滚动到元素顶部,但我想滚动到元素顶部上方 10px,不知道如何执行此操作,有什么建议吗?谢谢! $('html, body').stop(true,true).animate({
我有一个链接,可以在滚动时更改其垂直位置。当我点击此链接时,我想(平滑地)转到页面上的某个位置,该位置距离页面顶部正好 1080 像素。 我无法实现它,希望有人能帮助我。 链接: 脚本: $(do
我是一名优秀的程序员,十分优秀!