How do I estimate the distance spacing from a FFT image?

32 visualizaciones (últimos 30 días)
HI,
I have an image (attached). I used the fft command to get the fourier transform image.
How do I use the information to estimate the spacing in the lattice points(in pixels) in the original image?
It would be great if you could help me out.
Thanks a lot,
Pradeep
The code I used is given below:
clc;
clear all;
close all;
I=uint8(imread('perfect.jpg')); % read the image
Ibw=im2bw(I,0.2); % put threshold and get a black and white image
% imshow(Ibw); hold on; % to check whether we got the image or not
[lx, ly] = size(Ibw); % get size of image
nq = 2; % a number for the operation in the next two lines
Nqx = 2^(nextpow2(lx)+nq); % The sample number in X axis
Nqy = 2^(nextpow2(ly)+nq); % The sample number in X axis
Ifft = fftshift(fft2(Ibw,Nqx,Nqy)); % performing a fft and assigning output to Ifft
dx = 1; % micron per pixel
dy = 1; % micron per pixel
dqx = 1/(Nqx*dx);
dqy = 1/(Nqy*dy);
% qx = (1:floor(Nqx/2))*dqx;
% qy = (1:floor(Nqy/2))*dqy;
qx = (-(floor(Nqx/2))/2:(floor(Nqx/2))/2)*dqx;
qy = (-(floor(Nqy/2))/2:(floor(Nqy/2))/2)*dqy;
figure,imagesc(qx,qy,abs(Ifft)); axis equal;
  5 comentarios
Image Analyst
Image Analyst el 14 de Sept. de 2015
Your JPG images just show up as gibberish. Use the green and brown frame icon, not the paperclip icon to insert them.
Pradeep Bhaskar
Pradeep Bhaskar el 14 de Sept. de 2015
Editada: Pradeep Bhaskar el 14 de Sept. de 2015
Thank you once again, I have attached the image as you advised.This is my first question and I was attaching it as I would in g mail. Sorry.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Sept. de 2015
It might be easier to work in 1D, one direction at a time. fft() rather than fft2() the image. Take the result and zero out the first row (the order 0 component.) Look for the maxima of abs() of that, by max(abs()). The global max should either at the peak frequency or at one of its octaves, so when you find the frequency of the max also check the abs() at twice the frequency and if it has major component then consider going with that instead. (Repeat for twice that, etc.) Twice the frequency corresponds to half the spacing.
The columns of the image that have the dots will have much larger peaks than the other columns. However, some of the columns that do not visually have dots will have "bleed" from adjacent columns because you use JPEG and JPEG is not good on sharp edges. Anyhow, you should be able to filter by which columns have sharp peaks or not. Once you have a subset that you have found the maximum frequency for, you might want to average the maximum frequencies to reduce the error. Once you have the average, divide the height of the image by that in order to get the pixel spacing.
Rotate the image 90 degrees, repeat the process, to give you the horizontal spacing.
  1 comentario
Pradeep Bhaskar
Pradeep Bhaskar el 16 de Sept. de 2015
Hi Walter,
Thanks for your answer. I was able to get the peaks and the pixel spacing in 1D.
I have accepted the answer.
I would be working with dots that would be a bit random and some maybe absent (missing dots) too. I will try to apply this there too.
If you have another answer please share that too.
Thanks again.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by