tree with white decoration
Show older comments
So, we were given this picture of a tree that had a white line around it . We are asked to isolate the pixels of it in (x,y) cooridinates , then find the Fourier series coefficients based on those coordinates . I explain in the picture, y[n]=y coordinates of the white decoration and x[n]=x coordinates of the white decoratives. So I have found x,y, but I don't know how to find the Fourier Series coefficients and we are also asked to use the first 50 of them to reform the shape only of the white decoratives. I also have to say that when I plotted x,y my shape was not properly oriented (picture2)
Can anyone please give me an example code for those 2 questions , ? We have to use fft() function.
also since my shape is not properly oriented does that mean my y,x are wrong?
Also my deadline is very close ..........
8 Comments
oscillator
on 20 Feb 2022
oscillator
on 20 Feb 2022
Image Analyst
on 20 Feb 2022
Edited: Image Analyst
on 20 Feb 2022
I think you attached the wrong photo. There is no picture of a tree with decorations attached.
Did you do
ftx = fft(x);
ftx(51:end-50) = 0; % erase frequencies higher than the first 50 of them.
x2 = ifft(ftx);
% Same for y.
oscillator
on 20 Feb 2022
oscillator
on 20 Feb 2022
Image Analyst
on 20 Feb 2022
Here is what I see for the first image:

and the second image is:

Which one of those is the tree with decorations?
You would not use imshow() with x and y. You could use imshow() to display an image, then use hold on, and call plot(x,y) to display the cirve above the image in the overlay.
Once you've segmented the white decorations, you can get the boundaries (x,y) coordinates like this:
% Plot the borders of all the blobs in the overlay above the original grayscale image
% using the coordinates returned by bwboundaries().
% bwboundaries() returns a cell array, where each cell contains the row/column coordinates for an object in the image.
imshow(originalImage); % Optional : show the original image again. Or you can leave the binary image showing if you want.
% Here is where we actually get the boundaries for each blob.
boundaries = bwboundaries(mask);
% boundaries is a cell array - one cell for each blob.
% In each cell is an N-by-2 list of coordinates in a (row, column) format. Note: NOT (x,y).
% Column 1 is rows, or y. Column 2 is columns, or x.
numberOfBoundaries = size(boundaries, 1); % Count the boundaries so we can use it in our for loop
% Here is where we actually plot the boundaries of each blob in the overlay.
hold on; % Don't let boundaries blow away the displayed image.
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k}; % Get boundary for this specific blob.
x = thisBoundary(:,2); % Column 2 is the columns, which is x.
y = thisBoundary(:,1); % Column 1 is the rows, which is y.
plot(x, y, 'r-', 'LineWidth', 2); % Plot boundary in red.
end
hold off;
caption = sprintf('%d Outlines, from bwboundaries()', numberOfBoundaries);
fontSize = 15;
title(caption, 'FontSize', fontSize);
axis('on', 'image'); % Make sure image is not artificially stretched because of screen's aspect ratio.
oscillator
on 20 Feb 2022
Image Analyst
on 20 Feb 2022
I see. You could always grab one off the internet, but I don't think your professor would like you using our code. Aren't you supposed to write your own code?
Answers (0)
Categories
Find more on Contrast Adjustment in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!