coordinates of high frequency

2 visualizzazioni (ultimi 30 giorni)
AAS
AAS il 23 Giu 2022
Risposto: Rahul il 10 Set 2024
Is there any way to find points or coordinates of high frequencies in a 2d image?
  2 Commenti
Abhishek Tiwari
Abhishek Tiwari il 26 Giu 2022
Modificato: Abhishek Tiwari il 26 Giu 2022
Are you referring to points that occur the most frequently or the points with maximum intensity?
Jonas
Jonas il 27 Giu 2022
or the strongest frequency acquired from 2d fft spectrum?

Accedi per commentare.

Risposte (1)

Rahul
Rahul il 10 Set 2024
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!

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by