Image 如何处理一个;“超大图像文件”;在MATLAB中,找出最大值的像素

Image 如何处理一个;“超大图像文件”;在MATLAB中,找出最大值的像素,image,matlab,image-processing,Image,Matlab,Image Processing,我必须处理一个非常大的图像(比如10MB的图像文件或者更多),我必须在MATLAB中去除伪影和死像素 我读过大图像的块处理,但不知道如何将其应用于16位图像。 我指的是将具有最高值的像素移除到周围像素的平均值中。我的代码无法处理80 MB大小的图像 numIterations = 30; avgPrecisionSize = 16; % smaller is better, but takes longer % Read in the image grayscale:

我必须处理一个非常大的图像(比如10MB的图像文件或者更多),我必须在MATLAB中去除伪影和死像素

我读过大图像的块处理,但不知道如何将其应用于16位图像。 我指的是将具有最高值的像素移除到周围像素的平均值中。我的代码无法处理80 MB大小的图像

    numIterations = 30;
    avgPrecisionSize = 16; % smaller is better, but takes longer

    % Read in the image grayscale:
    originalImage = double(rgb2gray(imread('C:\Documents and Settings\admin\Desktop\TM\image5.tif')));

    % get the bad pixels where  = 0 and dilate to make sure they get everything:
    badPixels = (originalImage == 0);
    badPixels = imdilate(badPixels, ones(12));

    %# Create a big gaussian and an averaging kernel to use:
    G = fspecial('gaussian',[1 1]*100,50);
    H = fspecial('average', [1,1]*avgPrecisionSize);

    %# User a big filter to get started:
    newImage = imfilter(originalImage,G,'same');
    newImage(~badPixels) = originalImage(~badPixels);

    % Now average to
    for count = 1:numIterations
    newImage = imfilter(newImage, H, 'same');
    newImage(~badPixels) = originalImage(~badPixels);
    end

    %% Plot the results
    figure(123);
    clf;

    % Display the mask:
    subplot(1,2,1);
    imagesc(badPixels);  
    axis image
    title('Region Of the Bad Pixels');

    % Display the result:
    subplot(1,2,2);
    imagesc(newImage);
    axis image
    set(gca,'clim', [0 255])
    title('Infilled Image');

    colormap gray
    newImage2 = roifill(originalImage, badPixels);

    figure(44);
    clf;
    imagesc(newImage2);
    colormap gray

您正在做一些明显存在问题的事情(但这可能具体取决于您在内存耗尽之前能够深入代码的程度)

1) 您将立即将整个图像转换为
double

2) 您正在识别要替换的某些像素,但将整个图像传递给
imfilter
,然后(大概)丢弃大部分输出:

newImage = imfilter(originalImage,G,'same');  % filter across the entire image
newImage(~badPixels) = originalImage(~badPixels);  % replace all the good pixels!
如果不转换为双精度,为什么不首先检查坏像素的位置,在这些像素周围的适当大小的子区域上进行处理(子区域可以转换为双精度并返回),然后在最后重新组装图像


blockproc
如果您可以将过滤选项编写为一个函数,该函数接收图像区域并返回正确的区域,则可能会起作用-您必须适当地使用
border\u size
选项,并确保您的函数只返回原始图像,而不必费心进行任何过滤,如果它碰到一个没有坏的块像素。您甚至可以将其写入文件。

投票关闭。信息不足,无法诊断问题,甚至无法确定是否存在(编程)问题。为了说服读者,你必须发布一些代码,并清楚地解释它是如何工作的。图像格式是什么?你对“死像素”的定义是什么?您要删除哪些工件?你为什么说10MB大?是否有性能或内存限制导致您这样问这个问题?你有图像处理工具箱吗?你是否在这个主题上做过任何工作,但没有以令人满意的方式完成这个相当基本的任务?你现在明白为什么你的问题很快就要结束了吗?如果没有像@RodyOldenhuis提到的那样编辑更多的细节,我也不得不结束了。@HighPerformanceMark我现在已经编辑了我的文章。。我面临的唯一问题是,我的图像非常大,可以使用IMTOOL查看,但无法使用上述代码进行处理。。内存不足错误出现。@RodyOldenhuis我现在已经编辑了我的文章。帮助我处理大型图像。