From abd65ac5092e17d5188cf8a1cd73ad7379a3c231 Mon Sep 17 00:00:00 2001 From: Vlad Karpushin Date: Fri, 17 Aug 2018 12:36:13 +0700 Subject: [PATCH] filterring error is zero now --- src matlab/main6_papa_12.m | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src matlab/main6_papa_12.m b/src matlab/main6_papa_12.m index 71d1d3c..e1bb59c 100644 --- a/src matlab/main6_papa_12.m +++ b/src matlab/main6_papa_12.m @@ -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);