- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在开发一个 C# 项目来减少阶梯光栅光谱,它基本上是 FITS 格式的 2D 16 位图像。目前,最终结果应该是另一个 FITS 文件,但是是一维的。
对于此任务,我使用 CSharpFits 库 ( https://github.com/SidWatch/CSharpFITS ),它是 Java 实现 ( https://github.com/nom-tam-fits/nom-tam-fits ) 的一个端口,所有文档都位于该库中。
我仍处于这个库的学习阶段。到目前为止,我可以成功读取 FITS 文件,将其转换为 int
数组的数组并处理数据。但是尝试编写一个 FITS 文件给了我一个我无法理解的特殊问题。以下代码作为玩具示例,产生如图所示的结果。
private void SaveFits()
{
int[][] array = new int[10][];
int delta = 65536 / 100;
for (int i = 0; i < array.Length; i++)
{
array[i] = new int[10];
for (int j = 0; j < array[i].Length; j++)
{
array[i][j] = (i + 1) * (j + 1) * delta;
}
}
nom.tam.fits.Fits fits = new nom.tam.fits.Fits();
nom.tam.fits.BasicHDU hdu = nom.tam.fits.Fits.MakeHDU(array);
hdu.AddValue("BITPIX", 16, null); // set bit depth of 16 bit
hdu.AddValue("NAXIS", 2, null); // 2D-image
fits.AddHDU(hdu); // Debugging here shows correct HDU-data, i.e. gradient from top left to bottom right
nom.tam.util.BufferedFile file = new nom.tam.util.BufferedFile(@"D:\test.fits", System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite);
fits.Write(file);
file.Flush();
file.Close();
}
pixel-representation of 10-by-10-pixel FITS-file
如您所见,代码应生成一个 16 位图像,具有从左上角到右下角的灰度渐变。创建 HDU 后,其数据数组的控制台输出读取
655 1310 1965 2620 3275 3930 4585 5240 5895 6550
1310 2620 3930 5240 6550 7860 9170 10480 11790 13100
1965 3930 5895 7860 9825 11790 13755 15720 17685 19650
2620 5240 7860 10480 13100 15720 18340 20960 23580 26200
3275 6550 9825 13100 16375 19650 22925 26200 29475 32750
3930 7860 11790 15720 19650 23580 27510 31440 35370 39300
4585 9170 13755 18340 22925 27510 32095 36680 41265 45850
5240 10480 15720 20960 26200 31440 36680 41920 47160 52400
5895 11790 17685 23580 29475 35370 41265 47160 53055 58950
6550 13100 19650 26200 32750 39300 45850 52400 58950 65500
然而在最终图像中(在 PixInsight 中查看,但任何其他可以显示 FITS 图像的程序显示相同)每隔一列只有值为 0 的像素,并且每隔一行重复第一行。
到目前为止,我已经尝试将 HDU 实际上创建为 ImageHDU
,但没有任何效果。我还检查了正确读取的 FITS 文件的 HDU header 字段,并尝试在我的文件中手动设置它们(使用 hdu.AddValue
),但到目前为止没有任何效果。可以在此处找到使用 CSharpFITS 编写 FITS 文件的几个示例 ( https://csharp.hotexamples.com/examples/nom.tam.fits/Fits/Write/php-fits-write-method-examples.html ),但除了我所做的以外,没有其他使用。
非常感谢您的建议。谢谢!
最佳答案
根据 Iguananauts 的评论,将 int
数组更改为 short
数组会得到预期的结果。
关于c# - CSharpFits : Writing FITS-file results in wrong image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64070763/
这个问题在这里已经有了答案: java.lang.IllegalArgumentException: The servlets named [X] and [Y] are both mapped t
我无法让我的 WebRTC 代码正常工作。我相信我所做的一切都是正确的,但它仍然无法正常工作。为什么 ontrack 这么早就被调用有些奇怪,也许它应该是那样的。 该网站使用 javascript 代
使用 Mac OSX 优胜美地 (10.10.4): rails -v => Rails 4.2.3 ruby -v => ruby 2.2.2p95 遵循这些说明的组合: https://www
您好,我正在尝试使用(缓存的)已编译的 lambda 表达式来访问属性,与使用 PropertyInfo.GetValue()/SetValue() 方法调用相比,我确实得到了更好(即更快)的结果。然
我编写此代码是为了获取学生的字母成绩并计算他们的 GPA。当我运行该程序时,我可以正确获取学生的姓名和科目,但无法显示成绩或 GPA。 示例输入: Sally 1 A N 示例输出: Enter St
我一直在编写这段代码,根据这本书应该可以做到这一点: Write a script that creates and calls a stored procedure named test. This
我真的很难创建一个具有以下基本格式的有效多维 JavaScript 数组: var countries = [ { "country": "UK", "properties": {
我有一个小型 Python OOP 程序,其中 2 个类 Flan 和 Outil 继承自父类(super class) Part。 我的问题是,当我调用 Flan 时一切正常,但是当我调用 Outi
我目前正在尝试使用通用监听器来编写事件系统。 所有监听器都应添加到单个 EventSource 对象,该对象将为特定事件调用其 receiveEvent() 方法。 事件源: public class
我正在通过我的 PHP 应用程序发送电子邮件。但是,它们被 Gmail 标记为垃圾邮件。这是我发送电子邮件的方式(PHP): $headers = "From: test@bookmytakeout.
我已经正式走到了穷途末路的地步。我找不到我做错了什么。我完成的这个程序几乎与我几天前编写的另一个程序一模一样,但我在编译时遇到了问题。我不知道为什么输出线上出现错误。请帮忙: 这是正在运行的文件: p
---编辑:我不允许使用任何包或预置方法。不用担心,我不想让你做我的“作业”,我只需要一点提示!---我发现these interesting Algorithms 。我想使用按位添加方法。我的问题是
我制作了一个小程序,尝试使用 conn.getOutputStream(); 检索 URLConnection 对象输出流。当我尝试执行此操作时,我的小程序抛出异常 java.net.UnknownS
每当我尝试在 SVN 中合并时,我都会遇到成堆的树冲突。好吧,就此示例脚本而言,只有一个,但仍然如此。 #!/bin/bash svnadmin create repo svn checkout fi
我开始为 Scala 中的 X500PrincipalBuilder 类编写单元测试。这是我的测试代码: import org.junit.runner.RunWith import org.scal
我正在用 python 编写我的第一个程序,它必须模拟粒子(两种气体)的混合。我不知道我这个功能做错了什么。我不希望颗粒离开某些区域,即容器的壁。我使用 VPython。 def poruszanie
我正在尝试求解三角方程组,但我认为 Python 没有生成正确的解。我试图解决的方程: 1 − 2cosθ1 + 2cosθ2 − 2cosθ3 = −0.8 1 − 2cos5θ1 + 2cos5θ
这个问题已经有答案了: TypeError: worker() takes 0 positional arguments but 1 was given [duplicate] (11 个回答) 已关
大家好,我正在努力解决这个问题 编写一个 C 程序,计算弹丸在撞击地面之前行进的距离(即射程)、弹丸撞击地面所需的时间以及弹丸飞行中的最大高度(给定角度)它被射向空中,以及发射时的初始速度(速度)。我
我编写了代码来计算 QuickSort 中完成的比较次数。 每当对长度为 m 的数组执行快速排序时,该算法都会将比较次数增加 m-1(因为主元将与除自身以外的所有内容进行比较)。 枢轴的选择始终是数组
我是一名优秀的程序员,十分优秀!