fourier image of angled shape, and changes when cropping
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (2개)
DGM
2021년 6월 4일
편집: DGM
2021년 6월 4일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!