简体   繁体   English

Blob检测中的大位图图像内存分配,C#.Net

[英]Large bitmap images memory allocation in blob detectin, C# .Net

I have bitmap images like 14000x18000(~30MB ) height and width.我有像 14000x18000(~30MB) 高度和宽度的位图图像。 I am trying to process them with different image processing libraries (OpenCV (using the wrapper OpenCvSharp), Aforge.NET..) in order to do blob detection.我正在尝试使用不同的图像处理库(OpenCV(使用包装器 OpenCvSharp)、Aforge.NET ..)来处理它们,以便进行 blob 检测。 However, labeling the bitmap image causes memory allocation problems.但是,标记位图图像会导致内存分配问题。 The libraries tries to map the labeled image to 32bit image.库尝试将标记图像映射到 32 位图像。

Is there a way to da the labeling operation with a less amount of memory?有没有办法用更少的内存进行标记操作? (Cropping the image is not a solution) (裁剪图像不是解决方案)

For example labeling the bitmap image to a 8bit image instead of 32?例如将位图图像标记为 8 位图像而不是 32 位图像?

In case there isn't an answer for the 8-bit thing... and even if there is...如果 8 位的东西没有答案......即使有......

For speed and memory purposes, I would highly recommend resizing the image down (not cropping).出于速度和内存的目的,我强烈建议缩小图像大小(而不是裁剪)。 Use high-quality interpolation like this sample does , only just resize to 50%, not thumbnail (7.5MB im memory).这个示例一样使用高质量的插值,只是将大小调整为 50%,而不是缩略图(7.5MB 内存)。

You didn't mention that you don't want to do this, and I am assuming you probably don't want to try it, thinking the library will do better blob detection at full resolution.你没有提到你不想这样做,我假设你可能不想尝试,认为库会在全分辨率下进行更好的斑点检测。 Before you pooh-pooh the idea you need to test it with a full-resolution subsection of a sample image, of a size that the library will handle, compared to the same subsection at 50%.在你对这个想法嗤之以鼻之前,你需要用一个样本图像的全分辨率子部分来测试它,与库将处理的大小相比,与 50% 的相同子部分相比。

Unless you've actually done this, you can't know.除非你真的这样做过,否则你无法知道。 You can also figure a maximum amount of memory that the picture can use, compute a resize factor to target that number (reduce it for safety - you'll figure this out when things blow up in testing).您还可以计算图片可以使用的最大内存量,计算调整大小因子以定位该数字(为了安全而减少它 - 当测试中出现问题时,您会弄清楚这一点)。 If you care where the stuff is in the original image, scale it back up by the factor.如果您关心原始图像中的内容,请将其按比例放大。

This may not solve your particular problem (or it might), but have you considered splitting / segmenting the frame into a 2x2 (or 3x3) matrix and try to work on each of them separately.这可能无法解决您的特定问题(或可能),但您是否考虑过将帧拆分/分割为 2x2(或 3x3)矩阵并尝试分别处理它们中的每一个。 Then based on where you find the blobs in the 4 (or 9) frames, correlate and coalesce the adjoining blobs to make single blob.然后根据您在 4(或 9)帧中找到斑点的位置,关联并合并相邻的斑点以形成单个斑点。 Of course, this high level blob coalescing would have to be your own logic.当然,这种高级 blob 合并必须是您自己的逻辑。

PS> Admittedly, working off highly superficial knowledge of Aforge. PS> 诚然,对 Aforge 非常肤浅的了解。 No hands-on experience what-so-ever.没有任何实践经验。

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

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