我有一个二维图像 G(m,n)。
G 是通过首先获取 k 空间值然后逆傅立叶变换来构造的。 k 空间由 m*n 个复数值组成。
仅获取此数量的 1/q(来自 m*n)是什么意思? (q 为正数)
在一个方案中,我将只保留原始 k 空间值的 1/q th。 其他元素 0f 原始 k 空间将为零/一。
谢谢。
答案 0 :(得分:0)
一种方法是使用 fft2()
函数将图像转换到频域并根据其幅度删除最不重要的频率分量。为了找到最不重要的值,使用 sort()
函数并返回相应的索引。我们可以使用矩阵索引将对应于最低频率分量的特定索引设置为零。您已经在上面描述了必须完成的工作,但要提供更多背景信息:
• 1/q
频率分量必须保留。
• 1 - (1/q
) 频率分量必须设置为零/删除。
%Grabbing a built-in test image%
Image = imread("peppers.png");
%Converting to grayscale if colour%
if size(Image,3) == 3
Image = rgb2gray(Image);
end
%Converting to frequency domain%
Frequency_Domain = fft2(Image);
%Sorting the the frequency domain values from greatest to least magnitude%
[Sorted_Coefficients,Sort_Indices] = sort(reshape(abs(Frequency_Domain),[numel(Frequency_Domain) 1]),'descend');
%Evaluating the number of coefficients to delete%
Number_Of_Coefficients = length(Sort_Indices);
q = 40;
Preserved_Fraction = 1/q;
Number_Of_Coefficients_To_Keep = round(Preserved_Fraction*Number_Of_Coefficients);
%Finding out which values to deleted based on the indices corresponding to the sorted array%
Delete_Indices = Sort_Indices(Number_Of_Coefficients_To_Keep+1:end);
Frequency_Domain(Delete_Indices) = 0;
%Evaluating how many frequency components were deleted%
Number_Of_Deleted_Frequency_Components = numel(Delete_Indices);
fprintf("Deleted %d frequency coefficients\n",Number_Of_Deleted_Frequency_Components);
%Converting the image back to the spatial domain%
G = uint8(ifft2(Frequency_Domain));
subplot(1,2,1); imshow(Image);
title("Original Image");
subplot(1,2,2); imshow(G);
title("Frequency Sampled Image");
disp(1 - (numel(Delete_Indices)/numel(Frequency_Domain)));