Skip to content

Commit

Permalink
filterring error is zero now
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Karpushin committed Aug 17, 2018
1 parent f3f7e8c commit abd65ac
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src matlab/main6_papa_12.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,39 @@

% user input:
%4-element vector of the form [xmin ymin width height]. The initial size of the rectangle is width-by-height pixels. The upper-left corner of the rectangle is at the (x,y) coordinate (xmin,ymin).
h = imrect();
pos = getPosition(h);
pos = getPosition(imrect());

[h w] = size(imgC);
imgD = ones([h w]);

%Array of noise. Enough first eight components
% x1 = [1620 1618 1211 1212 1416 1822 1414 1007 1409 1620 1726 1420 1212 1105 1622 1824 2028 2026 1821 1618 1208 1007 805 806 1010 1215];
% y1 = [ 912 1222 1221 911 757 1068 1377 1066 890 1009 1068 1242 1123 1064 602 757 914 1225 1378 1532 1532 1375 1220 907 754 602];

xmin = pos(1);
ymin = pos(2);
width = pos(3);
height = pos(4);

imgD(ymin:ymin+height, xmin:xmin+width) = 0; %imgD(row, colomn), this is why imgD(y,x) rather than (x,y)

ymin2 = h - pos(2) - height+3;
imgD(ymin2:ymin2+height, xmin:xmin+width) = 0; %imgD(row, colomn), this is why imgD(y,x) rather than (x,y)

xmin2 = w - pos(1) - width+3;
imgD(ymin:ymin+height, xmin2:xmin2+width) = 0; %imgD(row, colomn), this is why imgD(y,x) rather than (x,y)
imgD(ymin2:ymin2+height, xmin2:xmin2+width) = 0; %imgD(row, colomn), this is why imgD(y,x) rather than (x,y)

figure; imshow((imgC+imgD)/2);
title('Power spectrum density + mask');


%**********************
%*****Filtering********
%**********************

imgE = ifft2(fftshift(imgD).*img_fft); %filtering
disp('real = ')
max(max(abs(real(imgE))))
disp('imag = ')
max(max(abs(imag(imgE))))
return;
imgE = real(imgE); %it needs to get real part because imgE is complex value
imgE = uint8(255*(imgE - min(min(imgE))) /(max(max(imgE)) - min(min(imgE))));
imgE = imadjust(imgE);
Expand Down

0 comments on commit abd65ac

Please sign in to comment.