Extracting frequency components of line in a image
Show older comments
Hi.. I want to extract the only frequency components of discontinuous line in the image shown here http://tinypic.com/r/2va11fc/7 while removing all other frequencies Can i do like this
I = imread(image);
imshow(I);
FT = fft2(I);
FT(1,1) = 0;
I2 = ifft2(FT);
imshow(I2);
Accepted Answer
More Answers (1)
Walter Roberson
on 16 Oct 2011
0 votes
Straight lines (or line segments) have frequency components at all frequencies. Zeroing the DC component would at best shift the line segments. Zeroing any other frequency component would result in a wiggly line after reverse transformation.
11 Comments
Gova ReDDy
on 4 Nov 2011
Image Analyst
on 4 Nov 2011
What are you talking about? The spectrum of a line segment (like a rectangular pulse) is just a sinc function (Google it). I doubt that's what you want or need. Do you mean the spectrum of the IMAGE under the line? Why do you think you need frequency components, either of the line or the underlying image? What would you do if you had it?
Gova ReDDy
on 5 Nov 2011
Image Analyst
on 5 Nov 2011
Sorry, but I don't want to send you on a wild goose chase. You'd have to explain to me how that would solve your problem (because I don't think it will).
Gova ReDDy
on 5 Nov 2011
Image Analyst
on 6 Nov 2011
Then take the FFT of it, and you'll see sinc(x).
x = zeros(151,1);
midPoint = ceil(length(x)/2)
width = 40;
x(midPoint-width/2 : midPoint+width/2) = 1;
subplot(2,1,1);
plot(x, 'LineWidth', 3);
ylim([0 2]);
xlim([1 length(x)]);
grid on;
title('X, spatial domain', 'FontSize', 30);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
spectrumOfX = fft(x);
subplot(2,1,2);
plot(real(fftshift(spectrumOfX)), 'LineWidth', 3);
grid on;
title('FFT(X), frequency domain', 'FontSize', 30);
Image Analyst
on 6 Nov 2011
Please let me know if this is helpful because I really feel you're wasting all of our time by continuing down this path. I just don't think you have the background concepts understood enough yet to realize what you're asking.
Gova ReDDy
on 6 Nov 2011
Walter Roberson
on 6 Nov 2011
What does it mean for a frequency to have a value of 1 ? Please keep in mind that the result of fft is generally a vector of complex values. The fft of a straight line (or approximation thereto) has phase components that you cannot neglect.
The magnitude of the coefficient of any frequency element does not often come out to be exactly 1.
If you are looking for relative peaks, then use a peak finder (once you work out the complex-number issues.)
Gova ReDDy
on 6 Nov 2011
Image Analyst
on 6 Nov 2011
Sorry. I consider this a dead end. I'm done. I suggest you take a different approach.
Categories
Find more on Discrete Fourier and Cosine Transforms in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!