【问题标题】:How to combine phase of one image with magnitude of another image in matlab and generate the inverse of the combined image如何在matlab中将一幅图像的相位与另一幅图像的幅值组合并生成组合图像的倒数
【发布时间】:2019-03-10 07:03:49
【问题描述】:

我计算了两幅图像的傅立叶变换(img1 & img2)并显示了它的相位和幅度。我想合并img1 的相位和img2 的幅度并生成一个新图像。如何生成组合图像并计算其倒数。以下是我的代码:

imagesc(img1); 
img1 = fftshift(img1(:,:,2)); 
F = fft2(img1); 

figure;  
imagesc(log(abs(fftshift(F)))); colormap(gray); 
title('magnitude Spectrum'); 
set(gca,'position',[0 0 1 1],'units','normalized')  
figure; 

imagesc(angle(F)); colormap(gray); 
title('PhaseSpectrum'); 
set(gca,'position',[0 0 1 1],'units','normalized') 

figure;  
imagesc(img2); 
img2 = fftshift(img2(:,:,2)); 
F2 = fft2(img2); 

figure;  
imagesc(log(abs(fftshift(F2)))); colormap(gray); 
title('magnitude Spectrum'); 
set(gca,'position',[0 0 1 1],'units','normalized')  

figure; 
imagesc(angle(F2)); colormap(gray); 
title('PhaseSpectrum'); 
set(gca,'position',[0 0 1 1],'units','normalized')  

【问题讨论】:

    标签: image matlab fft


    【解决方案1】:

    假设两幅图像大小相同,可以使用以下公式将幅值和相位组合起来:

    combined = abs(F2) .* exp(i * angle(F));
    

    然后获得逆只是使用ifft2 的问题(根据您的应用程序,可能后跟ifftshift;如果没有更多上下文,我无法判断您是否需要使用fftshift'ed 图像):

    combined_img = ifft2(combined);
    

    如果图像大小不同,则应首先使用以下方法获得相同大小的频域表示:

    m = max(size(img1,1), size(img2,1));
    n = max(size(img1,2), size(img2,2));
    F = fft2(img1,m,n);
    F2 = fft2(img2,m,n);
    

    【讨论】:

    • 您的帮助。我尝试了相同的方法,但是由于幅度和相位是不同的图像,所以出现“不同矩阵尺寸”的错误,这种情况我该怎么办?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-27
    • 1970-01-01
    • 2013-02-19
    • 2018-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多