简体   繁体   English

在2D阵列中的圆上积分

[英]Integrating over a circle in a 2D array

I'm trying to integrate over the area of a circular aperture superimposed on an array of pixels (see image below). 我正在尝试对叠加在像素阵列上的圆形孔径区域进行积分(请参见下图)。 However, I need to determine the fraction of flux (area) inside the circular aperture, and leave out anything outside the circular aperture in each square pixel on the boundary of the circle. 但是,我需要确定圆形孔内的通量(面积)的分数,并在圆的边界上的每个正方形像素中的圆形孔外保留任何东西。

How would I go about coding this in numpy/python such that I am getting an accurate measure of the flux inside the circle? 我该如何用numpy / python进行编码,以使我能够准确测量圆内部的通量?

在此处输入图片说明

Calculate the proportion of each pixel that is within the circle using calculus. 使用微积分计算圆内每个像素的比例。 (Integrate the equation of your circle between the left-right boundaries of the each.) (对每个圆弧的左右边界之间的圆方程进行积分。)

  1. Draw a white circle on a black background of the radius you're after in an image editor of your choice, and save a bitmap of your output 在您选择的图像编辑器中,在半径为黑色的黑色背景上绘制一个白色圆圈,然后保存输出的位图
  2. Load the image in your code, with scipy.misc.imload , and divide the pixel values by 255 so you have a mask in 0.0...1.0 使用scipy.misc.imload将图像加载到代码中,然后将像素值除以255,以便在0.0...1.0设置蒙版
  3. Calculate the sum of the product of that mask with your data to integrate 计算该掩码与数据的乘积之和以进行积分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM