首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于归一化背景变化的直方图归一化

用于归一化背景变化的直方图归一化
EN

Stack Overflow用户
提问于 2015-06-18 15:03:15
回答 1查看 584关注 0票数 0

我使用Kinect v2记录了一系列深度图像。但是背景亮度并不是恒定的。但它不断地从暗到亮,从亮到暗(即)

因此,我在考虑使用序列中每个图像的直方图归一化来将背景归一化到相同的水平。有没有人能告诉我该怎么做?

EN

回答 1

Stack Overflow用户

发布于 2015-06-19 02:18:44

Matlab有一个histogram matching函数,他们的网站上也有一些很好的例子。

只需使用任何帧作为参考(我建议使用第一个帧,但没有真正的理由这样做),并为所有剩余的帧保留它。如果你想减少处理时间,你也可以尝试减少垃圾箱的数量。对于uint8图像,通常有256个存储箱,但正如您将在链接中看到的那样,减少它仍然会产生有利的结果

我不知道kinect图像是rgb还是灰度,对于这个例子,我假设它们是灰度的

代码语言:javascript
复制
kinect_images = Depth;
num_frames = size(kinect_images,3); %maybe 4, I don't know if kinect images
                                    %are grayscale(3) or RGB(4)

num_of_bins = 32;

%imhistmatch is a recent addition to matlab, use this variable to 
%indicate whether or not you have it
I_have_imhistmatch = true;

%output variable
equalized_images = cast(zeros(size(kinect_images)),class(kinect_images));

%stores first frame as reference
ref_image = kinect_images(:,:,1);   %if rgb you may need (:,:,:,1)
ref_hist = imhist(ref_image);

%goes through every frame and matches the histof
for ii=1:1:num_frames
    if (I_have_imhistmatch)
        %use this with newer versions of matlab
        equalized_images(:,:,ii) = imhistmatch(kinect_images(:,:,ii), ref_image, num_of_bins);
    else
        %use this line with older versions that dont have imhistmatch
        equalized_images(:,:,ii) = histeq(kinect_images(:,:,ii), ref_hist);
    end
end

implay(equalized_images)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30908572

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档