Matlab图像基线(偏移消除)校正 [英] Matlab Image Baseline (Offset Removal) Correction

查看:562
本文介绍了Matlab图像基线(偏移消除)校正的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个情节:

,并希望使用Matlab展平其基线/减少偏移量.

and want to flatten its baseline/reduce offset using Matlab.

基本上像频谱的基线校正一样,但是这里我有一个网格,无法理解它如何在处理矩阵时展平其基线?基本上,点应该保留,但周围实际上为零.噪音仍然存在.

Basically like a baseline correction for a spectrum but here I've got a mesh and can't get my head around it how to flatten its baseline when dealing with a matrix? Basically the dot should stay but the surrounding is actually zero. The noise can stay, though.

这是图片:

我想知道这样的事情是否有效:

I am wondering if something like this works:

        for x=1:1201
        for y=1:1201
             Ibasetest = polyfit(x,y,1);
        end
        end

简单地为Z数据的每个X和Y做一个基线.但是我无法使它正常工作.:(

Simply put do a baseline for each X along Y for Z data. But I can't get it to work. :(

推荐答案

注意:另一种尝试的方法可能包括移动/窗口化平均值以计算要抵消的本地量.

Note: Another method to attempt may include moving/windowing averages to calculate the local amount to offset by.

使用离散傅立叶变换(DCT)将图像转换为频域.删除矩阵左上角的DC系数(设置为零),并使用离散傅立叶逆变换(IDCT)将其转换回空间域.

Converts the image into the frequency domain uses the Discrete Fourier Transform (DCT). Removes the DC coefficient in the top-left corner (set to zero) of the matrix and convert it back to the spatial domain using the Inverse Discrete Fourier Transform (IDCT).

Image = imread("Test_Image.jpg");

%Converting image to greyscale if RGB image%
[Image_Height,Image_Width,Depth] = size(Image);
if(Depth == 3)
Image = rgb2gray(Image);
end

%Removing image offset%    
Discrete_Cosine_Transformed_Image = dct2(Image);
Discrete_Cosine_Transformed_Image(1,1) = 0;
Inverse_Discrete_Cosine_Transformed_Image = idct2(Discrete_Cosine_Transformed_Image);

Calibrated_Image = medfilt2(Inverse_Discrete_Cosine_Transformed_Image,[20 20]);

% Plotting the original and thresholded image%
X_Axes = (1:1:Image_Height);
Y_Axes = (1:1:Image_Width);

subplot(1,2,1); surf(X_Axes,Y_Axes,Image,'EdgeColor','none');
title("Original Image Plot");
xlabel('X-Axis'); ylabel('Y-Label');
zlim([0 255]);

subplot(1,2,2); surf(X_Axes,Y_Axes,uint8(Calibrated_Image),'EdgeColor','none');
title("Calibrated Image Plot");
xlabel('X-Axis'); ylabel('Y-Label');
zlim([0 255]);

关键离散余弦变换(DCT)过滤代码行

%Removing image offset%    
Discrete_Cosine_Transformed_Image = dct2(Image);
Discrete_Cosine_Transformed_Image(1,1) = 0;
Inverse_Discrete_Cosine_Transformed_Image = idct2(Discrete_Cosine_Transformed_Image)

方法2:标准均匀偏移(无倾斜调节)

使用一个常量值,然后在整个图像矩阵中减去该值.

Method 2: Standard Uniform Offset (no-tilt accommodation)

Uses a constant value and subtracts that across the whole image matrix.

测试图像1:使用最低强度计算偏移量

测试图像2:使用平均值/均值来计算偏移量

Image = imread("Circular_Image.png");

%Converting image to greyscale if RGB image%
[Image_Height,Image_Width,Depth] = size(Image);
if(Depth == 3)
Image = rgb2gray(Image);
end

   %Removing image offset%
Lowest_Intensity_Value = min(Image,[],'all');
Average = mean(Image,'all');
Calibrated_Image = Image - Average;

% Plotting the original and thresholded image%
X_Axes = (1:1:Image_Height);
Y_Axes = (1:1:Image_Width);

subplot(1,2,1); surf(X_Axes,Y_Axes,Image,'EdgeColor','none');
title("Original Image Plot");
xlabel('X-Axis'); ylabel('Y-Label');
zlim([0 255]);

subplot(1,2,2); surf(X_Axes,Y_Axes,Calibrated_Image,'EdgeColor','none');
title("Calibrated Image Plot");
xlabel('X-Axis'); ylabel('Y-Label');
zlim([0 255]);

使用MATLAB版本:R2019b

这篇关于Matlab图像基线(偏移消除)校正的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆