批量处理大量文件 - 存储在内存中还是先写入磁盘?

发布于 2024-11-14 16:50:08 字数 474 浏览 2 评论 0原文

我正在编写一个软件,可以帮助我校准和堆叠图像 - 这种技术经常用于天文学/天文摄影中,以减少噪音并消除光学问题,例如渐晕。我将首先更详细地解释一下:

校准由 3 个文件组成 - 偏置、暗场和平场。从主图像中减去偏差和暗度,然后将主图像除以平场。正如您可以想象的那样,所有这些操作都是逐像素进行的。所有这些都不是问题,我已经对其进行了编程并且运行得很好。我一次打开一张图像,校准它,然后关闭它。当我走的时候释放记忆。

然而,我还需要能够堆叠图像,即对它们进行平均,或取中值。

我的问题是,我应该先校准每个图像,将其保存在临时目录中,然后逐行读取每个图像并平均结果吗?当我继续时,写出每一行的平均数。

或者

我应该将每个图像保留在内存中(可能会变得非常大),校准原始像素,然后保存堆叠图像?

在这种情况下最好的行动方案是什么?

当我操作它们时,像素数组存储为 (double*)rawPixels

I'm writing a software that can help me calibrate and stack images - this technique is often used in Astronomy/Astrophotography to reduce noise and get rid of optical issues, like vignetting. I'll start by explaining in a bit more detail:

Calibration consists of 3 files - a Bias, Dark and a Flat Field. The Bias and Dark are subtracted from the main image and then the main image is divided by the Flat Field. All these operations are pixel by pixel, as you can imagine. All of this is not a problem, I've programmed it and it works just fine. I open one image at a time, calibrate it and then close it. Releasing memory as I go.

However, I also need to be able to stack images i.e. average them, or take a median.

My question is, should I calibrate each image first, save it in a temporary directory and then read the each image row by row and average the result? Writing each averaged row as I proceed.

Or

Should I keep every image in memory (which can get very large), calibrate the raw pixels and then save the stacked image?

What is the best course of action in this scenario?

The pixel arrays are stored as (double*)rawPixels when I'm manipulating them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自由如风 2024-11-21 16:50:08

您还可以预先为平均/中值图像(结果)分配空间,并在迭代图像时计算它。用伪代码:

Image average;
foreach( Image i in Images){
    Calibrate(i);
    UpdateAverage( average, i );
}

嗯,没那么简单,但你明白了

You could also allocate space for the average/median image (the result) beforehand and calculate it as you iterate over the images. In pseudocode:

Image average;
foreach( Image i in Images){
    Calibrate(i);
    UpdateAverage( average, i );
}

Well, not that simple, but you get the idea

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文