Filter löschen
Filter löschen

How to change the graph of frequency domain

2 Ansichten (letzte 30 Tage)
mohd akmal masud
mohd akmal masud am 20 Mai 2024
Beantwortet: Hassaan am 20 Mai 2024
Dear all,
I have coding to convert from spatial domain to frequency domain. Below is my coding.
Z = zeros(99); % create square matrix of zeroes
origin = [round((size(Z,2)-1)/2+1) round((size(Z,1)-1)/2+1)]; % "center" of the matrix
radius = round(sqrt(numel(Z)/(2*pi))); % radius for a circle that fills half the area of the matrix
[xx,yy] = meshgrid((1:size(Z,2))-origin(1),(1:size(Z,1))-origin(2)); % create x and y grid
Z(sqrt(xx.^2 + yy.^2) <= radius) = 1; % set points inside the radius equal to one
Z = im2double(Z)
imshow(Z); % show the "image"
%spatial domain
figure, imtool(Z)
%Frequency Domain
j = fftshift(fft2(Z));
figure, imshow(j)
j1 = log(1+abs(j));
figure ,imshow(j1)
j2 = bar(j1);
My graph frequency domain like this
How to make the graph like below

Akzeptierte Antwort

Hassaan
Hassaan am 20 Mai 2024
% Create a square matrix of zeroes
Z = zeros(99);
origin = [round((size(Z,2)-1)/2+1) round((size(Z,1)-1)/2+1)]; % "center" of the matrix
radius = round(sqrt(numel(Z)/(2*pi))); % radius for a circle that fills half the area of the matrix
[xx,yy] = meshgrid((1:size(Z,2))-origin(1),(1:size(Z,1))-origin(2)); % create x and y grid
Z(sqrt(xx.^2 + yy.^2) <= radius) = 1; % set points inside the radius equal to one
Z = im2double(Z);
imshow(Z); % show the "image"
% Spatial domain
figure, imtool(Z)
% Frequency Domain
j = fftshift(fft2(Z));
j1 = log(1 + abs(j));
% Display the frequency domain image using imagesc
figure;
imagesc(j1);
colormap('jet'); % You can choose a different colormap if you prefer
colorbar;
title('Frequency Domain Representation');
% Extract a line profile through the center of the frequency domain representation
center = round(size(j1, 2) / 2);
lineProfile = j1(center, :);
% Plot the line profile
figure;
plot(lineProfile);
title('Line Profile of Frequency Domain');
xlabel('Frequency');
ylabel('Magnitude');
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by