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

41 ビュー (過去 30 日間)
Pradeep Bhaskar
Pradeep Bhaskar 2015 年 9 月 11 日
コメント済み: Pradeep Bhaskar 2015 年 9 月 16 日
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 件のコメント
Image Analyst
Image Analyst 2015 年 9 月 14 日
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 2015 年 9 月 14 日
編集済み: Pradeep Bhaskar 2015 年 9 月 14 日
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.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2015 年 9 月 15 日
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 件のコメント
Pradeep Bhaskar
Pradeep Bhaskar 2015 年 9 月 16 日
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.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by