GREIT_DESIRED_IMG_ORIGINAL The original desired solution for GREIT PSF= GREIT_desired_img_original(xyc, radius, opt) xyc - array of point centers [2xNpoints] radius - the radius of the target on the desired image as a fraction of the model radius (half the larger dimension in xy) opt - a struct with these mandatory fields: .rec_model a 2D model as generated by MK_GRID_MODEL, with some restrictions, see below. The supplied opt.rec_model is only used to figure out the requested image size in pixels, and the coordinates of the model in space. If pixels are removed from the model, a boolean opt.rec_model.inside must be specified indicating the removed pixels with false, as done by MK_PIXEL_SLICE. Nodes must not be removed. Only equal-size pixels are supported. NOTE that the amount of blur provided by this function decreases as the resolution of the image increases. As of 2015-03-29, the default desired image function used by MK_GRID_MODEL is MK_DESIRED_IMAGE_SIGMOID. See also: CALC_GREIT_RM, MK_GREIT_MODEL, MK_PIXEL_SLICE, GREIT_DESIRED_IMG_SIGMOID
0001 function PSF= GREIT_desired_img_original(xyc, radius, opt) 0002 %GREIT_DESIRED_IMG_ORIGINAL The original desired solution for GREIT 0003 % PSF= GREIT_desired_img_original(xyc, radius, opt) 0004 % xyc - array of point centers [2xNpoints] 0005 % radius - the radius of the target on the desired image as a fraction 0006 % of the model radius (half the larger dimension in xy) 0007 % opt - a struct with these mandatory fields: 0008 % .rec_model a 2D model as generated by MK_GRID_MODEL, with some 0009 % restrictions, see below. 0010 % 0011 % The supplied opt.rec_model is only used to figure out the requested image 0012 % size in pixels, and the coordinates of the model in space. If pixels are 0013 % removed from the model, a boolean opt.rec_model.inside must be specified 0014 % indicating the removed pixels with false, as done by MK_PIXEL_SLICE. 0015 % Nodes must not be removed. Only equal-size pixels are supported. 0016 % 0017 % NOTE that the amount of blur provided by this function decreases as the 0018 % resolution of the image increases. 0019 % 0020 % As of 2015-03-29, the default desired image function used by 0021 % MK_GRID_MODEL is MK_DESIRED_IMAGE_SIGMOID. 0022 % 0023 % See also: CALC_GREIT_RM, MK_GREIT_MODEL, MK_PIXEL_SLICE, 0024 % GREIT_DESIRED_IMG_SIGMOID 0025 0026 % (C) 2009-2015 Andy Adler and Bartlomiej Grychtol. 0027 % License: GPL v2 or v3 0028 % $Id: GREIT_desired_img_original.m 4986 2015-05-11 20:09:28Z aadler $ 0029 0030 opt = parse_opt(opt.rec_model); 0031 0032 copt.fstr = 'GREIT_desired_img_original'; 0033 copt.cache_obj = {xyc, radius, opt}; 0034 PSF = eidors_cache(@desired_soln,{xyc, radius, opt},copt); 0035 end 0036 0037 function PSF = desired_soln(xyc,radius,opt) 0038 0039 xsz = opt.imgsz(1); ysz = opt.imgsz(2); 0040 sz= xsz * ysz; 0041 xmin = opt.meshsz(1); xmax = opt.meshsz(2); 0042 ymin = opt.meshsz(3); ymax = opt.meshsz(4); 0043 % scale radius to half the greater dimension 0044 radius = radius * 0.5 * max(xmax-xmin, ymax-ymin); 0045 [x,y]= ndgrid(linspace(xmin,xmax,xsz), linspace(ymin,ymax,ysz)); 0046 x_spc = (xmax-xmin)/(xsz-1) * 0.5; 0047 y_spc = (ymax-ymin)/(ysz-1) * 0.5; 0048 PSF = zeros(sz,size(xyc,2)); 0049 for i=1:size(xyc,2); 0050 for dx = linspace(-x_spc, x_spc, 5) 0051 for dy = linspace(-y_spc, y_spc, 5) 0052 PSF(:,i) = PSF(:,i) + 1/25*( ... 0053 (dx+x(:)-xyc(1,i)).^2 + (dy+y(:)-xyc(2,i)).^2 ... 0054 < radius^2 ); 0055 end 0056 end 0057 % PSF(:,i) = PSF(:,i)/sum(PSF(:,i)); 0058 end 0059 if ~isempty(opt.inside) 0060 PSF = PSF(opt.inside,:); 0061 end 0062 0063 end 0064 0065 function opt = parse_opt(mdl) 0066 opt.meshsz = []; 0067 for i = 1:2 0068 opt.meshsz = [opt.meshsz min(mdl.nodes(:,i)) max(mdl.nodes(:,i))]; 0069 end 0070 opt.imgsz(1) = numel(unique(mdl.nodes(:,1))) - 1; 0071 opt.imgsz(2) = numel(unique(mdl.nodes(:,2))) - 1; 0072 % opt.inside = []; 0073 % try 0074 opt.inside = mdl.inside; 0075 % end 0076 end 0077