【发布时间】:2013-06-12 21:04:04
【问题描述】:
我在这个论坛上看到了一些类似的问题,但我没有找到真正解决这个问题的方法。
我有以下 matlab 代码,我在其中处理非常大的图像 (182MP):
%step 1: read the image
image=single(imread('image.tif'));
%step 2: read the image segmentation
regions=imread('image_segmentation.ppm');
%step 3: count the number of segments
number_of_regions=numel(unique(regions));
%step 4: regions label
regions_label=unique(regions);
for i=1:number_of_regions
%pick the pixel indexes of the i'th region
[x_region,y_region]=find(regions==label_regions(i));
%the problem starts here
ndvi_region=(image(x_region,y_region,1)-image(x_region,y_region,3))./(imagem(x_region,y_region,1)+image(x_region,y_region,3));
每次我使用特定区域运行代码时,matlab 都会返回错误:超出程序允许的最大变量大小。
我正在我学院的集群中运行具有 48GB RAM 的代码。问题仅在区域编号 43 及以下开始。其他地区运行正常。
我有什么聪明的方法可以运行这段代码吗?
【问题讨论】:
-
您确定需要
single吗?即,通常Matlab使用int8或int16,将内存使用量减少4(或2)倍......image.tif有多大(以像素为单位)? -
是的,我真的需要单身,计算 ndvi_region 至关重要。 image.tif 有 182 兆像素,它是一张遥感图像。感谢您的回复。
-
这就是 Matlab 对"What is the maximum matrix size for each platform?" 的评价。 48GB RAM 的物理存在并不意味着 Matlab 可以访问所有这些。
-
我还发现this answer by Rody Oldenhuis 对您的问题很感兴趣。
-
@Schorsch 感谢您的 cmets,它也有帮助。