coordinates of high frequency
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Is there any way to find points or coordinates of high frequencies in a 2d image?
2 comentarios
Abhishek Tiwari
el 26 de Jun. de 2022
Editada: Abhishek Tiwari
el 26 de Jun. de 2022
Are you referring to points that occur the most frequently or the points with maximum intensity?
Respuestas (1)
Rahul
el 10 de Sept. de 2024
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:
'detectSURFFeatures': https://www.mathworks.com/help/releases/R2024a/vision/ref/detectsurffeatures.html?searchHighlight=detectSURFFeatures&s_tid=doc_srchtitle
'selectStrongest': https://www.mathworks.com/help/releases/R2024a/vision/ref/kazepoints.selectstrongest.html?searchHighlight=selectStrongest&s_tid=doc_srchtitle
Hope this helps!
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!