fourier image of angled shape, and changes when cropping

1 view (last 30 days)
Hi
Attached is an image (please unzip) which has some kind of spot in an angle.
I'm performing the following fft as in the photo and using regionprops.
Why if i use crop, imcrop, the angle of the ellipse changes in the fft? what am i doing wrong here? I assume I should scale somehow the fft before the use of the regionprops.
I0_original = imread('1.tiff')
I0 = medfilt2(I0_original);
I = (double(I0) - double(min(I0(:))))/double(max(I0(:)) - min(I0(:)));
B = imbinarize(I, 'global');
If = fftshift(fft2(I0)); %% fft and fftshift - into center highest power
If_abs=abs(If);
dB = 10*log10(If_abs); %% convert into dB scale
dB = (double(dB) - min(dB(:)))/double(max(dB(:)) - min(dB(:))); % standardization
B2 = imbinarize(dB, 'adaptive');
[~, xc, ~, ~, ang] = analysis(dB, B2, 'FFT (dB scale)');
function [Bf, xc, lmx, lmn, ang] = analysis(I, B, str)
prop = regionprops(B, 'Area', 'Centroid', 'MajorAxisLength', 'MinorAxisLength', 'Orientation', 'BoundingBox');
for i = 1:length(prop)
area(i) = prop(i).Area;
end
[~, idx] = max(area); % get region with maximum area
Bf = B;
for i = 1:length(prop) % remove regions with no maximum area
if i ~= idx
bx = round(prop(i).BoundingBox);
xs = max(1, bx(2));
xe = min(bx(2)+bx(4), size(I, 1));
ys = max(1, bx(1));
ye = min(bx(1)+bx(3), size(I, 2));
Bf(xs:xe, ys:ye) = 0; % removing
end
end
xc = round(prop(idx).Centroid); % centroid
lmx = prop(idx).MajorAxisLength; % major axis length
lmn = prop(idx).MinorAxisLength; % minor axis length
ang = prop(idx).Orientation; % orientation angle in deg
bx = prop(idx).BoundingBox; % bounding box
disp(['(', num2str(xc(1)), ', ', num2str(xc(2)), '), ',...
num2str(lmx), ', ', num2str(lmn), ', ', num2str(ang)])
end

Answers (2)

DGM
DGM on 4 Jun 2021
Edited: DGM on 4 Jun 2021
Because the results of fft2() are scaled to match the geometry of the image it operates on, the shape of objects in the fft image depends on the aspect ratio of the input image.
If you want them to remain the same, you could resize dB (or some intermediate image) to have the same geometry as the uncropped image, or you could at least adjust it to have the same aspect ratio.
There's probably some canonical way to manage this, but I never really work with freq domain tasks.
  1 Comment
elis02
elis02 on 4 Jun 2021
Edited: elis02 on 4 Jun 2021
I need the fft angle to match that of the spot real two axis angles, as this is the fourier image. In the fourier that should be more accutate than doing this process on the real image as the real image is some kind of gaussian in two axis plus noise. I want to look at the gaussin part. since the fourier of a gaussian is also a gauss, looking at the fft, seems more accurate.
In any case, both angles should match, so indeed something with the scaling...

Sign in to comment.


elis02
elis02 on 4 Jun 2021
Hi
Attaching my script.
you will see in the begining cropping=0;
you can change that to 1 to make sure - something with my scaling if probably wrong. (the angles should stay the same in the fft)

Community Treasure Hunt

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

Start Hunting!