coordinates of high frequency

2 ビュー (過去 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!

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by