4

背景 私は、銀河の表面の明るさを楕円半径の関数として計算するプログラムを書いています。これには、最初に .fits ファイルの読み取りが含まれます。このファイルは、配列 [x][y] がその (x,y) ピクセルで表面の明るさの値を返すように、numpy 配列に格納されます。

表面の明るさを計算するには、ある最小サイズで楕円を銀河に当てはめ、その楕円内の表面の明るさの中央値を見つけ、次に楕円のサイズを大きくして、各年輪の表面の明るさを見つけられるようにする必要があります。表面の明るさが背景ノイズに対して特定の比率を下回るまで、さまざまなサイズの年輪がループされます。

問題 楕円の所定のパラメータには、位置角度、x および y ピクセルの中心座標、および B/A の比率が含まれます。楕円を本質的に配列の配列に適合させる方法を見つけるのに苦労しています。助けてください??

4

1 に答える 1

1

ラウエ回折パターン (材料科学) を含む私の研究プロジェクトで、あなたと同様の問題に取り組んだ可能性があると思います。私は、各ピークの中心座標が与えられたときに、回折パターンの各ピークの長さ、幅、および傾斜角を見つけることを任されました。私の解決策は、サブ画像にピークが1つだけになるように、ピークとしきい値、フィルターなどの周りの関心領域を選択することでした。次に、これらのパラメーターを結果の楕円に合わせる関数を作成しました。

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

あなたが探していたものと似ている場合に備えて、これをまとめました. さらに説明が必要な場合は、お気軽にコメントしてください。私が使用したソース (数学) はコメント内にあります。

于 2015-07-01T14:05:50.830 に答える