How can i convert the edge line of this image from white to black and the background from black to white?

7 views (last 30 days)
I just completed a code and it ran ok, but i have a slight issue with it. the code is to extract the edge of the image of an object in Fourier domain.the code is written below and the image used in the code is attached.
the problem i have with it is to convert the color of the edge line of the resulting image from white to black and the background from black to white.
kindly help insert the appropriate code in the appropriate line to help do the conversion.
% Read in a standard image
Standardimage = 'AEESS2.jpg';
Originalimage = imread(Standardimage);
% Display the original image
imshow(Originalimage);
%Convert Original image to grayscale and display.
grayImage = rgb2gray(Originalimage);
imshow(grayImage);
% Display the original grayscale image.
subplot(2, 2, 1);
imshow(grayImage, [0 255]);
title('Original Grayscale Image in its Spatial Domain', 'FontSize', 10);
% Enlarge the figure to full screen.
% set(gcf, 'Position', get(0,'Screensize'));
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Compute the FFT.
FFTImage = fft2(grayImage);
% Shift the zero frequency location from (0,0)to the center of the display
% and take log in order to have a clearer display.
centeredFFTImage = log(fftshift(real(FFTImage)));
% Display the FFT image.
subplot(2, 2, 2);
imshow(centeredFFTImage, []);
title('Visually Enhanced Frequency Domain of the Original Grayscale Image', 'FontSize', 9);
% Zero out the corners.
window = 30;
FFTImage(1:window, 1:window) = 0;
FFTImage(end-window:end, 1:window) = 0;
FFTImage(1:window, end-window:end) = 0;
FFTImage(end-window:end, end-window:end) = 0;
% Shift the zero frequency location from (0,0)to the center of the display
% and take log in order to have a clearer display.
centeredFFTImage = log(fftshift(real(FFTImage)));
subplot(2, 2, 3);
imshow(centeredFFTImage, []);
title('Visually Enhanced Frequency Domain of the Filtered image', 'FontSize', 10);
% Taking the Inverse FFT to convert the high pass filtered
%image back to Spatial domain.
output = ifft2(FFTImage);
% Display the output.
subplot(2, 2, 4);
imshow(real(output), [0 255]);
title('High Pass Filtered Image converted back to the Spatial Domain', 'FontSize', 10);
Thanks, Best Regards.

Accepted Answer

Image Analyst
Image Analyst on 4 Feb 2014
Can't you just invert your image:
output = 255 - real(output);
That will invert black and white.
  11 Comments
Image Analyst
Image Analyst on 2 Mar 2014
Edited: Image Analyst on 2 Mar 2014
No need to do that in the Foureir domain when you can simply do it in the spatial domain with the proper kernel. Attached (below in blue) is the code to find the border and do the spatial filter.
It's hard to see the final image because it's shrunk down and most of the pixels were lost to subsampling.
Dipps
Dipps on 17 Mar 2014
Thanks so much sir, i really appreciate your gesture. You've been of great help to me. God bless u. I've been having issues with internet thats why this is coming late.
Am really making good progress in my matlab codes now, much thanks to you. will keep you posted on my results soon.
Thanks
Best Regards

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!