Commit 143c1ed7 authored by jml1g18's avatar jml1g18
Browse files

other libraries to make code independent

parent f13ff8ab
function [D] = show2DVec( Frame )
%Display located vector field
D = create2DVec( Frame );
quiver( D.X, D.Y, D.U, D.V);
function [D] = show3DVec( Frame )
%Display located vector field
D = create3DVec( Frame );
disp 'quiver3d is to slow'
quiver3(D.X,D.Y,D.Z,D.U,D.V,D.W);
function [D]=showPlane( plane, scales )
D = createPlane( plane, scales );
%Display image data
imagesc(D.X,D.Y,D.I');
%Setup display
xlabel([scales.X.Description ' ' scales.X.Unit]);
ylabel([scales.Y.Description ' ' scales.Y.Unit]);
title ([scales.I.Description ' ' scales.I.Unit]);
if scales.Y.Slope >=0.0,
axis ij;
else
axis xy;
end
function [D]=showVolume( planeCells, scales )
nz = size(planeCells,1);
if nz < 1, error('invalid number of planes'); end;
nx = size(planeCells{1},1);
ny = size(planeCells{1},2);
%Create location data from scales
rx = double(1:nx) * scales.X.Slope + scales.X.Offset ;
ry = double(1:ny) * scales.Y.Slope + scales.Y.Offset ;
rz = double(1:nz) * scales.Z.Slope + scales.Z.Offset ;
% Display volume slizes
D = createVolume( planeCells, scales );
slice(D.X,D.Y,D.Z,D.I,[rx(nx/2)],[ry(ny/2)],rz(1:nz/4:nz) );
function [D]=showimx( Frame )
% CALL: []=showimx(Frame);
%
% FUNCTION: Displaying data of LaVision's IMX structure
% (one vector field, all image frames or only single image frame)
%
% ARGUMENTS: Frame = frames structure created by readimx2 function
%
% RETURN: in case of images (image type=0):
if nargin==0,
help showimx, return
end
if ~(isfield(Frame,'Components') & isfield(Frame,'Attributes') & isfield(Frame,'Scales') & isfield(Frame,'ComponentNames') & isfield(Frame,'IsVector') ) ,
help showimx, return
end
Components = Frame.Components;
if Frame.IsVector,
frameInfo = MakeFrameInfo(Frame);
if ( frameInfo.is3D ),
D = show3DVec(Frame);
else
D = show2DVec(Frame);
end
else
Planes = Components{1}.Planes; % assume image in component 1, ignore mask in component 2
nz = size(Planes,1);
if nz==0,
disp('no Planes')
elseif nz==1,
D = showPlane( Planes{1}, Frame.Scales );
else
D = showVolume( Planes, Frame.Scales );
end
end
\ No newline at end of file
folder = 'B:\davis\multiscale\Gen1_12\U10\';
cmap = gray * diag([0 1 0]);
cmap(end,:)=[1 0 0];
c_lim = [0 128];
wsize = [11 11];
%% get latest folder
dir_list= dir(folder);
dir_list(~[dir_list.isdir]) = [];
[~,idx] = sort([dir_list.datenum], 'ascend');
latest_dir = dir_list(idx(end));
latest_dir = [latest_dir.folder '/' latest_dir.name];
disp(latest_dir);
%% get latest file
file_list = dir(latest_dir);
file_list([file_list.isdir]) = [];
[~,idx] = sort([file_list.datenum], 'ascend');
latest_imx = file_list(idx(end-1));
latest_imx = [latest_imx.folder '/' latest_imx.name];
disp(latest_imx);
%% read
img = readimx(latest_imx);
im_ary = cellfun(@(f) f.Components{1}.Planes{1}, img.Frames, 'UniformOutput', false);
% subtract bg
%im_ary = cellfun(@(im) im - min(min(im)), im_ary, 'UniformOutput', false);
im_ary = cellfun(@(im) im - movmin(movmin(im, wsize, 2), 1), im_ary, 'UniformOutput', false);
%% plot
figure(1);
clf;
ax = [0 0 0 0];
for k = 1 : 4
ax(k) = subplot(1,4,k);
im = im_ary{k};% - bg_ary{k};
imagesc(im');
axis equal tight ij;
colormap(cmap);
set(gca,'clim',c_lim);
end
linkaxes(ax([1 2]), 'xy');
linkaxes(ax([3 4]), 'xy');
\ No newline at end of file
......@@ -8,30 +8,29 @@ image_B_fname = 'imD.tif';
n_passes = 3;
n_peaks = 3;
wsize = [64 64; 32 32; 32 32];
overlap = [50 75 75];
overlap = [75 75 75];
min_filt_size = [17 17];
gauss_filt_size = [3 3];
norm_filt_size = [11 11];
peak_finder = 'gauss3';
%% load images and filter
%% load images
im_A = single( imread(image_A_fname) );
%% grid setup
Nx = size(im_A_filt, 1);
Ny = size(im_A_filt, 2);
Nx = size(im_A, 1);
Ny = size(im_A, 2);
im_x = 1 : Nx;
im_y = 1 : Ny;
%% create artificial displacement field
[xmat,ymat] = ndgrid(im_x, im_y);
dx_ref = 0*ymat;%(Nj/2-ymat)/Nj * 8;
dy_ref = (Nj/2-ymat)/Nj * 8;
dx_ref = 0*ymat;
dy_ref = (Ny/2-ymat)/Ny * 8;
im_B = interpn(im_x, im_y, im_A, xmat-dx_ref, ymat-dy_ref, 'cubic', 0);
%%
%im_B = single( imread(image_B_fname) );
%% filter
im_mask = false(size(im_A));
filters = cell(1,3);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment