我有一个原子列的图像,我想存储每个原子列的最大值的 X 和 Y 坐标,但我不知道如何编写脚本来将一堆数据存储为数组。请帮我。
问问题
452 次
1 回答
1
我不确定我是否理解这个问题,但如果您只是想在“数组”中存储多个值,那么您只需要认识到任何 2D 图像已经是一个数组。如果要存储 n 个 XY 对值,则可以简单地创建一个 [nx 2] 图像并将值存储在那里。一些例子:
number n = 30 // number of pairs
image data := Realimage( "Data Array", 4, 2 , n )
for( number i = 0 ; i < n ; i++ )
{
number xValue = i * 10 // just something
number yValue = xValue * sin( xValue / 100 * PI() ) // just something
data.SetPixel(0, i, xValue ) // Set X at position i (first column)
data.SetPixel(1, i, YValue ) // Set Y at position i (second column)
}
data.ShowImage()
// You may want to display the image as "Spreadsheet". (Type 7)
data.ImageGetImageDisplay(0).ImageDisplayChangeDisplayType(7)
// And you may want to label the columns
data.ImageGetImageDisplay(0).SpreadSheetImageDisplaySetColumnLabel( 0, "X values" )
data.ImageGetImageDisplay(0).SpreadSheetImageDisplaySetColumnLabel( 1, "Y values" )
您不必使用SetPixel()
. 您还可以通过索引位置来设置像素值。
data[0, i] = xValue // Same as: data.SetPixel( 0, i, xValue )
于 2017-05-27T21:09:03.870 回答