% testing various ways to find the centeres of tiles. function test addpath /research/src/DNAdesign addpath /research/src/AFMutils %% %% rizal's beautiful image %% [im,in] = showafm('~winfree/Research/DNA/AFM_old/data.rizal/02-07-20/QBOX.097',0); im = flipud(im); figure(1); imagesc(im); axis square; title 'raw image' %% h = fspecial( 'gaussian', [3,3]); imc = imfilter(im, h); imc = imfilter(imc, h); imc = imfilter(imc, h); imc = imc .^2; imagesc(imc); pause; % from: notes-rizal %% %% find local maxima by making sure a pixel is greater than left, right, up, down %% neighbors imcD = imc([2:end 1],:); imcU = imc([end 1:end-1],:); imcR = imc(:,[2:end 1]); imcL = imc(:,[end 1:end-1]); % figure(2) % imagesc(imc>=max(imcL,imcR)); % % these show excellent detection % title 'left right local maxima' % figure(3) % imagesc(imc>=max(imcU,imcD)); % % these show excellent detection % title 'up down local maxima' figure(4) imagesc(imc>=max(.1,max(max(imcL,imcR),max(imcU,imcD)))); % arbitrary threshold here colormap gray title 'detected maxima' %% unfortunately, a bunch of spurious points show up %% pause; newimage = colfilt(imc , [3,3], 'sliding', @centermax); figure(5) imagesc(newimage); colormap gray title 'local max' pause; close all; % can change function and use to find local max/min? % @centermax -- returns 1 if the center value is the greatest, zero if % otherwise. % output = input_mtx(ceil(length/2))) == max(input_mtx); % should have odd length of matrix. function output = centermax ( input_mtx ) % % el = numel(input_mtx); % middle = ceil(el/2); % output = (input_mtx(middle) >= max(input_mtx)); output = (input_mtx(5) == max(input_mtx)); %%------------------------------------------------------------------------- % %% testing speed of varous implementaitons of median filters % % addpath /home/wrightc/program % % filepath = '/research/windows/backups/afm/d/Rizal/03-06-23/mov0623a.043' % rawim = showafm(filepath,1); % pause; % image = medfilt2 (rawim, [5,5]); % disp('done') % figure(1) % imagesc (image) % colormap gray % truesize % title 'median filtered image' % % pause; % % image2 = ordfilt2(rawim, 5, ones(5,5)); % disp('done') % figure(2) % imagesc (image2) % colormap gray % truesize % title 'median filtered image 2' % % pause; % % image3 = colfilt(rawim,[5,5],'sliding',@median); % disp('done') % figure(3) % imagesc (image3) % colormap gray % truesize % title 'median filtered image 3' % % pause; % close all % % %% results: medfilt2 is best as far as i can tell. % x = rand([10,1]) % d = fdesign.lowpass('n,fc') % hd = butter(d) % filter(hd,x) % [r,c] = size(rawim); % [x,y] = meshgrid (r/(-2):r/2-1,c/(-2):c/2-1); % z = sqrt(x.^2+y.^2); % threshold = 2; % c=(z< threshold); % figure(3) % imagesc(c) % truesize % % this part is fine. % % % fimage = fftshift(fft2(rawim)); % fimage = fimage .* c; % image = ifft2(fimage); % % figure(2) % imagesc(flipud(image)) % colormap gray; % % pause; % close all; % % % % i cant figure out why there is a grid superimposed on the image..... % % that would be a high frequency