coordinates of high frequency

4 次查看(过去 30 天)
AAS
AAS 2022-6-23
回答: Rahul 2024-9-10
Is there any way to find points or coordinates of high frequencies in a 2d image?
  2 个评论
Abhishek Tiwari
Abhishek Tiwari 2022-6-26
编辑:Abhishek Tiwari 2022-6-26
Are you referring to points that occur the most frequently or the points with maximum intensity?
Jonas
Jonas 2022-6-27
or the strongest frequency acquired from 2d fft spectrum?

请先登录,再进行评论。

回答(1 个)

Rahul
Rahul 2024-9-10
Hi @AAS,
I understand that you want to find the coordinates of high frequency from a 2d image.
If you wish to find the coordinates of strongest frequency acquired from 2d fft spectrum, you can follow the following method:
  • Convert the image to the frequency domain using 'fft2' function.
  • Shift frequency components to center at zero frequency using 'fftshift' function.
  • Obtain the magnitude spectrum to identify and threshold the highest frequencies.
% Considering 'img' to be the variable for the 2d Image
img = rgb2gray(img);
% Converting 'img' to frequency domain using 'fft2' function
% Shifting the Zero Frequncy component using 'fftshift' function
F = fft2(double(img));
F_shifted = fftshift(F);
% Obtaining the magnitude spectrum of frequencies
magnitude = abs(F_shifted);
magnitude = log(1 + magnitude);
magnitude = mat2gray(magnitude);
threshold = 0.7; % Using a threshold to obtain high frequncies. Can be adjusted according to use-case.
high_freq_mask = magnitude > threshold;
% Finding Coordinates of High Frequencies
[row, col] = find(high_freq_mask);
hold on;
plot(col, row, 'r*');
title('High Frequency Points');
If you wish to find the coordinates of highest frequency based on occurrance, you can follow the following method:
  • Identify features from the 2d Image using 'detectSURFFeatures' function.
  • Using 'selectStrongest' function from the identified points to extract the points occurring most frequently.
  • If required, 'kmeans' function can be leveraged to obtain clusters of high frequnecy points and showcase their centers.
% Considering 'img' to be the variable for the 2d Image
img = rgb2gray(img);
% Detect features
points = detectSURFFeatures(img);
% Extract and plot the strongest points
strongestPoints = points.selectStrongest(100); % 100 can be changed accoridng to use-case
imshow(img); hold on;
plot(strongestPoints);
% Perform clustering using 'kmeans' function and plot centers
coordinates = strongestPoints.Location;
[idx, C] = kmeans(coordinates, 5); % Example with 5 clusters, can be changed accordingly
plot(C(:,1), C(:,2), 'rx', 'MarkerSize', 15, 'LineWidth', 3);
You can refer to the following Mathworks documentations to know more about these functions:
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by