plateform
stringclasses
1 value
repo_name
stringlengths
13
113
name
stringlengths
3
74
ext
stringclasses
1 value
path
stringlengths
12
229
size
int64
23
843k
source_encoding
stringclasses
9 values
md5
stringlengths
32
32
text
stringlengths
23
843k
github
jacksky64/imageProcessing-master
upBlur.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/upBlur.m
1,213
utf_8
7b07d26940520537edb6e8dc25b72242
% RES = upBlur(IM, LEVELS, FILT) % % Upsample and blur an image. The blurring is done with filter % kernel specified by FILT (default = 'binom5'), which can be a string % (to be passed to namedFilter), a vector (applied separably as a 1D % convolution kernel in X and Y), or a matrix (applied as a 2D % convolution kernel). The downsampling is always by 2 in each % direction. % % The procedure is applied recursively LEVELS times (default=1). % Eero Simoncelli, 4/97. function res = upBlur(im, nlevs, filt) %------------------------------------------------------------ %% OPTIONAL ARGS: if (exist('nlevs') ~= 1) nlevs = 1; end if (exist('filt') ~= 1) filt = 'binom5'; end %------------------------------------------------------------ if isstr(filt) filt = namedFilter(filt); end if nlevs > 1 im = upBlur(im,nlevs-1,filt); end if (nlevs >= 1) if (any(size(im)==1)) if (size(im,1)==1) filt = filt'; end res = upConv(im,filt,'reflect1',(size(im)~=1)+1); elseif (any(size(filt)==1)) filt = filt(:); res = upConv(im,filt,'reflect1',[2 1]); res = upConv(res,filt','reflect1',[1 2]); else res = upConv(im,filt,'reflect1',[2 2]); end else res = im; end
github
jacksky64/imageProcessing-master
nextFig.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/nextFig.m
363
utf_8
94a66b00983cd3840ff1cc88f118a022
% nextFig (MAXFIGS, SKIP) % % Make figure number mod((GCF+SKIP), MAXFIGS) the current figure. % MAXFIGS is optional, and defaults to 2. % SKIP is optional, and defaults to 1. % Eero Simoncelli, 2/97. function nextFig(maxfigs, skip) if (exist('maxfigs') ~= 1) maxfigs = 2; end if (exist('skip') ~= 1) skip = 1; end figure(1+mod(gcf-1+skip,maxfigs));
github
jacksky64/imageProcessing-master
zconv2.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/zconv2.m
1,164
utf_8
cd266795530db4cb146c1038383316f3
% RES = ZCONV2(MTX1, MTX2, CTR) % % Convolution of two matrices, with boundaries handled as if the larger mtx % lies in a sea of zeros. Result will be of size of LARGER vector. % % The origin of the smaller matrix is assumed to be its center. % For even dimensions, the origin is determined by the CTR (optional) % argument: % CTR origin % 0 DIM/2 (default) % 1 (DIM/2)+1 (behaves like conv2(mtx1,mtx2,'same')) % Eero Simoncelli, 2/97. function c = zconv2(a,b,ctr) if (exist('ctr') ~= 1) ctr = 0; end if (( size(a,1) >= size(b,1) ) & ( size(a,2) >= size(b,2) )) large = a; small = b; elseif (( size(a,1) <= size(b,1) ) & ( size(a,2) <= size(b,2) )) large = b; small = a; else error('one arg must be larger than the other in both dimensions!'); end ly = size(large,1); lx = size(large,2); sy = size(small,1); sx = size(small,2); %% These values are the index of the small mtx that falls on the %% border pixel of the large matrix when computing the first %% convolution response sample: sy2 = floor((sy+ctr+1)/2); sx2 = floor((sx+ctr+1)/2); clarge = conv2(large,small); c = clarge(sy2:ly+sy2-1, sx2:lx+sx2-1);
github
jacksky64/imageProcessing-master
mkZonePlate.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/mkZonePlate.m
633
utf_8
d88329c8d374e54e124222c825679768
% IM = mkZonePlate(SIZE, AMPL, PHASE) % % Make a "zone plate" image: % AMPL * cos( r^2 + PHASE) % SIZE specifies the matrix size, as for zeros(). % AMPL (default = 1) and PHASE (default = 0) are optional. % Eero Simoncelli, 6/96. function [res] = mkZonePlate(sz, ampl, ph) sz = sz(:); if (size(sz,1) == 1) sz = [sz,sz]; end mxsz = max(sz(1),sz(2)); %------------------------------------------------------------ %% OPTIONAL ARGS: if (exist('ampl') ~= 1) ampl = 1; end if (exist('ph') ~= 1) ph = 0; end %------------------------------------------------------------ res = ampl * cos( (pi/mxsz) * mkR(sz,2) + ph );
github
jacksky64/imageProcessing-master
steer2HarmMtx.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/steer2HarmMtx.m
1,803
utf_8
35816be985c308717168260dc97419d8
% MTX = steer2HarmMtx(HARMONICS, ANGLES, REL_PHASES) % % Compute a steering matrix (maps a directional basis set onto the % angular Fourier harmonics). HARMONICS is a vector specifying the % angular harmonics contained in the steerable basis/filters. ANGLES % (optional) is a vector specifying the angular position of each filter. % REL_PHASES (optional, default = 'even') specifies whether the harmonics % are cosine or sine phase aligned about those positions. % The result matrix is suitable for passing to the function STEER. % Eero Simoncelli, 7/96. function mtx = steer2HarmMtx(harmonics, angles, evenorodd) %%================================================================= %%% Optional Parameters: if (exist('evenorodd') ~= 1) evenorodd = 'even'; end % Make HARMONICS a row vector harmonics = harmonics(:)'; numh = 2*size(harmonics,2) - any(harmonics == 0); if (exist('angles') ~= 1) angles = pi * [0:numh-1]'/numh; else angles = angles(:); end %%================================================================= if isstr(evenorodd) if strcmp(evenorodd,'even') evenorodd = 0; elseif strcmp(evenorodd,'odd') evenorodd = 1; else error('EVEN_OR_ODD should be the string EVEN or ODD'); end end %% Compute inverse matrix, which maps Fourier components onto %% steerable basis. imtx = zeros(size(angles,1),numh); col = 1; for h=harmonics args = h*angles; if (h == 0) imtx(:,col) = ones(size(angles)); col = col+1; elseif evenorodd imtx(:,col) = sin(args); imtx(:,col+1) = -cos(args); col = col+2; else imtx(:,col) = cos(args); imtx(:,col+1) = sin(args); col = col+2; end end r = rank(imtx); if (( r ~= numh ) & ( r ~= size(angles,1) )) fprintf(2,'WARNING: matrix is not full rank'); end mtx = pinv(imtx);
github
jacksky64/imageProcessing-master
mkAngularSine.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/mkAngularSine.m
845
utf_8
78a5e0afe3fef5c42804516e2ea1ccc8
% IM = mkAngularSine(SIZE, HARMONIC, AMPL, PHASE, ORIGIN) % % Make an angular sinusoidal image: % AMPL * sin( HARMONIC*theta + PHASE), % where theta is the angle about the origin. % SIZE specifies the matrix size, as for zeros(). % AMPL (default = 1) and PHASE (default = 0) are optional. % Eero Simoncelli, 2/97. function [res] = mkAngularSine(sz, harmonic, ampl, ph, origin) sz = sz(:); if (size(sz,1) == 1) sz = [sz,sz]; end mxsz = max(sz(1),sz(2)); %------------------------------------------------------------ %% OPTIONAL ARGS: if (exist('harmonic') ~= 1) harmonic = 1; end if (exist('ampl') ~= 1) ampl = 1; end if (exist('ph') ~= 1) ph = 0; end if (exist('origin') ~= 1) origin = (sz+1)/2; end %------------------------------------------------------------ res = ampl * sin(harmonic*mkAngle(sz,ph,origin) + ph);
github
jacksky64/imageProcessing-master
mkRamp.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/mkRamp.m
1,110
utf_8
28989822e19c604a816a287a4bee873d
% IM = mkRamp(SIZE, DIRECTION, SLOPE, INTERCEPT, ORIGIN) % % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) % containing samples of a ramp function, with given gradient DIRECTION % (radians, CW from X-axis, default = 0), SLOPE (per pixel, default = % 1), and a value of INTERCEPT (default = 0) at the ORIGIN (default = % (size+1)/2, [1 1] = upper left). All but the first argument are % optional. % Eero Simoncelli, 6/96. 2/97: adjusted coordinate system. function [res] = mkRamp(sz, dir, slope, intercept, origin) sz = sz(:); if (size(sz,1) == 1) sz = [sz,sz]; end % ----------------------------------------------------------------- % OPTIONAL args: if (exist('dir') ~= 1) dir = 0; end if (exist('slope') ~= 1) slope = 1; end if (exist('intercept') ~= 1) intercept = 0; end if (exist('origin') ~= 1) origin = (sz+1)/2; end % ----------------------------------------------------------------- xinc = slope*cos(dir); yinc = slope*sin(dir); [xramp,yramp] = meshgrid( xinc*([1:sz(2)]-origin(2)), ... yinc*([1:sz(1)]-origin(1)) ); res = intercept + xramp + yramp;
github
jacksky64/imageProcessing-master
histoMatch.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/histoMatch.m
858
utf_8
8936fc2eadacc591ecdffe5967726780
% RES = histoMatch(MTX, N, X) % % Modify elements of MTX so that normalized histogram matches that % specified by vectors X and N, where N contains the histogram counts % and X the histogram bin positions (see histo). % Eero Simoncelli, 7/96. function res = histoMatch(mtx, N, X) if ( exist('histo') == 3 ) [oN, oX] = histo(mtx(:), size(X(:),1)); else [oN, oX] = hist(mtx(:), size(X(:),1)); end oStep = oX(2) - oX(1); oC = [0, cumsum(oN)]/sum(oN); oX = [oX(1)-oStep/2, oX+oStep/2]; N = N(:)'; X = X(:)'; N = N + mean(N)/(1e8); %% HACK: no empty bins ensures nC strictly monotonic nStep = X(2) - X(1); nC = [0, cumsum(N)]/sum(N); nX = [X(1)-nStep/2, X+nStep/2]; nnX = interp1(nC, nX, oC, 'linear'); if ( exist('pointOp') == 3 ) res = pointOp(mtx, nnX, oX(1), oStep); else res = reshape(interp1(oX, nnX, mtx(:)),size(mtx,1),size(mtx,2)); end
github
jacksky64/imageProcessing-master
subMtx.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/subMtx.m
420
utf_8
c660029ce728dcb8c540c9cf419fa7bc
% MTX = subMtx(VEC, DIMENSIONS, START_INDEX) % % Reshape a portion of VEC starting from START_INDEX (optional, % default=1) to the given dimensions. % Eero Simoncelli, 6/96. function mtx = subMtx(vec, sz, offset) if (exist('offset') ~= 1) offset = 1; end vec = vec(:); sz = sz(:); if (size(sz,1) ~= 2) error('DIMENSIONS must be a 2-vector.'); end mtx = reshape( vec(offset:offset+prod(sz)-1), sz(1), sz(2) );
github
jacksky64/imageProcessing-master
showLpyr.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/showLpyr.m
5,421
utf_8
0646b94ae144cf6160a44f50e67f8dd5
% RANGE = showLpyr (PYR, INDICES, RANGE, GAP, LEVEL_SCALE_FACTOR) % % Display a Laplacian (or Gaussian) pyramid, specified by PYR and % INDICES (see buildLpyr), in the current figure. % % RANGE is a 2-vector specifying the values that map to black and % white, respectively. These values are scaled by % LEVEL_SCALE_FACTOR^(lev-1) for bands at each level. Passing a value % of 'auto1' sets RANGE to the min and max values of MATRIX. 'auto2' % sets RANGE to 3 standard deviations below and above 0.0. In both of % these cases, the lowpass band is independently scaled. A value of % 'indep1' sets the range of each subband independently, as in a call % to showIm(subband,'auto1'). Similarly, 'indep2' causes each subband % to be scaled independently as if by showIm(subband,'indep2'). % The default value for RANGE is 'auto1' for 1D images, and 'auto2' for % 2D images. % % GAP (optional, default=1) specifies the gap in pixels to leave % between subbands (2D images only). % % LEVEL_SCALE_FACTOR indicates the relative scaling between pyramid % levels. This should be set to the sum of the kernel taps of the % lowpass filter used to construct the pyramid (default assumes % L2-normalalized filters, using a value of 2 for 2D images, sqrt(2) for % 1D images). % Eero Simoncelli, 2/97. function [range] = showLpyr(pyr, pind, range, gap, scale); % Determine 1D or 2D pyramid: if ((pind(1,1) == 1) | (pind(1,2) ==1)) oned = 1; else oned = 0; end %------------------------------------------------------------ %% OPTIONAL ARGS: if (exist('range') ~= 1) if (oned==1) range = 'auto1'; else range = 'auto2'; end end if (exist('gap') ~= 1) gap = 1; end if (exist('scale') ~= 1) if (oned == 1) scale = sqrt(2); else scale = 2; end end %------------------------------------------------------------ nind = size(pind,1); %% Auto range calculations: if strcmp(range,'auto1') range = zeros(nind,1); mn = 0.0; mx = 0.0; for bnum = 1:(nind-1) band = pyrBand(pyr,pind,bnum)/(scale^(bnum-1)); range(bnum) = scale^(bnum-1); [bmn,bmx] = range2(band); mn = min(mn, bmn); mx = max(mx, bmx); end if (oned == 1) pad = (mx-mn)/12; % *** MAGIC NUMBER!! mn = mn-pad; mx = mx+pad; end range = range * [mn mx]; % outer product band = pyrLow(pyr,pind); [mn,mx] = range2(band); if (oned == 1) pad = (mx-mn)/12; % *** MAGIC NUMBER!! mn = mn-pad; mx = mx+pad; end range(nind,:) = [mn, mx]; elseif strcmp(range,'indep1') range = zeros(nind,2); for bnum = 1:nind band = pyrBand(pyr,pind,bnum); [mn,mx] = range2(band); if (oned == 1) pad = (mx-mn)/12; % *** MAGIC NUMBER!! mn = mn-pad; mx = mx+pad; end range(bnum,:) = [mn mx]; end elseif strcmp(range,'auto2') range = zeros(nind,1); sqsum = 0; numpixels = 0; for bnum = 1:(nind-1) band = pyrBand(pyr,pind,bnum)/(scale^(bnum-1)); sqsum = sqsum + sum(sum(band.^2)); numpixels = numpixels + prod(size(band)); range(bnum) = scale^(bnum-1); end stdev = sqrt(sqsum/(numpixels-1)); range = range * [ -3*stdev 3*stdev ]; % outer product band = pyrLow(pyr,pind); av = mean2(band); stdev = sqrt(var2(band)); range(nind,:) = [av-2*stdev,av+2*stdev]; elseif strcmp(range,'indep2') range = zeros(nind,2); for bnum = 1:(nind-1) band = pyrBand(pyr,pind,bnum); stdev = sqrt(var2(band)); range(bnum,:) = [ -3*stdev 3*stdev ]; end band = pyrLow(pyr,pind); av = mean2(band); stdev = sqrt(var2(band)); range(nind,:) = [av-2*stdev,av+2*stdev]; elseif isstr(range) error(sprintf('Bad RANGE argument: %s',range)) elseif ((size(range,1) == 1) & (size(range,2) == 2)) scales = scale.^[0:nind-1]; range = scales(:) * range; % outer product band = pyrLow(pyr,pind); range(nind,:) = range(nind,:) + mean2(band) - mean(range(nind,:)); end %% Clear Figure clf; if (oned == 1) %%%%% 1D signal: for bnum=1:nind band = pyrBand(pyr,pind,bnum); subplot(nind,1,nind-bnum+1); plot(band); axis([1, prod(size(band)), range(bnum,:)]); end else %%%%% 2D signal: colormap(gray); cmap = get(gcf,'Colormap'); nshades = size(cmap,1); % Find background color index: clr = get(gcf,'Color'); bg = 1; dist = norm(cmap(bg,:)-clr); for n = 1:nshades ndist = norm(cmap(n,:)-clr); if (ndist < dist) dist = ndist; bg = n; end end %% Compute positions of subbands: llpos = ones(nind,2); dir = [-1 -1]; ctr = [pind(1,1)+1+gap 1]; sz = [0 0]; for bnum = 1:nind prevsz = sz; sz = pind(bnum,:); % Determine center position of new band: ctr = ctr + gap*dir/2 + dir.* floor((prevsz+(dir>0))/2); dir = dir * [0 -1; 1 0]; % ccw rotation ctr = ctr + gap*dir/2 + dir.* floor((sz+(dir<0))/2); llpos(bnum,:) = ctr - floor(sz./2); end %% Make position list positive, and allocate appropriate image: llpos = llpos - ones(nind,1)*min(llpos) + 1; urpos = llpos + pind - 1; d_im = bg + zeros(max(urpos)); %% Paste bands into image, (im-r1)*(nshades-1)/(r2-r1) + 1.5 for bnum=1:nind mult = (nshades-1) / (range(bnum,2)-range(bnum,1)); d_im(llpos(bnum,1):urpos(bnum,1), llpos(bnum,2):urpos(bnum,2)) = ... mult*pyrBand(pyr,pind,bnum) + (1.5-mult*range(bnum,1)); end hh = image(d_im); axis('off'); pixelAxes(size(d_im),'full'); set(hh,'UserData',range); end
github
jacksky64/imageProcessing-master
sp1Filters.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/sp1Filters.m
9,435
utf_8
81cfbf726744492bee2374b9b564ebdf
% Steerable pyramid filters. Transform described in: % % @INPROCEEDINGS{Simoncelli95b, % TITLE = "The Steerable Pyramid: A Flexible Architecture for % Multi-Scale Derivative Computation", % AUTHOR = "E P Simoncelli and W T Freeman", % BOOKTITLE = "Second Int'l Conf on Image Processing", % ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } % % Filter kernel design described in: % %@INPROCEEDINGS{Karasaridis96, % TITLE = "A Filter Design Technique for % Steerable Pyramid Image Transforms", % AUTHOR = "A Karasaridis and E P Simoncelli", % BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", % MONTH = "May", YEAR = 1996 } % Eero Simoncelli, 6/96. function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp1Filters(); harmonics = [ 1 ]; %% filters only contain first harmonic. mtx = eye(2); lo0filt = [ ... -8.701000e-05 -1.354280e-03 -1.601260e-03 -5.033700e-04 2.524010e-03 -5.033700e-04 -1.601260e-03 -1.354280e-03 -8.701000e-05 -1.354280e-03 2.921580e-03 7.522720e-03 8.224420e-03 1.107620e-03 8.224420e-03 7.522720e-03 2.921580e-03 -1.354280e-03 -1.601260e-03 7.522720e-03 -7.061290e-03 -3.769487e-02 -3.297137e-02 -3.769487e-02 -7.061290e-03 7.522720e-03 -1.601260e-03 -5.033700e-04 8.224420e-03 -3.769487e-02 4.381320e-02 1.811603e-01 4.381320e-02 -3.769487e-02 8.224420e-03 -5.033700e-04 2.524010e-03 1.107620e-03 -3.297137e-02 1.811603e-01 4.376250e-01 1.811603e-01 -3.297137e-02 1.107620e-03 2.524010e-03 -5.033700e-04 8.224420e-03 -3.769487e-02 4.381320e-02 1.811603e-01 4.381320e-02 -3.769487e-02 8.224420e-03 -5.033700e-04 -1.601260e-03 7.522720e-03 -7.061290e-03 -3.769487e-02 -3.297137e-02 -3.769487e-02 -7.061290e-03 7.522720e-03 -1.601260e-03 -1.354280e-03 2.921580e-03 7.522720e-03 8.224420e-03 1.107620e-03 8.224420e-03 7.522720e-03 2.921580e-03 -1.354280e-03 -8.701000e-05 -1.354280e-03 -1.601260e-03 -5.033700e-04 2.524010e-03 -5.033700e-04 -1.601260e-03 -1.354280e-03 -8.701000e-05 ]; lofilt = [ ... -4.350000e-05 1.207800e-04 -6.771400e-04 -1.243400e-04 -8.006400e-04 -1.597040e-03 -2.516800e-04 -4.202000e-04 1.262000e-03 -4.202000e-04 -2.516800e-04 -1.597040e-03 -8.006400e-04 -1.243400e-04 -6.771400e-04 1.207800e-04 -4.350000e-05 ; ... 1.207800e-04 4.460600e-04 -5.814600e-04 5.621600e-04 -1.368800e-04 2.325540e-03 2.889860e-03 4.287280e-03 5.589400e-03 4.287280e-03 2.889860e-03 2.325540e-03 -1.368800e-04 5.621600e-04 -5.814600e-04 4.460600e-04 1.207800e-04 ; ... -6.771400e-04 -5.814600e-04 1.460780e-03 2.160540e-03 3.761360e-03 3.080980e-03 4.112200e-03 2.221220e-03 5.538200e-04 2.221220e-03 4.112200e-03 3.080980e-03 3.761360e-03 2.160540e-03 1.460780e-03 -5.814600e-04 -6.771400e-04 ; ... -1.243400e-04 5.621600e-04 2.160540e-03 3.175780e-03 3.184680e-03 -1.777480e-03 -7.431700e-03 -9.056920e-03 -9.637220e-03 -9.056920e-03 -7.431700e-03 -1.777480e-03 3.184680e-03 3.175780e-03 2.160540e-03 5.621600e-04 -1.243400e-04 ; ... -8.006400e-04 -1.368800e-04 3.761360e-03 3.184680e-03 -3.530640e-03 -1.260420e-02 -1.884744e-02 -1.750818e-02 -1.648568e-02 -1.750818e-02 -1.884744e-02 -1.260420e-02 -3.530640e-03 3.184680e-03 3.761360e-03 -1.368800e-04 -8.006400e-04 ; ... -1.597040e-03 2.325540e-03 3.080980e-03 -1.777480e-03 -1.260420e-02 -2.022938e-02 -1.109170e-02 3.955660e-03 1.438512e-02 3.955660e-03 -1.109170e-02 -2.022938e-02 -1.260420e-02 -1.777480e-03 3.080980e-03 2.325540e-03 -1.597040e-03 ; ... -2.516800e-04 2.889860e-03 4.112200e-03 -7.431700e-03 -1.884744e-02 -1.109170e-02 2.190660e-02 6.806584e-02 9.058014e-02 6.806584e-02 2.190660e-02 -1.109170e-02 -1.884744e-02 -7.431700e-03 4.112200e-03 2.889860e-03 -2.516800e-04 ; ... -4.202000e-04 4.287280e-03 2.221220e-03 -9.056920e-03 -1.750818e-02 3.955660e-03 6.806584e-02 1.445500e-01 1.773651e-01 1.445500e-01 6.806584e-02 3.955660e-03 -1.750818e-02 -9.056920e-03 2.221220e-03 4.287280e-03 -4.202000e-04 ; ... 1.262000e-03 5.589400e-03 5.538200e-04 -9.637220e-03 -1.648568e-02 1.438512e-02 9.058014e-02 1.773651e-01 2.120374e-01 1.773651e-01 9.058014e-02 1.438512e-02 -1.648568e-02 -9.637220e-03 5.538200e-04 5.589400e-03 1.262000e-03 ; ... -4.202000e-04 4.287280e-03 2.221220e-03 -9.056920e-03 -1.750818e-02 3.955660e-03 6.806584e-02 1.445500e-01 1.773651e-01 1.445500e-01 6.806584e-02 3.955660e-03 -1.750818e-02 -9.056920e-03 2.221220e-03 4.287280e-03 -4.202000e-04 ; ... -2.516800e-04 2.889860e-03 4.112200e-03 -7.431700e-03 -1.884744e-02 -1.109170e-02 2.190660e-02 6.806584e-02 9.058014e-02 6.806584e-02 2.190660e-02 -1.109170e-02 -1.884744e-02 -7.431700e-03 4.112200e-03 2.889860e-03 -2.516800e-04 ; ... -1.597040e-03 2.325540e-03 3.080980e-03 -1.777480e-03 -1.260420e-02 -2.022938e-02 -1.109170e-02 3.955660e-03 1.438512e-02 3.955660e-03 -1.109170e-02 -2.022938e-02 -1.260420e-02 -1.777480e-03 3.080980e-03 2.325540e-03 -1.597040e-03 ; ... -8.006400e-04 -1.368800e-04 3.761360e-03 3.184680e-03 -3.530640e-03 -1.260420e-02 -1.884744e-02 -1.750818e-02 -1.648568e-02 -1.750818e-02 -1.884744e-02 -1.260420e-02 -3.530640e-03 3.184680e-03 3.761360e-03 -1.368800e-04 -8.006400e-04 ; ... -1.243400e-04 5.621600e-04 2.160540e-03 3.175780e-03 3.184680e-03 -1.777480e-03 -7.431700e-03 -9.056920e-03 -9.637220e-03 -9.056920e-03 -7.431700e-03 -1.777480e-03 3.184680e-03 3.175780e-03 2.160540e-03 5.621600e-04 -1.243400e-04 ; ... -6.771400e-04 -5.814600e-04 1.460780e-03 2.160540e-03 3.761360e-03 3.080980e-03 4.112200e-03 2.221220e-03 5.538200e-04 2.221220e-03 4.112200e-03 3.080980e-03 3.761360e-03 2.160540e-03 1.460780e-03 -5.814600e-04 -6.771400e-04 ; ... 1.207800e-04 4.460600e-04 -5.814600e-04 5.621600e-04 -1.368800e-04 2.325540e-03 2.889860e-03 4.287280e-03 5.589400e-03 4.287280e-03 2.889860e-03 2.325540e-03 -1.368800e-04 5.621600e-04 -5.814600e-04 4.460600e-04 1.207800e-04 ; ... -4.350000e-05 1.207800e-04 -6.771400e-04 -1.243400e-04 -8.006400e-04 -1.597040e-03 -2.516800e-04 -4.202000e-04 1.262000e-03 -4.202000e-04 -2.516800e-04 -1.597040e-03 -8.006400e-04 -1.243400e-04 -6.771400e-04 1.207800e-04 -4.350000e-05 ]; hi0filt = [... -9.570000e-04 -2.424100e-04 -1.424720e-03 -8.742600e-04 -1.166810e-03 -8.742600e-04 -1.424720e-03 -2.424100e-04 -9.570000e-04 ; ... -2.424100e-04 -4.317530e-03 8.998600e-04 9.156420e-03 1.098012e-02 9.156420e-03 8.998600e-04 -4.317530e-03 -2.424100e-04 ; ... -1.424720e-03 8.998600e-04 1.706347e-02 1.094866e-02 -5.897780e-03 1.094866e-02 1.706347e-02 8.998600e-04 -1.424720e-03 ; ... -8.742600e-04 9.156420e-03 1.094866e-02 -7.841370e-02 -1.562827e-01 -7.841370e-02 1.094866e-02 9.156420e-03 -8.742600e-04 ; ... -1.166810e-03 1.098012e-02 -5.897780e-03 -1.562827e-01 7.282593e-01 -1.562827e-01 -5.897780e-03 1.098012e-02 -1.166810e-03 ; ... -8.742600e-04 9.156420e-03 1.094866e-02 -7.841370e-02 -1.562827e-01 -7.841370e-02 1.094866e-02 9.156420e-03 -8.742600e-04 ; ... -1.424720e-03 8.998600e-04 1.706347e-02 1.094866e-02 -5.897780e-03 1.094866e-02 1.706347e-02 8.998600e-04 -1.424720e-03 ; ... -2.424100e-04 -4.317530e-03 8.998600e-04 9.156420e-03 1.098012e-02 9.156420e-03 8.998600e-04 -4.317530e-03 -2.424100e-04 ; ... -9.570000e-04 -2.424100e-04 -1.424720e-03 -8.742600e-04 -1.166810e-03 -8.742600e-04 -1.424720e-03 -2.424100e-04 -9.570000e-04 ]; bfilts = -[ ... 6.125880e-03 -8.052600e-03 -2.103714e-02 -1.536890e-02 -1.851466e-02 -1.536890e-02 -2.103714e-02 -8.052600e-03 6.125880e-03 ... -1.287416e-02 -9.611520e-03 1.023569e-02 6.009450e-03 1.872620e-03 6.009450e-03 1.023569e-02 -9.611520e-03 -1.287416e-02 ... -5.641530e-03 4.168400e-03 -2.382180e-02 -5.375324e-02 -2.076086e-02 -5.375324e-02 -2.382180e-02 4.168400e-03 -5.641530e-03 ... -8.957260e-03 -1.751170e-03 -1.836909e-02 1.265655e-01 2.996168e-01 1.265655e-01 -1.836909e-02 -1.751170e-03 -8.957260e-03 ... 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 ... 8.957260e-03 1.751170e-03 1.836909e-02 -1.265655e-01 -2.996168e-01 -1.265655e-01 1.836909e-02 1.751170e-03 8.957260e-03 ... 5.641530e-03 -4.168400e-03 2.382180e-02 5.375324e-02 2.076086e-02 5.375324e-02 2.382180e-02 -4.168400e-03 5.641530e-03 ... 1.287416e-02 9.611520e-03 -1.023569e-02 -6.009450e-03 -1.872620e-03 -6.009450e-03 -1.023569e-02 9.611520e-03 1.287416e-02 ... -6.125880e-03 8.052600e-03 2.103714e-02 1.536890e-02 1.851466e-02 1.536890e-02 2.103714e-02 8.052600e-03 -6.125880e-03; ... ... -6.125880e-03 1.287416e-02 5.641530e-03 8.957260e-03 0.000000e+00 -8.957260e-03 -5.641530e-03 -1.287416e-02 6.125880e-03 ... 8.052600e-03 9.611520e-03 -4.168400e-03 1.751170e-03 0.000000e+00 -1.751170e-03 4.168400e-03 -9.611520e-03 -8.052600e-03 ... 2.103714e-02 -1.023569e-02 2.382180e-02 1.836909e-02 0.000000e+00 -1.836909e-02 -2.382180e-02 1.023569e-02 -2.103714e-02 ... 1.536890e-02 -6.009450e-03 5.375324e-02 -1.265655e-01 0.000000e+00 1.265655e-01 -5.375324e-02 6.009450e-03 -1.536890e-02 ... 1.851466e-02 -1.872620e-03 2.076086e-02 -2.996168e-01 0.000000e+00 2.996168e-01 -2.076086e-02 1.872620e-03 -1.851466e-02 ... 1.536890e-02 -6.009450e-03 5.375324e-02 -1.265655e-01 0.000000e+00 1.265655e-01 -5.375324e-02 6.009450e-03 -1.536890e-02 ... 2.103714e-02 -1.023569e-02 2.382180e-02 1.836909e-02 0.000000e+00 -1.836909e-02 -2.382180e-02 1.023569e-02 -2.103714e-02 ... 8.052600e-03 9.611520e-03 -4.168400e-03 1.751170e-03 0.000000e+00 -1.751170e-03 4.168400e-03 -9.611520e-03 -8.052600e-03 ... -6.125880e-03 1.287416e-02 5.641530e-03 8.957260e-03 0.000000e+00 -8.957260e-03 -5.641530e-03 -1.287416e-02 6.125880e-03 ... ]';
github
jacksky64/imageProcessing-master
spyrHt.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/spyrHt.m
305
utf_8
06e83c1f45c1a99e242fa7ea37093a11
% [HEIGHT] = spyrHt(INDICES) % % Compute height of steerable pyramid with given index matrix. % Eero Simoncelli, 6/96. function [ht] = spyrHt(pind) nbands = spyrNumBands(pind); % Don't count lowpass, or highpass residual bands if (size(pind,1) > 2) ht = (size(pind,1)-2)/nbands; else ht = 0; end
github
jacksky64/imageProcessing-master
spyrBand.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/spyrBand.m
819
utf_8
7d15b24244e521c9e85c68b3037f569b
% [LEV,IND] = spyrBand(PYR,INDICES,LEVEL,BAND) % % Access a band from a steerable pyramid. % % LEVEL indicates the scale (finest = 1, coarsest = spyrHt(INDICES)). % % BAND (optional, default=1) indicates which subband % (1 = vertical, rest proceeding anti-clockwise). % Eero Simoncelli, 6/96. function res = spyrBand(pyr,pind,level,band) if (exist('level') ~= 1) level = 1; end if (exist('band') ~= 1) band = 1; end nbands = spyrNumBands(pind); if ((band > nbands) | (band < 1)) error(sprintf('Bad band number (%d) should be in range [1,%d].', band, nbands)); end maxLev = spyrHt(pind); if ((level > maxLev) | (level < 1)) error(sprintf('Bad level number (%d), should be in range [1,%d].', level, maxLev)); end firstband = 1 + band + nbands*(level-1); res = pyrBand(pyr, pind, firstband);
github
jacksky64/imageProcessing-master
wpyrBand.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/wpyrBand.m
873
utf_8
12e08d90ccd6261b737e2d3c5ac5b1e7
% RES = wpyrBand(PYR, INDICES, LEVEL, BAND) % % Access a subband from a separable QMF/wavelet pyramid. % % LEVEL (optional, default=1) indicates the scale (finest = 1, % coarsest = wpyrHt(INDICES)). % % BAND (optional, default=1) indicates which subband (1=horizontal, % 2=vertical, 3=diagonal). % Eero Simoncelli, 6/96. function im = wpyrBand(pyr,pind,level,band) if (exist('level') ~= 1) level = 1; end if (exist('band') ~= 1) band = 1; end if ((pind(1,1) == 1) | (pind(1,2) ==1)) nbands = 1; else nbands = 3; end if ((band > nbands) | (band < 1)) error(sprintf('Bad band number (%d) should be in range [1,%d].', band, nbands)); end maxLev = wpyrHt(pind); if ((level > maxLev) | (level < 1)) error(sprintf('Bad level number (%d), should be in range [1,%d].', level, maxLev)); end band = band + nbands*(level-1); im = pyrBand(pyr,pind,band);
github
jacksky64/imageProcessing-master
skew2.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/skew2.m
478
utf_8
b304767117ab43e408c5757ab9e3402d
% S = SKEW2(MTX,MEAN,VAR) % % Sample skew (third moment divided by variance^3/2) of a matrix. % MEAN (optional) and VAR (optional) make the computation faster. function res = skew2(mtx, mn, v) if (exist('mn') ~= 1) mn = mean2(mtx); end if (exist('v') ~= 1) v = var2(mtx,mn); end if (isreal(mtx)) res = mean(mean((mtx-mn).^3)) / (v^(3/2)); else res = mean(mean(real(mtx-mn).^3)) / (real(v)^(3/2)) + ... i * mean(mean(imag(mtx-mn).^3)) / (imag(v)^(3/2)); end
github
jacksky64/imageProcessing-master
imStats.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/imStats.m
1,217
utf_8
aab8c3264c5939806bbca5657c925734
% imStats(IM1,IM2) % % Report image (matrix) statistics. % When called on a single image IM1, report min, max, mean, stdev, skew, % and kurtosis (4th moment about the mean, divided by squared variance) % % When called on two images (IM1 and IM2), report min, max, mean, % stdev of the difference, and also SNR (relative to IM1). % Eero Simoncelli, 6/96. function [] = imStats(im1,im2) if (~isreal(im1)) error('Args must be real-valued matrices'); end if (exist('im2') == 1) difference = im1 - im2; [mn,mx] = range2(difference); mean = mean2(difference); v = var2(difference,mean); if (v < realmin) snr = Inf; else snr = 10 * log10(var2(im1)/v); end fprintf(1, 'Difference statistics:\n'); fprintf(1, ' Range: [%c, %c]\n',mn,mx); fprintf(1, ' Mean: %f, Stdev (rmse): %f, SNR (dB): %f\n',... mean,sqrt(v),snr); else [mn,mx] = range2(im1); mean = mean2(im1); var = var2(im1,mean); stdev = sqrt(real(var))+sqrt(imag(var)); sk = skew2(im1, mean, stdev^2); kurt = kurt2(im1, mean, stdev^2); fprintf(1, 'Image statistics:\n'); fprintf(1, ' Range: [%f, %f]\n',mn,mx); fprintf(1, ' Mean: %f, Stdev: %f, Skew: %f, Kurt: %f\n',mean,stdev,sk,kurt); end
github
jacksky64/imageProcessing-master
innerProd.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/innerProd.m
314
utf_8
e2ea166f9b3ddbc08cb54ef697343d06
% RES = innerProd(MTX) % % Compute (MTX' * MTX) efficiently (i.e., without copying the matrix) % % NOTE: This function used to call a MEX function (C code) to avoid copying, but % newer versions of matlab have eliminated the overhead of the % simpler form below. function res = innerProd(mtx) res = mtx' * mtx;
github
jacksky64/imageProcessing-master
reconSFpyr.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/reconSFpyr.m
3,114
utf_8
ebb08817efc597692b9026a84e2a6906
% RES = reconSFpyr(PYR, INDICES, LEVS, BANDS, TWIDTH) % % Reconstruct image from its steerable pyramid representation, in the Fourier % domain, as created by buildSFpyr. % % PYR is a vector containing the N pyramid subbands, ordered from fine % to coarse. INDICES is an Nx2 matrix containing the sizes of % each subband. This is compatible with the MatLab Wavelet toolbox. % % LEVS (optional) should be a list of levels to include, or the string % 'all' (default). 0 corresonds to the residual highpass subband. % 1 corresponds to the finest oriented scale. The lowpass band % corresponds to number spyrHt(INDICES)+1. % % BANDS (optional) should be a list of bands to include, or the string % 'all' (default). 1 = vertical, rest proceeding anti-clockwise. % % TWIDTH is the width of the transition region of the radial lowpass % function, in octaves (default = 1, which gives a raised cosine for % the bandpass filters). %%% MODIFIED VERSION, 7/04, uses different lookup table for radial frequency! % Eero Simoncelli, 5/97. function res = reconSFpyr(pyr, pind, levs, bands, twidth) %%------------------------------------------------------------ %% DEFAULTS: if (exist('levs') ~= 1) levs = 'all'; end if (exist('bands') ~= 1) bands = 'all'; end if (exist('twidth') ~= 1) twidth = 1; elseif (twidth <= 0) fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); twidth = 1; end %%------------------------------------------------------------ nbands = spyrNumBands(pind); maxLev = 1+spyrHt(pind); if strcmp(levs,'all') levs = [0:maxLev]'; else if (any(levs > maxLev) | any(levs < 0)) error(sprintf('Level numbers must be in the range [0, %d].', maxLev)); end levs = levs(:); end if strcmp(bands,'all') bands = [1:nbands]'; else if (any(bands < 1) | any(bands > nbands)) error(sprintf('Band numbers must be in the range [1,3].', nbands)); end bands = bands(:); end %---------------------------------------------------------------------- dims = pind(1,:); ctr = ceil((dims+0.5)/2); [xramp,yramp] = meshgrid( ([1:dims(2)]-ctr(2))./(dims(2)/2), ... ([1:dims(1)]-ctr(1))./(dims(1)/2) ); angle = atan2(yramp,xramp); log_rad = sqrt(xramp.^2 + yramp.^2); log_rad(ctr(1),ctr(2)) = log_rad(ctr(1),ctr(2)-1); log_rad = log2(log_rad); %% Radial transition function (a raised cosine in log-frequency): [Xrcos,Yrcos] = rcosFn(twidth,(-twidth/2),[0 1]); Yrcos = sqrt(Yrcos); YIrcos = sqrt(abs(1.0 - Yrcos.^2)); if (size(pind,1) == 2) if (any(levs==1)) resdft = fftshift(fft2(pyrBand(pyr,pind,2))); else resdft = zeros(pind(2,:)); end else resdft = reconSFpyrLevs(pyr(1+prod(pind(1,:)):size(pyr,1)), ... pind(2:size(pind,1),:), ... log_rad, Xrcos, Yrcos, angle, nbands, levs, bands); end lo0mask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); resdft = resdft .* lo0mask; %% residual highpass subband if any(levs == 0) hi0mask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); hidft = fftshift(fft2(subMtx(pyr, pind(1,:)))); resdft = resdft + hidft .* hi0mask; end res = real(ifft2(ifftshift(resdft)));
github
jacksky64/imageProcessing-master
corrDn.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/corrDn.m
2,272
utf_8
cce615994bded51a721560b782ea9eef
% RES = corrDn(IM, FILT, EDGES, STEP, START, STOP) % % Compute correlation of matrices IM with FILT, followed by % downsampling. These arguments should be 1D or 2D matrices, and IM % must be larger (in both dimensions) than FILT. The origin of filt % is assumed to be floor(size(filt)/2)+1. % % EDGES is a string determining boundary handling: % 'circular' - Circular convolution % 'reflect1' - Reflect about the edge pixels % 'reflect2' - Reflect, doubling the edge pixels % 'repeat' - Repeat the edge pixels % 'zero' - Assume values of zero outside image boundary % 'extend' - Reflect and invert (continuous values and derivs) % 'dont-compute' - Zero output when filter overhangs input boundaries % % Downsampling factors are determined by STEP (optional, default=[1 1]), % which should be a 2-vector [y,x]. % % The window over which the convolution occurs is specfied by START % (optional, default=[1,1], and STOP (optional, default=size(IM)). % % NOTE: this operation corresponds to multiplication of a signal % vector by a matrix whose rows contain copies of the FILT shifted by % multiples of STEP. See upConv.m for the operation corresponding to % the transpose of this matrix. % Eero Simoncelli, 6/96, revised 2/97. function res = corrDn(im, filt, edges, step, start, stop) %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) fprintf(1,'WARNING: You should compile the MEX version of "corrDn.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster, and provides more boundary-handling options.\n'); %------------------------------------------------------------ %% OPTIONAL ARGS: if (exist('edges') == 1) if (strcmp(edges,'reflect1') ~= 1) warning('Using REFLECT1 edge-handling (use MEX code for other options).'); end end if (exist('step') ~= 1) step = [1,1]; end if (exist('start') ~= 1) start = [1,1]; end if (exist('stop') ~= 1) stop = size(im); end %------------------------------------------------------------ % Reverse order of taps in filt, to do correlation instead of convolution filt = filt(size(filt,1):-1:1,size(filt,2):-1:1); tmp = rconv2(im,filt); res = tmp(start(1):step(1):stop(1),start(2):step(2):stop(2));
github
jacksky64/imageProcessing-master
vectify.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/vectify.m
186
utf_8
1da0e519af06d6baaff1decc40dc3702
% [VEC] = columnize(MTX) % % Pack elements of MTX into a column vector. Just provides a % function-call notatoin for the operation MTX(:) function vec = columnize(mtx) vec = mtx(:);
github
jacksky64/imageProcessing-master
maxPyrHt.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/maxPyrHt.m
603
utf_8
019e5ce9d036a893ec979c63f51ff54a
% HEIGHT = maxPyrHt(IMSIZE, FILTSIZE) % % Compute maximum pyramid height for given image and filter sizes. % Specifically: the number of corrDn operations that can be sequentially % performed when subsampling by a factor of 2. % Eero Simoncelli, 6/96. function height = maxPyrHt(imsz, filtsz) imsz = imsz(:); filtsz = filtsz(:); if any(imsz == 1) % 1D image imsz = prod(imsz); filtsz = prod(filtsz); elseif any(filtsz == 1) % 2D image, 1D filter filtsz = [filtsz(1); filtsz(1)]; end if any(imsz < filtsz) height = 0; else height = 1 + maxPyrHt( floor(imsz/2), filtsz ); end
github
jacksky64/imageProcessing-master
buildSpyrLevs.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/buildSpyrLevs.m
861
utf_8
a5fa1e98161a8137e666c1406c28a748
% [PYR, INDICES] = buildSpyrLevs(LOIM, HEIGHT, LOFILT, BFILTS, EDGES) % % Recursive function for constructing levels of a steerable pyramid. This % is called by buildSpyr, and is not usually called directly. % Eero Simoncelli, 6/96. function [pyr,pind] = buildSpyrLevs(lo0,ht,lofilt,bfilts,edges); if (ht <= 0) pyr = lo0(:); pind = size(lo0); else % Assume square filters: bfiltsz = round(sqrt(size(bfilts,1))); bands = zeros(prod(size(lo0)),size(bfilts,2)); bind = zeros(size(bfilts,2),2); for b = 1:size(bfilts,2) filt = reshape(bfilts(:,b),bfiltsz,bfiltsz); band = corrDn(lo0, filt, edges); bands(:,b) = band(:); bind(b,:) = size(band); end lo = corrDn(lo0, lofilt, edges, [2 2], [1 1]); [npyr,nind] = buildSpyrLevs(lo, ht-1, lofilt, bfilts, edges); pyr = [bands(:); npyr]; pind = [bind; nind]; end
github
jacksky64/imageProcessing-master
showSpyr.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/showSpyr.m
5,213
utf_8
bc643d88c491a55c0a0abb5e86c91757
% RANGE = showSpyr (PYR, INDICES, RANGE, GAP, LEVEL_SCALE_FACTOR) % % Display a steerable pyramid, specified by PYR and INDICES % (see buildSpyr), in the current figure. The highpass band is not shown. % % RANGE is a 2-vector specifying the values that map to black and % white, respectively. These values are scaled by % LEVEL_SCALE_FACTOR^(lev-1) for bands at each level. Passing a value % of 'auto1' sets RANGE to the min and max values of MATRIX. 'auto2' % sets RANGE to 3 standard deviations below and above 0.0. In both of % these cases, the lowpass band is independently scaled. A value of % 'indep1' sets the range of each subband independently, as in a call % to showIm(subband,'auto1'). Similarly, 'indep2' causes each subband % to be scaled independently as if by showIm(subband,'indep2'). % The default value for RANGE is 'auto2'. % % GAP (optional, default=1) specifies the gap in pixels to leave % between subbands. % % LEVEL_SCALE_FACTOR indicates the relative scaling between pyramid % levels. This should be set to the sum of the kernel taps of the % lowpass filter used to construct the pyramid (default is 2, which is % correct for L2-normalized filters. % Eero Simoncelli, 2/97. function [range] = showSpyr(pyr, pind, range, gap, scale); nbands = spyrNumBands(pind); %------------------------------------------------------------ %% OPTIONAL ARGS: if (exist('range') ~= 1) range = 'auto2'; end if (exist('gap') ~= 1) gap = 1; end if (exist('scale') ~= 1) scale = 2; end %------------------------------------------------------------ ht = spyrHt(pind); nind = size(pind,1); %% Auto range calculations: if strcmp(range,'auto1') range = ones(nind,1); band = spyrHigh(pyr,pind); [mn,mx] = range2(band); for lnum = 1:ht for bnum = 1:nbands band = spyrBand(pyr,pind,lnum,bnum)/(scale^(lnum-1)); range((lnum-1)*nbands+bnum+1) = scale^(lnum-1); [bmn,bmx] = range2(band); mn = min(mn, bmn); mx = max(mx, bmx); end end range = range * [mn mx]; % outer product band = pyrLow(pyr,pind); [mn,mx] = range2(band); range(nind,:) = [mn, mx]; elseif strcmp(range,'indep1') range = zeros(nind,2); for bnum = 1:nind band = pyrBand(pyr,pind,bnum); [mn,mx] = range2(band); range(bnum,:) = [mn mx]; end elseif strcmp(range,'auto2') range = ones(nind,1); band = spyrHigh(pyr,pind); sqsum = sum(sum(band.^2)); numpixels = prod(size(band)); for lnum = 1:ht for bnum = 1:nbands band = spyrBand(pyr,pind,lnum,bnum)/(scale^(lnum-1)); sqsum = sqsum + sum(sum(band.^2)); numpixels = numpixels + prod(size(band)); range((lnum-1)*nbands+bnum+1) = scale^(lnum-1); end end stdev = sqrt(sqsum/(numpixels-1)); range = range * [ -3*stdev 3*stdev ]; % outer product band = pyrLow(pyr,pind); av = mean2(band); stdev = sqrt(var2(band)); range(nind,:) = [av-2*stdev,av+2*stdev]; elseif strcmp(range,'indep2') range = zeros(nind,2); for bnum = 1:(nind-1) band = pyrBand(pyr,pind,bnum); stdev = sqrt(var2(band)); range(bnum,:) = [ -3*stdev 3*stdev ]; end band = pyrLow(pyr,pind); av = mean2(band); stdev = sqrt(var2(band)); range(nind,:) = [av-2*stdev,av+2*stdev]; elseif isstr(range) error(sprintf('Bad RANGE argument: %s',range)) elseif ((size(range,1) == 1) & (size(range,2) == 2)) scales = scale.^[0:(ht-1)]; scales = ones(nbands,1) * scales; %outer product scales = [1; scales(:); scale^ht]; %tack on highpass and lowpass range = scales * range; % outer product band = pyrLow(pyr,pind); range(nind,:) = range(nind,:) + mean2(band) - mean(range(nind,:)); end % CLEAR FIGURE: clf; colormap(gray); cmap = get(gcf,'Colormap'); nshades = size(cmap,1); % Find background color index: clr = get(gcf,'Color'); bg = 1; dist = norm(cmap(bg,:)-clr); for n = 1:nshades ndist = norm(cmap(n,:)-clr); if (ndist < dist) dist = ndist; bg = n; end end %% Compute positions of subbands: llpos = ones(nind,2); if (nbands == 2) ncols = 1; nrows = 2; else ncols = ceil((nbands+1)/2); nrows = ceil(nbands/2); end relpos = [ (1-nrows):0, zeros(1,(ncols-1)); ... zeros(1,nrows), -1:-1:(1-ncols) ]'; if (nbands > 1) mvpos = [-1 -1]; else mvpos = [0 -1]; end basepos = [0 0]; for lnum = 1:ht ind1 = (lnum-1)*nbands + 2; sz = pind(ind1,:)+gap; basepos = basepos + mvpos .* sz; if (nbands < 5) % to align edges... sz = sz + gap*(ht-lnum+1); end llpos(ind1:ind1+nbands-1,:) = relpos * diag(sz) + ones(nbands,1)*basepos; end % lowpass band sz = pind(nind-1,:)+gap; basepos = basepos + mvpos .* sz; llpos(nind,:) = basepos; %% Make position list positive, and allocate appropriate image: llpos = llpos - ones(nind,1)*min(llpos) + 1; llpos(1,:) = [1 1]; urpos = llpos + pind - 1; d_im = bg + zeros(max(urpos)); %% Paste bands into image, (im-r1)*(nshades-1)/(r2-r1) + 1.5 for bnum=2:nind mult = (nshades-1) / (range(bnum,2)-range(bnum,1)); d_im(llpos(bnum,1):urpos(bnum,1), llpos(bnum,2):urpos(bnum,2)) = ... mult*pyrBand(pyr,pind,bnum) + (1.5-mult*range(bnum,1)); end hh = image(d_im); axis('off'); pixelAxes(size(d_im),'full'); set(hh,'UserData',range);
github
jacksky64/imageProcessing-master
histo.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/histo.m
1,835
utf_8
e76d8956cd1d59f518a8146dc5145f9b
% [N,X] = histo(MTX, nbinsOrBinsize, binCenter); % % Compute a histogram of (all) elements of MTX. N contains the histogram % counts, X is a vector containg the centers of the histogram bins. % % nbinsOrBinsize (optional, default = 101) specifies either % the number of histogram bins, or the negative of the binsize. % % binCenter (optional, default = mean2(MTX)) specifies a center position % for (any one of) the histogram bins. % % How does this differ from MatLab's HIST function? This function: % - allows uniformly spaced bins only. % +/- operates on all elements of MTX, instead of columnwise. % + is much faster (approximately a factor of 80 on my machine). % + allows specification of number of bins OR binsize. Default=101 bins. % + allows (optional) specification of binCenter. % Eero Simoncelli, 3/97. function [N, X] = histo(mtx, nbins, binCtr) %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) fprintf(1,'WARNING: You should compile the MEX version of "histo.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n'); mtx = mtx(:); %------------------------------------------------------------ %% OPTIONAL ARGS: [mn,mx] = range2(mtx); if (exist('binCtr') ~= 1) binCtr = mean(mtx); end if (exist('nbins') == 1) if (nbins < 0) binSize = -nbins; else binSize = ((mx-mn)/nbins); tmpNbins = round((mx-binCtr)/binSize) - round((mn-binCtr)/binSize); if (tmpNbins ~= nbins) warning('Using %d bins instead of requested number (%d)',tmpNbins,nbins); end end else binSize = ((mx-mn)/101); end firstBin = binCtr + binSize*round( (mn-binCtr)/binSize ); tmpNbins = round((mx-binCtr)/binSize) - round((mn-binCtr)/binSize); bins = firstBin + binSize*[0:tmpNbins]; [N, X] = hist(mtx, bins);
github
jacksky64/imageProcessing-master
lplot.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/lplot.m
1,009
utf_8
87c83936af0b318d55077862065b56df
% lplot(VEC, XRANGE) % % Plot VEC, a vector, in "lollipop" format. % XRANGE (optional, default = [1,length(VEC)]), should be a 2-vector % specifying the X positions (for labeling purposes) of the first and % last sample of VEC. % Mark Liberman, Linguistics Dept, UPenn, 1994. function lplot(x,xrange) if (exist('xrange') ~= 1) xrange = [1,length(x)]; end msize = size(x); if ( msize(2) == 1) x = x'; elseif (msize(1) ~= 1) error('First arg must be a vector'); end if (~isreal(x)) fprintf(1,'Warning: Imaginary part of signal ignored\n'); x = abs(x); end N = length(x); index = xrange(1) + (xrange(2)-xrange(1))*[0:(N-1)]/(N-1); xinc = index(2)-index(1); xx = [zeros(1,N);x;zeros(1,N)]; indexis = [index;index;index]; xdiscrete = [0 xx(:)' 0]; idiscrete = [index(1)-xinc indexis(:)' index(N)+xinc]; [mn,mx] = range2(xdiscrete); ypad = (mx-mn)/12; % MAGIC NUMBER: graph padding plot(idiscrete, xdiscrete, index, x, 'o'); axis([index(1)-xinc, index(N)+xinc, mn-ypad, mx+ypad]); return
github
jacksky64/imageProcessing-master
blurDn.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/blurDn.m
1,364
utf_8
d528010bfd2b4c50e7dbb2aede757214
% RES = blurDn(IM, LEVELS, FILT) % % Blur and downsample an image. The blurring is done with filter % kernel specified by FILT (default = 'binom5'), which can be a string % (to be passed to namedFilter), a vector (applied separably as a 1D % convolution kernel in X and Y), or a matrix (applied as a 2D % convolution kernel). The downsampling is always by 2 in each % direction. % % The procedure is applied recursively LEVELS times (default=1). % Eero Simoncelli, 3/97. function res = blurDn(im, nlevs, filt) %------------------------------------------------------------ %% OPTIONAL ARGS: if (exist('nlevs') ~= 1) nlevs = 1; end if (exist('filt') ~= 1) filt = 'binom5'; end %------------------------------------------------------------ if isstr(filt) filt = namedFilter(filt); end filt = filt/sum(filt(:)); if nlevs > 1 im = blurDn(im,nlevs-1,filt); end if (nlevs >= 1) if (any(size(im)==1)) if (~any(size(filt)==1)) error('Cant apply 2D filter to 1D signal'); end if (size(im,2)==1) filt = filt(:); else filt = filt(:)'; end res = corrDn(im,filt,'reflect1',(size(im)~=1)+1); elseif (any(size(filt)==1)) filt = filt(:); res = corrDn(im,filt,'reflect1',[2 1]); res = corrDn(res,filt','reflect1',[1 2]); else res = corrDn(im,filt,'reflect1',[2 2]); end else res = im; end
github
jacksky64/imageProcessing-master
reconSpyrLevs.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/reconSpyrLevs.m
1,126
utf_8
1f10e3cea5d79a4f4a30d979f3bb1298
% RES = reconSpyrLevs(PYR,INDICES,LOFILT,BFILTS,EDGES,LEVS,BANDS) % % Recursive function for reconstructing levels of a steerable pyramid % representation. This is called by reconSpyr, and is not usually % called directly. % Eero Simoncelli, 6/96. function res = reconSpyrLevs(pyr,pind,lofilt,bfilts,edges,levs,bands); nbands = size(bfilts,2); lo_ind = nbands+1; res_sz = pind(1,:); % Assume square filters: bfiltsz = round(sqrt(size(bfilts,1))); if any(levs > 1) if (size(pind,1) > lo_ind) nres = reconSpyrLevs( pyr(1+sum(prod(pind(1:lo_ind-1,:)')):size(pyr,1)), ... pind(lo_ind:size(pind,1),:), ... lofilt, bfilts, edges, levs-1, bands); else nres = pyrBand(pyr,pind,lo_ind); % lowpass subband end res = upConv(nres, lofilt, edges, [2 2], [1 1], res_sz); else res = zeros(res_sz); end if any(levs == 1) ind = 1; for b = 1:nbands if any(bands == b) bfilt = reshape(bfilts(:,b), bfiltsz, bfiltsz); res = upConv(reshape(pyr(ind:ind+prod(res_sz)-1), res_sz(1), res_sz(2)), ... bfilt, edges, [1 1], [1 1], res_sz, res); end ind = ind + prod(res_sz); end end
github
jacksky64/imageProcessing-master
mkSine.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/mkSine.m
1,725
utf_8
35c6d83f70860ab6defcbdcf7366d89e
% IM = mkSine(SIZE, PERIOD, DIRECTION, AMPLITUDE, PHASE, ORIGIN) % or % IM = mkSine(SIZE, FREQ, AMPLITUDE, PHASE, ORIGIN) % % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) % containing samples of a 2D sinusoid, with given PERIOD (in pixels), % DIRECTION (radians, CW from X-axis, default = 0), AMPLITUDE (default % = 1), and PHASE (radians, relative to ORIGIN, default = 0). ORIGIN % defaults to the center of the image. % % In the second form, FREQ is a 2-vector of frequencies (radians/pixel). % Eero Simoncelli, 6/96. function [res] = mkSine(sz, per_freq, dir_amp, amp_phase, phase_orig, orig) %------------------------------------------------------------ %% OPTIONAL ARGS: if (prod(size(per_freq)) == 2) frequency = norm(per_freq); direction = atan2(per_freq(1),per_freq(2)); if (exist('dir_amp') == 1) amplitude = dir_amp; else amplitude = 1; end if (exist('amp_phase') == 1) phase = amp_phase; else phase = 0; end if (exist('phase_orig') == 1) origin = phase_orig; end if (exist('orig') == 1) error('Too many arguments for (second form) of mkSine'); end else frequency = 2*pi/per_freq; if (exist('dir_amp') == 1) direction = dir_amp; else direction = 0; end if (exist('amp_phase') == 1) amplitude = amp_phase; else amplitude = 1; end if (exist('phase_orig') == 1) phase = phase_orig; else phase = 0; end if (exist('orig') == 1) origin = orig; end end %------------------------------------------------------------ if (exist('origin') == 1) res = amplitude*sin(mkRamp(sz, direction, frequency, phase, origin)); else res = amplitude*sin(mkRamp(sz, direction, frequency, phase)); end
github
jacksky64/imageProcessing-master
buildSFpyrLevs.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/buildSFpyrLevs.m
1,891
utf_8
52ab858761411b2a5a75e7de641259cf
% [PYR, INDICES] = buildSFpyrLevs(LODFT, LOGRAD, XRCOS, YRCOS, ANGLE, HEIGHT, NBANDS) % % Recursive function for constructing levels of a steerable pyramid. This % is called by buildSFpyr, and is not usually called directly. % Eero Simoncelli, 5/97. function [pyr,pind] = buildSFpyrLevs(lodft,log_rad,Xrcos,Yrcos,angle,ht,nbands); if (ht <= 0) lo0 = ifft2(ifftshift(lodft)); pyr = real(lo0(:)); pind = size(lo0); else bands = zeros(prod(size(lodft)), nbands); bind = zeros(nbands,2); % log_rad = log_rad + 1; Xrcos = Xrcos - log2(2); % shift origin of lut by 1 octave. lutsize = 1024; Xcosn = pi*[-(2*lutsize+1):(lutsize+1)]/lutsize; % [-2*pi:pi] order = nbands-1; %% divide by sqrt(sum_(n=0)^(N-1) cos(pi*n/N)^(2(N-1)) ) %% Thanks to Patrick Teo for writing this out :) const = (2^(2*order))*(factorial(order)^2)/(nbands*factorial(2*order)); Ycosn = sqrt(const) * (cos(Xcosn)).^order; himask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); for b = 1:nbands anglemask = pointOp(angle, Ycosn, Xcosn(1)+pi*(b-1)/nbands, Xcosn(2)-Xcosn(1)); banddft = ((-sqrt(-1))^order) .* lodft .* anglemask .* himask; band = ifft2(ifftshift(banddft)); bands(:,b) = real(band(:)); bind(b,:) = size(band); end dims = size(lodft); ctr = ceil((dims+0.5)/2); lodims = ceil((dims-0.5)/2); loctr = ceil((lodims+0.5)/2); lostart = ctr-loctr+1; loend = lostart+lodims-1; log_rad = log_rad(lostart(1):loend(1),lostart(2):loend(2)); angle = angle(lostart(1):loend(1),lostart(2):loend(2)); lodft = lodft(lostart(1):loend(1),lostart(2):loend(2)); YIrcos = abs(sqrt(1.0 - Yrcos.^2)); lomask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); lodft = lomask .* lodft; [npyr,nind] = buildSFpyrLevs(lodft, log_rad, Xrcos, Yrcos, angle, ht-1, nbands); pyr = [bands(:); npyr]; pind = [bind; nind]; end
github
jacksky64/imageProcessing-master
pixelAxes.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/pixelAxes.m
1,983
utf_8
1b2a2bfddd425fee2ccd276f3948cec7
% [ZOOM] = pixelAxes(DIMS, ZOOM) % % Set the axes of the current plot to cover a multiple of DIMS pixels, % thereby eliminating screen aliasing artifacts when displaying an % image of size DIMS. % % ZOOM (optional, default='same') expresses the desired number of % samples displayed per screen pixel. It should be a scalar, which % will be rounded to the nearest integer, or 1 over an integer. It % may also be the string 'same' or 'auto', in which case the value is chosen so % as to produce an image closest in size to the currently displayed % image. It may also be the string 'full', in which case the image is % made as large as possible while still fitting in the window. % Eero Simoncelli, 2/97. function [zoom] = pixelAxes(dims, zoom) %------------------------------------------------------------ %% OPTIONAL ARGS: if (exist('zoom') ~= 1) zoom = 'same'; end %% Reverse dimension order, since Figure Positions reported as (x,y). dims = dims(2:-1:1); %% Use MatLab's axis function to force square pixels, etc: axis('image'); ax = gca; oldunits = get(ax,'Units'); if strcmp(zoom,'full'); set(ax,'Units','normalized'); set(ax,'Position',[0 0 1 1]); zoom = 'same'; end set(ax,'Units','pixels'); pos = get(ax,'Position'); ctr = pos(1:2)+pos(3:4)/2; if (strcmp(zoom,'same') | strcmp(zoom,'auto')) %% HACK: enlarge slightly so that floor doesn't round down zoom = min( pos(3:4) ./ (dims - 1) ); elseif isstr(zoom) error(sprintf('Bad ZOOM argument: %s',zoom)); end %% Force zoom value to be an integer, or inverse integer. if (zoom < 0.75) zoom = 1/ceil(1/zoom); %% Round upward, subtracting 0.5 to avoid floating point errors. newsz = ceil(zoom*(dims-0.5)); else zoom = floor(zoom + 0.001); % Avoid floating pt errors if (zoom < 1.5) % zoom=1 zoom = 1; newsz = dims + 0.5; else newsz = zoom*(dims-1) + mod(zoom,2); end end set(ax,'Position', [floor(ctr-newsz/2)+0.5, newsz] ) % Restore units set(ax,'Units',oldunits);
github
jacksky64/imageProcessing-master
pyrBandIndices.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/pyrBandIndices.m
589
utf_8
28f90484526c294bdb24bdbf8014012d
% RES = pyrBandIndices(INDICES, BAND_NUM) % % Return indices for accessing a subband from a pyramid % (gaussian, laplacian, QMF/wavelet, steerable). % Eero Simoncelli, 6/96. function indices = pyrBandIndices(pind,band) if ((band > size(pind,1)) | (band < 1)) error(sprintf('BAND_NUM must be between 1 and number of pyramid bands (%d).', ... size(pind,1))); end if (size(pind,2) ~= 2) error('INDICES must be an Nx2 matrix indicating the size of the pyramid subbands'); end ind = 1; for l=1:band-1 ind = ind + prod(pind(l,:)); end indices = ind:ind+prod(pind(band,:))-1;
github
jacksky64/imageProcessing-master
pointOp.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/pointOp.m
1,207
utf_8
f3b4f566bebca0b7f56477785bb89fc5
% RES = pointOp(IM, LUT, ORIGIN, INCREMENT, WARNINGS) % % Apply a point operation, specified by lookup table LUT, to image IM. % LUT must be a row or column vector, and is assumed to contain % (equi-spaced) samples of the function. ORIGIN specifies the % abscissa associated with the first sample, and INCREMENT specifies the % spacing between samples. Between-sample values are estimated via % linear interpolation. If WARNINGS is non-zero, the function prints % a warning whenever the lookup table is extrapolated. % % This function is much faster than MatLab's interp1, and allows % extrapolation beyond the lookup table domain. The drawbacks are % that the lookup table must be equi-spaced, and the interpolation is % linear. % Eero Simoncelli, 8/96. function res = pointOp(im, lut, origin, increment, warnings) %% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD) fprintf(1,'WARNING: You should compile the MEX version of "pointOp.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n'); X = origin + increment*[0:size(lut(:),1)-1]; Y = lut(:); res = reshape(interp1(X, Y, im(:), 'linear', 'extrap'),size(im));
github
jacksky64/imageProcessing-master
reconWpyr.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/reconWpyr.m
3,992
utf_8
859a606f214bce204ce3c9ea18c0fc87
% RES = reconWpyr(PYR, INDICES, FILT, EDGES, LEVS, BANDS) % % Reconstruct image from its separable orthonormal QMF/wavelet pyramid % representation, as created by buildWpyr. % % PYR is a vector containing the N pyramid subbands, ordered from fine % to coarse. INDICES is an Nx2 matrix containing the sizes of % each subband. This is compatible with the MatLab Wavelet toolbox. % % FILT (optional) can be a string naming a standard filter (see % namedFilter), or a vector which will be used for (separable) % convolution. Default = 'qmf9'. EDGES specifies edge-handling, % and defaults to 'reflect1' (see corrDn). % % LEVS (optional) should be a vector of levels to include, or the string % 'all' (default). 1 corresponds to the finest scale. The lowpass band % corresponds to wpyrHt(INDICES)+1. % % BANDS (optional) should be a vector of bands to include, or the string % 'all' (default). 1=horizontal, 2=vertical, 3=diagonal. This is only used % for pyramids of 2D images. % Eero Simoncelli, 6/96. function res = reconWpyr(pyr, ind, filt, edges, levs, bands) if (nargin < 2) error('First two arguments (PYR INDICES) are required'); end %%------------------------------------------------------------ %% OPTIONAL ARGS: if (exist('filt') ~= 1) filt = 'qmf9'; end if (exist('edges') ~= 1) edges= 'reflect1'; end if (exist('levs') ~= 1) levs = 'all'; end if (exist('bands') ~= 1) bands = 'all'; end %%------------------------------------------------------------ maxLev = 1+wpyrHt(ind); if strcmp(levs,'all') levs = [1:maxLev]'; else if (any(levs > maxLev)) error(sprintf('Level numbers must be in the range [1, %d].', maxLev)); end levs = levs(:); end if strcmp(bands,'all') bands = [1:3]'; else if (any(bands < 1) | any(bands > 3)) error('Band numbers must be in the range [1,3].'); end bands = bands(:); end if isstr(filt) filt = namedFilter(filt); end filt = filt(:); hfilt = modulateFlip(filt); %% For odd-length filters, stagger the sampling lattices: if (mod(size(filt,1),2) == 0) stag = 2; else stag = 1; end %% Compute size of result image: assumes critical sampling (boundaries correct) res_sz = ind(1,:); if (res_sz(1) == 1) loind = 2; res_sz(2) = sum(ind(:,2)); elseif (res_sz(2) == 1) loind = 2; res_sz(1) = sum(ind(:,1)); else loind = 4; res_sz = ind(1,:) + ind(2,:); %%horizontal + vertical bands. hres_sz = [ind(1,1), res_sz(2)]; lres_sz = [ind(2,1), res_sz(2)]; end %% First, recursively collapse coarser scales: if any(levs > 1) if (size(ind,1) > loind) nres = reconWpyr( pyr(1+sum(prod(ind(1:loind-1,:)')):size(pyr,1)), ... ind(loind:size(ind,1),:), filt, edges, levs-1, bands); else nres = pyrBand(pyr, ind, loind); % lowpass subband end if (res_sz(1) == 1) res = upConv(nres, filt', edges, [1 2], [1 stag], res_sz); elseif (res_sz(2) == 1) res = upConv(nres, filt, edges, [2 1], [stag 1], res_sz); else ires = upConv(nres, filt', edges, [1 2], [1 stag], lres_sz); res = upConv(ires, filt, edges, [2 1], [stag 1], res_sz); end else res = zeros(res_sz); end %% Add in reconstructed bands from this level: if any(levs == 1) if (res_sz(1) == 1) upConv(pyrBand(pyr,ind,1), hfilt', edges, [1 2], [1 2], res_sz, res); elseif (res_sz(2) == 1) upConv(pyrBand(pyr,ind,1), hfilt, edges, [2 1], [2 1], res_sz, res); else if any(bands == 1) % horizontal ires = upConv(pyrBand(pyr,ind,1),filt',edges,[1 2],[1 stag],hres_sz); upConv(ires,hfilt,edges,[2 1],[2 1],res_sz,res); %destructively modify res end if any(bands == 2) % vertical ires = upConv(pyrBand(pyr,ind,2),hfilt',edges,[1 2],[1 2],lres_sz); upConv(ires,filt,edges,[2 1],[stag 1],res_sz,res); %destructively modify res end if any(bands == 3) % diagonal ires = upConv(pyrBand(pyr,ind,3),hfilt',edges,[1 2],[1 2],hres_sz); upConv(ires,hfilt,edges,[2 1],[2 1],res_sz,res); %destructively modify res end end end
github
jacksky64/imageProcessing-master
showWpyr.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/showWpyr.m
5,491
utf_8
4bc0b260425f553810ae04afced17fda
% RANGE = showWpyr (PYR, INDICES, RANGE, GAP, LEVEL_SCALE_FACTOR) % % Display a separable QMF/wavelet pyramid, specified by PYR and INDICES % (see buildWpyr), in the current figure. % % RANGE is a 2-vector specifying the values that map to black and % white, respectively. These values are scaled by % LEVEL_SCALE_FACTOR^(lev-1) for bands at each level. Passing a value % of 'auto1' sets RANGE to the min and max values of MATRIX. 'auto2' % sets RANGE to 3 standard deviations below and above 0.0. In both of % these cases, the lowpass band is independently scaled. A value of % 'indep1' sets the range of each subband independently, as in a call % to showIm(subband,'auto1'). Similarly, 'indep2' causes each subband % to be scaled independently as if by showIm(subband,'indep2'). % The default value for RANGE is 'auto1' for 1D images, and 'auto2' for % 2D images. % % GAP (optional, default=1) specifies the gap in pixels to leave % between subbands (2D images only). % % LEVEL_SCALE_FACTOR indicates the relative scaling between pyramid % levels. This should be set to the sum of the kernel taps of the % lowpass filter used to construct the pyramid (default assumes % L2-normalized filters, using a value of 2 for 2D images, sqrt(2) for % 1D images). % Eero Simoncelli, 2/97. function [range] = showWpyr(pyr, pind, range, gap, scale); % Determine 1D or 2D pyramid: if ((pind(1,1) == 1) | (pind(1,2) ==1)) nbands = 1; else nbands = 3; end %------------------------------------------------------------ %% OPTIONAL ARGS: if (exist('range') ~= 1) if (nbands==1) range = 'auto1'; else range = 'auto2'; end end if (exist('gap') ~= 1) gap = 1; end if (exist('scale') ~= 1) if (nbands == 1) scale = sqrt(2); else scale = 2; end end %------------------------------------------------------------ ht = wpyrHt(pind); nind = size(pind,1); %% Auto range calculations: if strcmp(range,'auto1') range = zeros(nind,1); mn = 0.0; mx = 0.0; for lnum = 1:ht for bnum = 1:nbands band = wpyrBand(pyr,pind,lnum,bnum)/(scale^(lnum-1)); range((lnum-1)*nbands+bnum) = scale^(lnum-1); [bmn,bmx] = range2(band); mn = min(mn, bmn); mx = max(mx, bmx); end end if (nbands == 1) pad = (mx-mn)/12; % *** MAGIC NUMBER!! mn = mn-pad; mx = mx+pad; end range = range * [mn mx]; % outer product band = pyrLow(pyr,pind); [mn,mx] = range2(band); if (nbands == 1) pad = (mx-mn)/12; % *** MAGIC NUMBER!! mn = mn-pad; mx = mx+pad; end range(nind,:) = [mn, mx]; elseif strcmp(range,'indep1') range = zeros(nind,2); for bnum = 1:nind band = pyrBand(pyr,pind,bnum); [mn,mx] = range2(band); if (nbands == 1) pad = (mx-mn)/12; % *** MAGIC NUMBER!! mn = mn-pad; mx = mx+pad; end range(bnum,:) = [mn mx]; end elseif strcmp(range,'auto2') range = zeros(nind,1); sqsum = 0; numpixels = 0; for lnum = 1:ht for bnum = 1:nbands band = wpyrBand(pyr,pind,lnum,bnum)/(scale^(lnum-1)); sqsum = sqsum + sum(sum(band.^2)); numpixels = numpixels + prod(size(band)); range((lnum-1)*nbands+bnum) = scale^(lnum-1); end end stdev = sqrt(sqsum/(numpixels-1)); range = range * [ -3*stdev 3*stdev ]; % outer product band = pyrLow(pyr,pind); av = mean2(band); stdev = sqrt(var2(band)); range(nind,:) = [av-2*stdev,av+2*stdev]; elseif strcmp(range,'indep2') range = zeros(nind,2); for bnum = 1:(nind-1) band = pyrBand(pyr,pind,bnum); stdev = sqrt(var2(band)); range(bnum,:) = [ -3*stdev 3*stdev ]; end band = pyrLow(pyr,pind); av = mean2(band); stdev = sqrt(var2(band)); range(nind,:) = [av-2*stdev,av+2*stdev]; elseif isstr(range) error(sprintf('Bad RANGE argument: %s',range)) elseif ((size(range,1) == 1) & (size(range,2) == 2)) scales = scale.^[0:ht]; if (nbands ~= 1) scales = [scales; scales; scales]; end range = scales(:) * range; % outer product band = pyrLow(pyr,pind); range(nind,:) = range(nind,:) + mean2(band) - mean(range(nind,:)); end % CLEAR FIGURE: clf; if (nbands == 1) %%%%% 1D signal: for bnum=1:nind band = pyrBand(pyr,pind,bnum); subplot(nind,1,nind-bnum+1); plot(band); axis([1, prod(size(band)), range(bnum,:)]); end else %%%%% 2D signal: colormap(gray); cmap = get(gcf,'Colormap'); nshades = size(cmap,1); % Find background color index: clr = get(gcf,'Color'); bg = 1; dist = norm(cmap(bg,:)-clr); for n = 1:nshades ndist = norm(cmap(n,:)-clr); if (ndist < dist) dist = ndist; bg = n; end end %% Compute positions of subbands: llpos = ones(nind,2); for lnum = 1:ht ind1 = nbands*(lnum-1) + 1; xpos = pind(ind1,2) + 1 + gap*(ht-lnum+1); ypos = pind(ind1+1,1) + 1 + gap*(ht-lnum+1); llpos(ind1:ind1+2,:) = [ypos 1; 1 xpos; ypos xpos]; end llpos(nind,:) = [1 1]; %lowpass %% Make position list positive, and allocate appropriate image: llpos = llpos - ones(nind,1)*min(llpos) + 1; urpos = llpos + pind - 1; d_im = bg + zeros(max(urpos)); %% Paste bands into image, (im-r1)*(nshades-1)/(r2-r1) + 1.5 for bnum=1:nind mult = (nshades-1) / (range(bnum,2)-range(bnum,1)); d_im(llpos(bnum,1):urpos(bnum,1), llpos(bnum,2):urpos(bnum,2)) = ... mult*pyrBand(pyr,pind,bnum) + (1.5-mult*range(bnum,1)); end hh = image(d_im); axis('off'); pixelAxes(size(d_im),'full'); set(hh,'UserData',range); end
github
jacksky64/imageProcessing-master
imGradient.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/imGradient.m
1,547
utf_8
b13a85bea09c3f4e0c1e6140c9a31f7a
% [dx, dy] = imGradient(im, edges) % % Compute the gradient of the image using smooth derivative filters % optimized for accurate direction estimation. Coordinate system % corresponds to standard pixel indexing: X axis points rightward. Y % axis points downward. EDGES specify boundary handling (see corrDn % for options). % % Unlike matlab's new gradient function, which is based on local % differences, this function computes derivatives using 5x5 filters % designed to accurately reflect the local orientation content. % EPS, 1997. % original filters from Int'l Conf Image Processing, 1994. % updated filters 10/2003: see Farid & Simoncelli, IEEE Trans Image Processing, 13(4):496-508, April 2004. % Incorporated into matlabPyrTools 10/2004. function [dx, dy] = imGradient(im, edges) if (exist('edges') ~= 1) edges = 'dont-compute'; end %% kernels from Farid & Simoncelli, IEEE Trans Image Processing, 13(4):496-508, April 2004. gp = [0.037659 0.249153 0.426375 0.249153 0.037659]'; gd = [-0.109604 -0.276691 0.000000 0.276691 0.109604]'; dx = corrDn(corrDn(im, gp, edges), gd', edges); dy = corrDn(corrDn(im, gd, edges), gp', edges); return %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% TEST: %%Make a ramp with random slope and direction dir = 2*pi*rand - pi; slope = 10*rand; sz = 32 im = mkRamp(sz, dir, slope); [dx,dy] = imGradient(im); showIm(dx + sqrt(-1)*dy); ctr = (sz*sz/2)+sz/2; slopeEst = sqrt(dx(ctr).^2 + dy(ctr).^2); dirEst = atan2(dy(ctr), dx(ctr)); [slope, slopeEst] [dir, dirEst]
github
jacksky64/imageProcessing-master
lpyrHt.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/lpyrHt.m
233
utf_8
dd0b45926abda2b3fe9aaec0a4f4d214
% [HEIGHT] = lpyrHt(INDICES) % % Compute height of Laplacian pyramid with given its INDICES matrix. % See buildLpyr.m % Eero Simoncelli, 6/96. function [ht] = lpyrHt(pind) % Don't count lowpass residual band ht = size(pind,1)-1;
github
jacksky64/imageProcessing-master
buildGpyr.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/buildGpyr.m
1,931
utf_8
3f1cfe5507fe34b51d71a87d955abbf5
% [PYR, INDICES] = buildGpyr(IM, HEIGHT, FILT, EDGES) % % Construct a Gaussian pyramid on matrix IM. % % HEIGHT (optional) specifies the number of pyramid levels to build. Default % is 1+maxPyrHt(size(IM),size(FILT)). % You can also specify 'auto' to use this value. % % FILT (optional) can be a string naming a standard filter (see % namedFilter), or a vector which will be used for (separable) % convolution. Default = 'binom5'. EDGES specifies edge-handling, and % defaults to 'reflect1' (see corrDn). % % PYR is a vector containing the N pyramid subbands, ordered from fine % to coarse. INDICES is an Nx2 matrix containing the sizes of % each subband. This is compatible with the MatLab Wavelet toolbox. % Eero Simoncelli, 6/96. function [pyr,pind] = buildGpyr(im, ht, filt, edges) if (nargin < 1) error('First argument (IM) is required'); end im_sz = size(im); %------------------------------------------------------------ %% OPTIONAL ARGS: if (exist('filt') ~= 1) filt = 'binom5'; end if isstr(filt) filt = namedFilter(filt); end if ( (size(filt,1) > 1) & (size(filt,2) > 1) ) error('FILT should be a 1D filter (i.e., a vector)'); else filt = filt(:); end max_ht = 1 + maxPyrHt(im_sz, size(filt,1)); if ( (exist('ht') ~= 1) | (ht == 'auto') ) ht = max_ht; else if (ht > max_ht) error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); end end if (exist('edges') ~= 1) edges= 'reflect1'; end %------------------------------------------------------------ if (ht <= 1) pyr = im(:); pind = im_sz; else if (im_sz(2) == 1) lo2 = corrDn(im, filt, edges, [2 1], [1 1]); elseif (im_sz(1) == 1) lo2 = corrDn(im, filt', edges, [1 2], [1 1]); else lo = corrDn(im, filt', edges, [1 2], [1 1]); lo2 = corrDn(lo, filt, edges, [2 1], [1 1]); end [npyr,nind] = buildGpyr(lo2, ht-1, filt, edges); pyr = [im(:); npyr]; pind = [im_sz; nind]; end
github
jacksky64/imageProcessing-master
shift.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/shift.m
438
utf_8
2ac42b171e4ca683ef1d361eaf331870
% [RES] = shift(MTX, OFFSET) % % Circular shift 2D matrix samples by OFFSET (a [Y,X] 2-vector), % such that RES(POS) = MTX(POS-OFFSET). function res = shift(mtx, offset) dims = size(mtx); offset = mod(-offset,dims); res = [ mtx(offset(1)+1:dims(1), offset(2)+1:dims(2)), ... mtx(offset(1)+1:dims(1), 1:offset(2)); ... mtx(1:offset(1), offset(2)+1:dims(2)), ... mtx(1:offset(1), 1:offset(2)) ];
github
jacksky64/imageProcessing-master
namedFilter.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/namedFilter.m
3,207
utf_8
8f45ef65fca60f53e0f734c4f1ae01bf
% KERNEL = NAMED_FILTER(NAME) % % Some standard 1D filter kernels. These are scaled such that % their L2-norm is 1.0. % % binomN - binomial coefficient filter of order N-1 % haar: - Haar wavelet. % qmf8, qmf12, qmf16 - Symmetric Quadrature Mirror Filters [Johnston80] % daub2,daub3,daub4 - Daubechies wavelet [Daubechies88]. % qmf5, qmf9, qmf13: - Symmetric Quadrature Mirror Filters [Simoncelli88,Simoncelli90] % % See bottom of file for full citations. % Eero Simoncelli, 6/96. function [kernel] = named_filter(name) if strcmp(name(1:min(5,size(name,2))), 'binom') kernel = sqrt(2) * binomialFilter(str2num(name(6:size(name,2)))); elseif strcmp(name,'qmf5') kernel = [-0.076103 0.3535534 0.8593118 0.3535534 -0.076103]'; elseif strcmp(name,'qmf9') kernel = [0.02807382 -0.060944743 -0.073386624 0.41472545 0.7973934 ... 0.41472545 -0.073386624 -0.060944743 0.02807382]'; elseif strcmp(name,'qmf13') kernel = [-0.014556438 0.021651438 0.039045125 -0.09800052 ... -0.057827797 0.42995453 0.7737113 0.42995453 -0.057827797 ... -0.09800052 0.039045125 0.021651438 -0.014556438]'; elseif strcmp(name,'qmf8') kernel = sqrt(2) * [0.00938715 -0.07065183 0.06942827 0.4899808 ... 0.4899808 0.06942827 -0.07065183 0.00938715 ]'; elseif strcmp(name,'qmf12') kernel = sqrt(2) * [-0.003809699 0.01885659 -0.002710326 -0.08469594 ... 0.08846992 0.4843894 0.4843894 0.08846992 -0.08469594 -0.002710326 ... 0.01885659 -0.003809699 ]'; elseif strcmp(name,'qmf16') kernel = sqrt(2) * [0.001050167 -0.005054526 -0.002589756 0.0276414 -0.009666376 ... -0.09039223 0.09779817 0.4810284 0.4810284 0.09779817 -0.09039223 -0.009666376 ... 0.0276414 -0.002589756 -0.005054526 0.001050167 ]'; elseif strcmp(name,'haar') kernel = [1 1]' / sqrt(2); elseif strcmp(name,'daub2') kernel = [0.482962913145 0.836516303738 0.224143868042 -0.129409522551]'; elseif strcmp(name,'daub3') kernel = [0.332670552950 0.806891509311 0.459877502118 -0.135011020010 ... -0.085441273882 0.035226291882]'; elseif strcmp(name,'daub4') kernel = [0.230377813309 0.714846570553 0.630880767930 -0.027983769417 ... -0.187034811719 0.030841381836 0.032883011667 -0.010597401785]'; elseif strcmp(name,'gauss5') % for backward-compatibility kernel = sqrt(2) * [0.0625 0.25 0.375 0.25 0.0625]'; elseif strcmp(name,'gauss3') % for backward-compatibility kernel = sqrt(2) * [0.25 0.5 0.25]'; else error(sprintf('Bad filter name: %s\n',name)); end % [Johnston80] - J D Johnston, "A filter family designed for use in quadrature % mirror filter banks", Proc. ICASSP, pp 291-294, 1980. % % [Daubechies88] - I Daubechies, "Orthonormal bases of compactly supported wavelets", % Commun. Pure Appl. Math, vol. 42, pp 909-996, 1988. % % [Simoncelli88] - E P Simoncelli, "Orthogonal sub-band image transforms", % PhD Thesis, MIT Dept. of Elec. Eng. and Comp. Sci. May 1988. % Also available as: MIT Media Laboratory Vision and Modeling Technical % Report #100. % % [Simoncelli90] - E P Simoncelli and E H Adelson, "Subband image coding", % Subband Transforms, chapter 4, ed. John W Woods, Kluwer Academic % Publishers, Norwell, MA, 1990, pp 143--192.
github
jacksky64/imageProcessing-master
buildLpyr.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/buildLpyr.m
2,632
utf_8
b62aad457634fd598b373448741860cd
% [PYR, INDICES] = buildLpyr(IM, HEIGHT, FILT1, FILT2, EDGES) % % Construct a Laplacian pyramid on matrix (or vector) IM. % % HEIGHT (optional) specifies the number of pyramid levels to build. Default % is 1+maxPyrHt(size(IM),size(FILT)). You can also specify 'auto' to % use this value. % % FILT1 (optional) can be a string naming a standard filter (see % namedFilter), or a vector which will be used for (separable) % convolution. Default = 'binom5'. FILT2 specifies the "expansion" % filter (default = filt1). EDGES specifies edge-handling, and % defaults to 'reflect1' (see corrDn). % % PYR is a vector containing the N pyramid subbands, ordered from fine % to coarse. INDICES is an Nx2 matrix containing the sizes of % each subband. This is compatible with the MatLab Wavelet toolbox. % Eero Simoncelli, 6/96. function [pyr,pind] = buildLpyr(im, ht, filt1, filt2, edges) if (nargin < 1) error('First argument (IM) is required'); end im_sz = size(im); %------------------------------------------------------------ %% OPTIONAL ARGS: if (exist('filt1') ~= 1) filt1 = 'binom5'; end if isstr(filt1) filt1 = namedFilter(filt1); end if ( (size(filt1,1) > 1) & (size(filt1,2) > 1) ) error('FILT1 should be a 1D filter (i.e., a vector)'); else filt1 = filt1(:); end if (exist('filt2') ~= 1) filt2 = filt1; end if isstr(filt2) filt2 = namedFilter(filt2); end if ( (size(filt2,1) > 1) & (size(filt2,2) > 1) ) error('FILT2 should be a 1D filter (i.e., a vector)'); else filt2 = filt2(:); end max_ht = 1 + maxPyrHt(im_sz, max(size(filt1,1), size(filt2,1))); if ( (exist('ht') ~= 1) | (ht == 'auto') ) ht = max_ht; else if (ht > max_ht) error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); end end if (exist('edges') ~= 1) edges= 'reflect1'; end %------------------------------------------------------------ if (ht <= 1) pyr = im(:); pind = im_sz; else if (im_sz(2) == 1) lo2 = corrDn(im, filt1, edges, [2 1], [1 1]); elseif (im_sz(1) == 1) lo2 = corrDn(im, filt1', edges, [1 2], [1 1]); else lo = corrDn(im, filt1', edges, [1 2], [1 1]); int_sz = size(lo); lo2 = corrDn(lo, filt1, edges, [2 1], [1 1]); end [npyr,nind] = buildLpyr(lo2, ht-1, filt1, filt2, edges); if (im_sz(1) == 1) hi2 = upConv(lo2, filt2', edges, [1 2], [1 1], im_sz); elseif (im_sz(2) == 1) hi2 = upConv(lo2, filt2, edges, [2 1], [1 1], im_sz); else hi = upConv(lo2, filt2, edges, [2 1], [1 1], int_sz); hi2 = upConv(hi, filt2', edges, [1 2], [1 1], im_sz); end hi2 = im - hi2; pyr = [hi2(:); npyr]; pind = [im_sz; nind]; end
github
jacksky64/imageProcessing-master
mkAngle.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/mkAngle.m
788
utf_8
126297224256c6e9077dc58f4094c39a
% IM = mkAngle(SIZE, PHASE, ORIGIN) % % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) % containing samples of the polar angle (in radians, CW from the % X-axis, ranging from -pi to pi), relative to angle PHASE (default = % 0), about ORIGIN pixel (default = (size+1)/2). % Eero Simoncelli, 6/96. function [res] = mkAngle(sz, phase, origin) sz = sz(:); if (size(sz,1) == 1) sz = [sz,sz]; end % ----------------------------------------------------------------- % OPTIONAL args: if (exist('origin') ~= 1) origin = (sz+1)/2; end % ----------------------------------------------------------------- [xramp,yramp] = meshgrid( [1:sz(2)]-origin(2), [1:sz(1)]-origin(1) ); res = atan2(yramp,xramp); if (exist('phase') == 1) res = mod(res+(pi-phase),2*pi)-pi; end
github
jacksky64/imageProcessing-master
wpyrHt.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/wpyrHt.m
270
utf_8
18e1a724afee99389db70484333eb05a
% [HEIGHT] = wpyrHt(INDICES) % % Compute height of separable QMF/wavelet pyramid with given index matrix. % Eero Simoncelli, 6/96. function [ht] = wpyrHt(pind) if ((pind(1,1) == 1) | (pind(1,2) ==1)) nbands = 1; else nbands = 3; end ht = (size(pind,1)-1)/nbands;
github
jacksky64/imageProcessing-master
sp0Filters.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/sp0Filters.m
6,140
utf_8
0c5cd7bafff21efacd2a8ec71af90f49
% Steerable pyramid filters. Transform described in: % % @INPROCEEDINGS{Simoncelli95b, % TITLE = "The Steerable Pyramid: A Flexible Architecture for % Multi-Scale Derivative Computation", % AUTHOR = "E P Simoncelli and W T Freeman", % BOOKTITLE = "Second Int'l Conf on Image Processing", % ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } % % Filter kernel design described in: % %@INPROCEEDINGS{Karasaridis96, % TITLE = "A Filter Design Technique for % Steerable Pyramid Image Transforms", % AUTHOR = "A Karasaridis and E P Simoncelli", % BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", % MONTH = "May", YEAR = 1996 } % Eero Simoncelli, 6/96. function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp0Filters(); harmonics = [ 0 ]; lo0filt = [ ... -4.514000e-04 -1.137100e-04 -3.725800e-04 -3.743860e-03 -3.725800e-04 -1.137100e-04 -4.514000e-04 -1.137100e-04 -6.119520e-03 -1.344160e-02 -7.563200e-03 -1.344160e-02 -6.119520e-03 -1.137100e-04 -3.725800e-04 -1.344160e-02 6.441488e-02 1.524935e-01 6.441488e-02 -1.344160e-02 -3.725800e-04 -3.743860e-03 -7.563200e-03 1.524935e-01 3.153017e-01 1.524935e-01 -7.563200e-03 -3.743860e-03 -3.725800e-04 -1.344160e-02 6.441488e-02 1.524935e-01 6.441488e-02 -1.344160e-02 -3.725800e-04 -1.137100e-04 -6.119520e-03 -1.344160e-02 -7.563200e-03 -1.344160e-02 -6.119520e-03 -1.137100e-04 -4.514000e-04 -1.137100e-04 -3.725800e-04 -3.743860e-03 -3.725800e-04 -1.137100e-04 -4.514000e-04]; lofilt = [ ... -2.257000e-04 -8.064400e-04 -5.686000e-05 8.741400e-04 -1.862800e-04 -1.031640e-03 -1.871920e-03 -1.031640e-03 -1.862800e-04 8.741400e-04 -5.686000e-05 -8.064400e-04 -2.257000e-04 -8.064400e-04 1.417620e-03 -1.903800e-04 -2.449060e-03 -4.596420e-03 -7.006740e-03 -6.948900e-03 -7.006740e-03 -4.596420e-03 -2.449060e-03 -1.903800e-04 1.417620e-03 -8.064400e-04 -5.686000e-05 -1.903800e-04 -3.059760e-03 -6.401000e-03 -6.720800e-03 -5.236180e-03 -3.781600e-03 -5.236180e-03 -6.720800e-03 -6.401000e-03 -3.059760e-03 -1.903800e-04 -5.686000e-05 8.741400e-04 -2.449060e-03 -6.401000e-03 -5.260020e-03 3.938620e-03 1.722078e-02 2.449600e-02 1.722078e-02 3.938620e-03 -5.260020e-03 -6.401000e-03 -2.449060e-03 8.741400e-04 -1.862800e-04 -4.596420e-03 -6.720800e-03 3.938620e-03 3.220744e-02 6.306262e-02 7.624674e-02 6.306262e-02 3.220744e-02 3.938620e-03 -6.720800e-03 -4.596420e-03 -1.862800e-04 -1.031640e-03 -7.006740e-03 -5.236180e-03 1.722078e-02 6.306262e-02 1.116388e-01 1.348999e-01 1.116388e-01 6.306262e-02 1.722078e-02 -5.236180e-03 -7.006740e-03 -1.031640e-03 -1.871920e-03 -6.948900e-03 -3.781600e-03 2.449600e-02 7.624674e-02 1.348999e-01 1.576508e-01 1.348999e-01 7.624674e-02 2.449600e-02 -3.781600e-03 -6.948900e-03 -1.871920e-03 -1.031640e-03 -7.006740e-03 -5.236180e-03 1.722078e-02 6.306262e-02 1.116388e-01 1.348999e-01 1.116388e-01 6.306262e-02 1.722078e-02 -5.236180e-03 -7.006740e-03 -1.031640e-03 -1.862800e-04 -4.596420e-03 -6.720800e-03 3.938620e-03 3.220744e-02 6.306262e-02 7.624674e-02 6.306262e-02 3.220744e-02 3.938620e-03 -6.720800e-03 -4.596420e-03 -1.862800e-04 8.741400e-04 -2.449060e-03 -6.401000e-03 -5.260020e-03 3.938620e-03 1.722078e-02 2.449600e-02 1.722078e-02 3.938620e-03 -5.260020e-03 -6.401000e-03 -2.449060e-03 8.741400e-04 -5.686000e-05 -1.903800e-04 -3.059760e-03 -6.401000e-03 -6.720800e-03 -5.236180e-03 -3.781600e-03 -5.236180e-03 -6.720800e-03 -6.401000e-03 -3.059760e-03 -1.903800e-04 -5.686000e-05 -8.064400e-04 1.417620e-03 -1.903800e-04 -2.449060e-03 -4.596420e-03 -7.006740e-03 -6.948900e-03 -7.006740e-03 -4.596420e-03 -2.449060e-03 -1.903800e-04 1.417620e-03 -8.064400e-04 -2.257000e-04 -8.064400e-04 -5.686000e-05 8.741400e-04 -1.862800e-04 -1.031640e-03 -1.871920e-03 -1.031640e-03 -1.862800e-04 8.741400e-04 -5.686000e-05 -8.064400e-04 -2.257000e-04]; mtx = [ 1.000000 ]; hi0filt = [... 5.997200e-04 -6.068000e-05 -3.324900e-04 -3.325600e-04 -2.406600e-04 -3.325600e-04 -3.324900e-04 -6.068000e-05 5.997200e-04 -6.068000e-05 1.263100e-04 4.927100e-04 1.459700e-04 -3.732100e-04 1.459700e-04 4.927100e-04 1.263100e-04 -6.068000e-05 -3.324900e-04 4.927100e-04 -1.616650e-03 -1.437358e-02 -2.420138e-02 -1.437358e-02 -1.616650e-03 4.927100e-04 -3.324900e-04 -3.325600e-04 1.459700e-04 -1.437358e-02 -6.300923e-02 -9.623594e-02 -6.300923e-02 -1.437358e-02 1.459700e-04 -3.325600e-04 -2.406600e-04 -3.732100e-04 -2.420138e-02 -9.623594e-02 8.554893e-01 -9.623594e-02 -2.420138e-02 -3.732100e-04 -2.406600e-04 -3.325600e-04 1.459700e-04 -1.437358e-02 -6.300923e-02 -9.623594e-02 -6.300923e-02 -1.437358e-02 1.459700e-04 -3.325600e-04 -3.324900e-04 4.927100e-04 -1.616650e-03 -1.437358e-02 -2.420138e-02 -1.437358e-02 -1.616650e-03 4.927100e-04 -3.324900e-04 -6.068000e-05 1.263100e-04 4.927100e-04 1.459700e-04 -3.732100e-04 1.459700e-04 4.927100e-04 1.263100e-04 -6.068000e-05 5.997200e-04 -6.068000e-05 -3.324900e-04 -3.325600e-04 -2.406600e-04 -3.325600e-04 -3.324900e-04 -6.068000e-05 5.997200e-04 ]; bfilts = [ ... -9.066000e-05 -1.738640e-03 -4.942500e-03 -7.889390e-03 -1.009473e-02 -7.889390e-03 -4.942500e-03 -1.738640e-03 -9.066000e-05 ... -1.738640e-03 -4.625150e-03 -7.272540e-03 -7.623410e-03 -9.091950e-03 -7.623410e-03 -7.272540e-03 -4.625150e-03 -1.738640e-03 ... -4.942500e-03 -7.272540e-03 -2.129540e-02 -2.435662e-02 -3.487008e-02 -2.435662e-02 -2.129540e-02 -7.272540e-03 -4.942500e-03 ... -7.889390e-03 -7.623410e-03 -2.435662e-02 -1.730466e-02 -3.158605e-02 -1.730466e-02 -2.435662e-02 -7.623410e-03 -7.889390e-03 ... -1.009473e-02 -9.091950e-03 -3.487008e-02 -3.158605e-02 9.464195e-01 -3.158605e-02 -3.487008e-02 -9.091950e-03 -1.009473e-02 ... -7.889390e-03 -7.623410e-03 -2.435662e-02 -1.730466e-02 -3.158605e-02 -1.730466e-02 -2.435662e-02 -7.623410e-03 -7.889390e-03 ... -4.942500e-03 -7.272540e-03 -2.129540e-02 -2.435662e-02 -3.487008e-02 -2.435662e-02 -2.129540e-02 -7.272540e-03 -4.942500e-03 ... -1.738640e-03 -4.625150e-03 -7.272540e-03 -7.623410e-03 -9.091950e-03 -7.623410e-03 -7.272540e-03 -4.625150e-03 -1.738640e-03 ... -9.066000e-05 -1.738640e-03 -4.942500e-03 -7.889390e-03 -1.009473e-02 -7.889390e-03 -4.942500e-03 -1.738640e-03 -9.066000e-05 ]';
github
jacksky64/imageProcessing-master
sp5Filters.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/sp5Filters.m
6,949
utf_8
305fb0c0ca0709fc34ca6c5b4bb91712
% Steerable pyramid filters. Transform described in: % % @INPROCEEDINGS{Simoncelli95b, % TITLE = "The Steerable Pyramid: A Flexible Architecture for % Multi-Scale Derivative Computation", % AUTHOR = "E P Simoncelli and W T Freeman", % BOOKTITLE = "Second Int'l Conf on Image Processing", % ADDRESS = "Washington, DC", MONTH = "October", YEAR = 1995 } % % Filter kernel design described in: % %@INPROCEEDINGS{Karasaridis96, % TITLE = "A Filter Design Technique for % Steerable Pyramid Image Transforms", % AUTHOR = "A Karasaridis and E P Simoncelli", % BOOKTITLE = "ICASSP", ADDRESS = "Atlanta, GA", % MONTH = "May", YEAR = 1996 } % Eero Simoncelli, 6/96. function [lo0filt,hi0filt,lofilt,bfilts,mtx,harmonics] = sp5Filters(); harmonics = [1 3 5]; mtx = [ ... 0.3333 0.2887 0.1667 0.0000 -0.1667 -0.2887 0.0000 0.1667 0.2887 0.3333 0.2887 0.1667 0.3333 -0.0000 -0.3333 -0.0000 0.3333 -0.0000 0.0000 0.3333 0.0000 -0.3333 0.0000 0.3333 0.3333 -0.2887 0.1667 -0.0000 -0.1667 0.2887 -0.0000 0.1667 -0.2887 0.3333 -0.2887 0.1667]; hi0filt = [ -0.00033429 -0.00113093 -0.00171484 -0.00133542 -0.00080639 -0.00133542 -0.00171484 -0.00113093 -0.00033429 -0.00113093 -0.00350017 -0.00243812 0.00631653 0.01261227 0.00631653 -0.00243812 -0.00350017 -0.00113093 -0.00171484 -0.00243812 -0.00290081 -0.00673482 -0.00981051 -0.00673482 -0.00290081 -0.00243812 -0.00171484 -0.00133542 0.00631653 -0.00673482 -0.07027679 -0.11435863 -0.07027679 -0.00673482 0.00631653 -0.00133542 -0.00080639 0.01261227 -0.00981051 -0.11435863 0.81380200 -0.11435863 -0.00981051 0.01261227 -0.00080639 -0.00133542 0.00631653 -0.00673482 -0.07027679 -0.11435863 -0.07027679 -0.00673482 0.00631653 -0.00133542 -0.00171484 -0.00243812 -0.00290081 -0.00673482 -0.00981051 -0.00673482 -0.00290081 -0.00243812 -0.00171484 -0.00113093 -0.00350017 -0.00243812 0.00631653 0.01261227 0.00631653 -0.00243812 -0.00350017 -0.00113093 -0.00033429 -0.00113093 -0.00171484 -0.00133542 -0.00080639 -0.00133542 -0.00171484 -0.00113093 -0.00033429]; lo0filt = [ 0.00341614 -0.01551246 -0.03848215 -0.01551246 0.00341614 -0.01551246 0.05586982 0.15925570 0.05586982 -0.01551246 -0.03848215 0.15925570 0.40304148 0.15925570 -0.03848215 -0.01551246 0.05586982 0.15925570 0.05586982 -0.01551246 0.00341614 -0.01551246 -0.03848215 -0.01551246 0.00341614]; lofilt = 2*[ 0.00085404 -0.00244917 -0.00387812 -0.00944432 -0.00962054 -0.00944432 -0.00387812 -0.00244917 0.00085404 -0.00244917 -0.00523281 -0.00661117 0.00410600 0.01002988 0.00410600 -0.00661117 -0.00523281 -0.00244917 -0.00387812 -0.00661117 0.01396746 0.03277038 0.03981393 0.03277038 0.01396746 -0.00661117 -0.00387812 -0.00944432 0.00410600 0.03277038 0.06426333 0.08169618 0.06426333 0.03277038 0.00410600 -0.00944432 -0.00962054 0.01002988 0.03981393 0.08169618 0.10096540 0.08169618 0.03981393 0.01002988 -0.00962054 -0.00944432 0.00410600 0.03277038 0.06426333 0.08169618 0.06426333 0.03277038 0.00410600 -0.00944432 -0.00387812 -0.00661117 0.01396746 0.03277038 0.03981393 0.03277038 0.01396746 -0.00661117 -0.00387812 -0.00244917 -0.00523281 -0.00661117 0.00410600 0.01002988 0.00410600 -0.00661117 -0.00523281 -0.00244917 0.00085404 -0.00244917 -0.00387812 -0.00944432 -0.00962054 -0.00944432 -0.00387812 -0.00244917 0.00085404]; bfilts = [... 0.00277643 0.00496194 0.01026699 0.01455399 0.01026699 0.00496194 0.00277643 ... -0.00986904 -0.00893064 0.01189859 0.02755155 0.01189859 -0.00893064 -0.00986904 ... -0.01021852 -0.03075356 -0.08226445 -0.11732297 -0.08226445 -0.03075356 -0.01021852 ... 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 ... 0.01021852 0.03075356 0.08226445 0.11732297 0.08226445 0.03075356 0.01021852 ... 0.00986904 0.00893064 -0.01189859 -0.02755155 -0.01189859 0.00893064 0.00986904 ... -0.00277643 -0.00496194 -0.01026699 -0.01455399 -0.01026699 -0.00496194 -0.00277643; ... -0.00343249 -0.00640815 -0.00073141 0.01124321 0.00182078 0.00285723 0.01166982 ... -0.00358461 -0.01977507 -0.04084211 -0.00228219 0.03930573 0.01161195 0.00128000 ... 0.01047717 0.01486305 -0.04819057 -0.12227230 -0.05394139 0.00853965 -0.00459034 ... 0.00790407 0.04435647 0.09454202 -0.00000000 -0.09454202 -0.04435647 -0.00790407 ... 0.00459034 -0.00853965 0.05394139 0.12227230 0.04819057 -0.01486305 -0.01047717 ... -0.00128000 -0.01161195 -0.03930573 0.00228219 0.04084211 0.01977507 0.00358461 ... -0.01166982 -0.00285723 -0.00182078 -0.01124321 0.00073141 0.00640815 0.00343249; ... 0.00343249 0.00358461 -0.01047717 -0.00790407 -0.00459034 0.00128000 0.01166982 ... 0.00640815 0.01977507 -0.01486305 -0.04435647 0.00853965 0.01161195 0.00285723 ... 0.00073141 0.04084211 0.04819057 -0.09454202 -0.05394139 0.03930573 0.00182078 ... -0.01124321 0.00228219 0.12227230 -0.00000000 -0.12227230 -0.00228219 0.01124321 ... -0.00182078 -0.03930573 0.05394139 0.09454202 -0.04819057 -0.04084211 -0.00073141 ... -0.00285723 -0.01161195 -0.00853965 0.04435647 0.01486305 -0.01977507 -0.00640815 ... -0.01166982 -0.00128000 0.00459034 0.00790407 0.01047717 -0.00358461 -0.00343249; ... -0.00277643 0.00986904 0.01021852 -0.00000000 -0.01021852 -0.00986904 0.00277643 ... -0.00496194 0.00893064 0.03075356 -0.00000000 -0.03075356 -0.00893064 0.00496194 ... -0.01026699 -0.01189859 0.08226445 -0.00000000 -0.08226445 0.01189859 0.01026699 ... -0.01455399 -0.02755155 0.11732297 -0.00000000 -0.11732297 0.02755155 0.01455399 ... -0.01026699 -0.01189859 0.08226445 -0.00000000 -0.08226445 0.01189859 0.01026699 ... -0.00496194 0.00893064 0.03075356 -0.00000000 -0.03075356 -0.00893064 0.00496194 ... -0.00277643 0.00986904 0.01021852 -0.00000000 -0.01021852 -0.00986904 0.00277643; ... -0.01166982 -0.00128000 0.00459034 0.00790407 0.01047717 -0.00358461 -0.00343249 ... -0.00285723 -0.01161195 -0.00853965 0.04435647 0.01486305 -0.01977507 -0.00640815 ... -0.00182078 -0.03930573 0.05394139 0.09454202 -0.04819057 -0.04084211 -0.00073141 ... -0.01124321 0.00228219 0.12227230 -0.00000000 -0.12227230 -0.00228219 0.01124321 ... 0.00073141 0.04084211 0.04819057 -0.09454202 -0.05394139 0.03930573 0.00182078 ... 0.00640815 0.01977507 -0.01486305 -0.04435647 0.00853965 0.01161195 0.00285723 ... 0.00343249 0.00358461 -0.01047717 -0.00790407 -0.00459034 0.00128000 0.01166982; ... -0.01166982 -0.00285723 -0.00182078 -0.01124321 0.00073141 0.00640815 0.00343249 ... -0.00128000 -0.01161195 -0.03930573 0.00228219 0.04084211 0.01977507 0.00358461 ... 0.00459034 -0.00853965 0.05394139 0.12227230 0.04819057 -0.01486305 -0.01047717 ... 0.00790407 0.04435647 0.09454202 -0.00000000 -0.09454202 -0.04435647 -0.00790407 ... 0.01047717 0.01486305 -0.04819057 -0.12227230 -0.05394139 0.00853965 -0.00459034 ... -0.00358461 -0.01977507 -0.04084211 -0.00228219 0.03930573 0.01161195 0.00128000 ... -0.00343249 -0.00640815 -0.00073141 0.01124321 0.00182078 0.00285723 0.01166982]';
github
jacksky64/imageProcessing-master
steer.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/steer.m
1,990
utf_8
3db4dd948e0ece7c7237330b7d4f191e
% RES = STEER(BASIS, ANGLE, HARMONICS, STEERMTX) % % Steer BASIS to the specfied ANGLE. % % BASIS should be a matrix whose columns are vectorized rotated copies of a % steerable function, or the responses of a set of steerable filters. % % ANGLE can be a scalar, or a column vector the size of the basis. % % HARMONICS (optional, default is N even or odd low frequencies, as for % derivative filters) should be a list of harmonic numbers indicating % the angular harmonic content of the basis. % % STEERMTX (optional, default assumes cosine phase harmonic components, % and filter positions at 2pi*n/N) should be a matrix which maps % the filters onto Fourier series components (ordered [cos0 cos1 sin1 % cos2 sin2 ... sinN]). See steer2HarmMtx.m % Eero Simoncelli, 7/96. function res = steer(basis,angle,harmonics,steermtx) num = size(basis,2); if ( any(size(angle) ~= [size(basis,1) 1]) & any(size(angle) ~= [1 1]) ) error('ANGLE must be a scalar, or a column vector the size of the basis elements'); end %% If HARMONICS are not passed, assume derivatives. if (exist('harmonics') ~= 1) if (mod(num,2) == 0) harmonics = [0:(num/2)-1]'*2 + 1; else harmonics = [0:(num-1)/2]'*2; end else harmonics = harmonics(:); if ((2*size(harmonics,1)-any(harmonics == 0)) ~= num) error('harmonics list is incompatible with basis size'); end end %% If STEERMTX not passed, assume evenly distributed cosine-phase filters: if (exist('steermtx') ~= 1) steermtx = steer2HarmMtx(harmonics, pi*[0:num-1]/num, 'even'); end steervect = zeros(size(angle,1),num); arg = angle * harmonics(find(harmonics~=0))'; if (all(harmonics)) steervect(:, 1:2:num) = cos(arg); steervect(:, 2:2:num) = sin(arg); else steervect(:, 1) = ones(size(arg,1),1); steervect(:, 2:2:num) = cos(arg); steervect(:, 3:2:num) = sin(arg); end steervect = steervect * steermtx; if (size(steervect,1) > 1) tmp = basis' .* steervect'; res = sum(tmp)'; else res = basis * steervect'; end
github
jacksky64/imageProcessing-master
mkGaussian.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/mkGaussian.m
1,565
utf_8
1f55e73fbc9155a38607b0667da2d7f3
% IM = mkGaussian(SIZE, COVARIANCE, MEAN, AMPLITUDE) % % Compute a matrix with dimensions SIZE (a [Y X] 2-vector, or a % scalar) containing a Gaussian function, centered at pixel position % specified by MEAN (default = (size+1)/2), with given COVARIANCE (can % be a scalar, 2-vector, or 2x2 matrix. Default = (min(size)/6)^2), % and AMPLITUDE. AMPLITUDE='norm' (default) will produce a % probability-normalized function. All but the first argument are % optional. % Eero Simoncelli, 6/96. function [res] = mkGaussian(sz, cov, mn, ampl) sz = sz(:); if (size(sz,1) == 1) sz = [sz,sz]; end %------------------------------------------------------------ %% OPTIONAL ARGS: if (exist('cov') ~= 1) cov = (min(sz(1),sz(2))/6)^2; end if ( (exist('mn') ~= 1) | isempty(mn) ) mn = (sz+1)/2; else mn = mn(:); if (size(mn,1) == 1) mn = [mn, mn]; end end if (exist('ampl') ~= 1) ampl = 'norm'; end %------------------------------------------------------------ [xramp,yramp] = meshgrid([1:sz(2)]-mn(2),[1:sz(1)]-mn(1)); if (sum(size(cov)) == 2) % scalar if (strcmp(ampl,'norm')) ampl = 1/(2*pi*cov(1)); end e = (xramp.^2 + yramp.^2)/(-2 * cov); elseif (sum(size(cov)) == 3) % a 2-vector if (strcmp(ampl,'norm')) ampl = 1/(2*pi*sqrt(cov(1)*cov(2))); end e = xramp.^2/(-2 * cov(2)) + yramp.^2/(-2 * cov(1)); else if (strcmp(ampl,'norm')) ampl = 1/(2*pi*sqrt(det(cov))); end cov = -inv(cov)/2; e = cov(2,2)*xramp.^2 + (cov(1,2)+cov(2,1))*(xramp.*yramp) ... + cov(1,1)*yramp.^2; end res = ampl .* exp(e);
github
jacksky64/imageProcessing-master
factorial.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/factorial.m
273
utf_8
370971eae7a2351704973c452848d194
%% RES = factorial(NUM) % % Factorial function that works on matrices (matlab's does not). % EPS, 11/02 function res = factorial(num) res = ones(size(num)); ind = find(num > 0); if ( ~isempty(ind) ) subNum = num(ind); res(ind) = subNum .* factorial(subNum-1); end
github
jacksky64/imageProcessing-master
entropy2.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/entropy2.m
693
utf_8
c637630f7ac8912e5cb30f67551aece7
% E = ENTROPY2(MTX,BINSIZE) % % Compute the first-order sample entropy of MTX. Samples of VEC are % first discretized. Optional argument BINSIZE controls the % discretization, and defaults to 256/(max(VEC)-min(VEC)). % % NOTE: This is a heavily biased estimate of entropy (it is too % small) when you don't have much data! % Eero Simoncelli, 6/96. function res = entropy2(mtx,binsize) %% Ensure it's a vector, not a matrix. vec = mtx(:); [mn,mx] = range2(vec); if (exist('binsize') == 1) nbins = max((mx-mn)/binsize, 1); else nbins = 256; end [bincount,bins] = histo(vec,nbins); %% Collect non-zero bins: H = bincount(find(bincount)); H = H/sum(H); res = -sum(H .* log2(H));
github
jacksky64/imageProcessing-master
buildSFpyr.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/buildSFpyr.m
3,256
utf_8
84c0a17ac90df74f317c29833c54ffa3
% [PYR, INDICES, STEERMTX, HARMONICS] = buildSFpyr(IM, HEIGHT, ORDER, TWIDTH) % % Construct a steerable pyramid on matrix IM, in the Fourier domain. % This is similar to buildSpyr, except that: % % + Reconstruction is exact (within floating point errors) % + It can produce any number of orientation bands. % - Typically slower, especially for non-power-of-two sizes. % - Boundary-handling is circular. % % HEIGHT (optional) specifies the number of pyramid levels to build. Default % is maxPyrHt(size(IM),size(FILT)); % % The squared radial functions tile the Fourier plane, with a raised-cosine % falloff. Angular functions are cos(theta-k\pi/(K+1))^K, where K is % the ORDER (one less than the number of orientation bands, default= 3). % % TWIDTH is the width of the transition region of the radial lowpass % function, in octaves (default = 1, which gives a raised cosine for % the bandpass filters). % % PYR is a vector containing the N pyramid subbands, ordered from fine % to coarse. INDICES is an Nx2 matrix containing the sizes of % each subband. This is compatible with the MatLab Wavelet toolbox. % See the function STEER for a description of STEERMTX and HARMONICS. % Eero Simoncelli, 5/97. % See http://www.cns.nyu.edu/~eero/STEERPYR/ for more % information about the Steerable Pyramid image decomposition. function [pyr,pind,steermtx,harmonics] = buildSFpyr(im, ht, order, twidth) %----------------------------------------------------------------- %% DEFAULTS: max_ht = floor(log2(min(size(im)))) - 2; if (exist('ht') ~= 1) ht = max_ht; else if (ht > max_ht) error(sprintf('Cannot build pyramid higher than %d levels.',max_ht)); end end if (exist('order') ~= 1) order = 3; elseif ((order > 15) | (order < 0)) fprintf(1,'Warning: ORDER must be an integer in the range [0,15]. Truncating.\n'); order = min(max(order,0),15); else order = round(order); end nbands = order+1; if (exist('twidth') ~= 1) twidth = 1; elseif (twidth <= 0) fprintf(1,'Warning: TWIDTH must be positive. Setting to 1.\n'); twidth = 1; end %----------------------------------------------------------------- %% Steering stuff: if (mod((nbands),2) == 0) harmonics = [0:(nbands/2)-1]'*2 + 1; else harmonics = [0:(nbands-1)/2]'*2; end steermtx = steer2HarmMtx(harmonics, pi*[0:nbands-1]/nbands, 'even'); %----------------------------------------------------------------- dims = size(im); ctr = ceil((dims+0.5)/2); [xramp,yramp] = meshgrid( ([1:dims(2)]-ctr(2))./(dims(2)/2), ... ([1:dims(1)]-ctr(1))./(dims(1)/2) ); angle = atan2(yramp,xramp); log_rad = sqrt(xramp.^2 + yramp.^2); log_rad(ctr(1),ctr(2)) = log_rad(ctr(1),ctr(2)-1); log_rad = log2(log_rad); %% Radial transition function (a raised cosine in log-frequency): [Xrcos,Yrcos] = rcosFn(twidth,(-twidth/2),[0 1]); Yrcos = sqrt(Yrcos); YIrcos = sqrt(1.0 - Yrcos.^2); lo0mask = pointOp(log_rad, YIrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); imdft = fftshift(fft2(im)); lo0dft = imdft .* lo0mask; [pyr,pind] = buildSFpyrLevs(lo0dft, log_rad, Xrcos, Yrcos, angle, ht, nbands); hi0mask = pointOp(log_rad, Yrcos, Xrcos(1), Xrcos(2)-Xrcos(1), 0); hi0dft = imdft .* hi0mask; hi0 = ifft2(ifftshift(hi0dft)); pyr = [real(hi0(:)) ; pyr]; pind = [size(hi0); pind];
github
jacksky64/imageProcessing-master
spyrLev.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/spyrLev.m
668
utf_8
8d25ccc2790a62ab21a20cc3d0772706
% [LEV,IND] = spyrLev(PYR,INDICES,LEVEL) % % Access a level from a steerable pyramid. % Return as an SxB matrix, B = number of bands, S = total size of a band. % Also returns an Bx2 matrix containing dimensions of the subbands. % Eero Simoncelli, 6/96. function [lev,ind] = spyrLev(pyr,pind,level) nbands = spyrNumBands(pind); if ((level > spyrHt(pind)) | (level < 1)) error(sprintf('Level number must be in the range [1, %d].', spyrHt(pind))); end firstband = 2 + nbands*(level-1); firstind = 1; for l=1:firstband-1 firstind = firstind + prod(pind(l,:)); end ind = pind(firstband:firstband+nbands-1,:); lev = pyr(firstind:firstind+sum(prod(ind'))-1);
github
jacksky64/imageProcessing-master
pgmWrite.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/pgmWrite.m
3,119
utf_8
6425008296069df51c5c30ee1c011850
% RANGE = pgmWrite(MTX, FILENAME, RANGE, TYPE, COMMENT) % % Write a MatLab matrix to a pgm (graylevel image) file. % This format is accessible from the XV image browsing utility. % % RANGE (optional) is a 2-vector specifying the values that map to % black and white, respectively. Passing a value of 'auto' (default) % sets RANGE=[min,max] (as in MatLab's imagesc). 'auto2' sets % RANGE=[mean-2*stdev, mean+2*stdev]. 'auto3' sets % RANGE=[p1-(p2-p1)/8, p2+(p2-p1)/8], where p1 is the 10th percentile % value of the sorted MATRIX samples, and p2 is the 90th percentile % value. % % TYPE (optional) should be 'raw' or 'ascii'. Defaults to 'raw'. % Hany Farid, Spring '96. Modified by Eero Simoncelli, 6/96. function range = pgmWrite(mtx, fname, range, type, comment ); [fid,msg] = fopen( fname, 'w' ); if (fid == -1) error(msg); end %------------------------------------------------------------ %% optional ARGS: if (exist('range') ~= 1) range = 'auto'; end if (exist('type') ~= 1) type = 'raw'; end %------------------------------------------------------------ %% Automatic range calculation: if (strcmp(range,'auto1') | strcmp(range,'auto')) [mn,mx] = range2(mtx); range = [mn,mx]; elseif strcmp(range,'auto2') stdev = sqrt(var2(mtx)); av = mean2(mtx); range = [av-2*stdev,av+2*stdev]; % MAGIC NUMBER: 2 stdevs elseif strcmp(range, 'auto3') percentile = 0.1; % MAGIC NUMBER: 0<p<0.5 [N,X] = histo(mtx); binsz = X(2)-X(1); N = N+1e-10; % Ensure cumsum will be monotonic for call to interp1 cumN = [0, cumsum(N)]/sum(N); cumX = [X(1)-binsz, X] + (binsz/2); ctrRange = interp1(cumN,cumX, [percentile, 1-percentile]); range = mean(ctrRange) + (ctrRange-mean(ctrRange))/(1-2*percentile); elseif isstr(range) error(sprintf('Bad RANGE argument: %s',range)) end if ((range(2) - range(1)) <= eps) range(1) = range(1) - 0.5; range(2) = range(2) + 0.5; end %%% First line contains ID string: %%% "P1" = ascii bitmap, "P2" = ascii greymap, %%% "P3" = ascii pixmap, "P4" = raw bitmap, %%% "P5" = raw greymap, "P6" = raw pixmap if strcmp(type,'raw') fprintf(fid,'P5\n'); format = 5; elseif strcmp(type,'ascii') fprintf(fid,'P2\n'); format = 2; else error(sprintf('PGMWRITE: Bad type argument: %s',type)); end fprintf(fid,'# MatLab PGMWRITE file, saved %s\n',date); if (exist('comment') == 1) fprintf(fid,'# %s\n', comment); end %%% dimensions fprintf(fid,'%d %d\n',size(mtx,2),size(mtx,1)); %%% Maximum pixel value fprintf(fid,'255\n'); %% MatLab's "fprintf" floors when writing floats, so we compute %% (mtx-r1)*255/(r2-r1)+0.5 mult = (255 / (range(2)-range(1))); mtx = (mult * mtx) + (0.5 - mult * range(1)); mtx = max(-0.5+eps,min(255.5-eps,mtx)); if (format == 2) count = fprintf(fid,'%d ',mtx'); elseif (format == 5) count = fwrite(fid,mtx','uchar'); end fclose(fid); if (count ~= size(mtx,1)*size(mtx,2)) fprintf(1,'Warning: File output terminated early!'); end %%% TEST: % foo = 257*rand(100)-1; % pgmWrite(foo,'foo.pgm',[0 255]); % foo2=pgmRead('foo.pgm'); % size(find((foo2-round(foo))~=0)) % foo(find((foo2-round(foo))~=0))
github
jacksky64/imageProcessing-master
modulateFlip.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/modulateFlip.m
461
utf_8
92f12f8068fcf49b9863851f106a5aa3
% [HFILT] = modulateFlipShift(LFILT) % % QMF/Wavelet highpass filter construction: modulate by (-1)^n, % reverse order (and shift by one, which is handled by the convolution % routines). This is an extension of the original definition of QMF's % (e.g., see Simoncelli90). % Eero Simoncelli, 7/96. function [hfilt] = modulateFlipShift(lfilt) lfilt = lfilt(:); sz = size(lfilt,1); sz2 = ceil(sz/2); ind = [sz:-1:1]'; hfilt = lfilt(ind) .* (-1).^(ind-sz2);
github
jacksky64/imageProcessing-master
mkFract.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/mkFract.m
843
utf_8
f0d97e35133978ade3a5fe34dea5d08a
% IM = mkFract(SIZE, FRACT_DIM) % % Make a matrix of dimensions SIZE (a [Y X] 2-vector, or a scalar) % containing fractal (pink) noise with power spectral density of the % form: 1/f^(5-2*FRACT_DIM). Image variance is normalized to 1.0. % FRACT_DIM defaults to 1.0 % Eero Simoncelli, 6/96. %% TODO: Verify that this matches Mandelbrot defn of fractal dimension. %% Make this more efficient! function res = mkFract(dims, fract_dim) if (exist('fract_dim') ~= 1) fract_dim = 1.0; end res = randn(dims); fres = fft2(res); sz = size(res); ctr = ceil((sz+1)./2); shape = ifftshift(mkR(sz, -(2.5-fract_dim), ctr)); shape(1,1) = 1; %%DC term fres = shape .* fres; fres = ifft2(fres); if (max(max(abs(imag(fres)))) > 1e-10) error('Symmetry error in creating fractal'); else res = real(fres); res = res / sqrt(var2(res)); end
github
jacksky64/imageProcessing-master
mkSquare.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/mkSquare.m
2,344
utf_8
7d9553e391552cd91cdd6d81348404e2
% IM = mkSquare(SIZE, PERIOD, DIRECTION, AMPLITUDE, PHASE, ORIGIN, TWIDTH) % or % IM = mkSine(SIZE, FREQ, AMPLITUDE, PHASE, ORIGIN, TWIDTH) % % Compute a matrix of dimension SIZE (a [Y X] 2-vector, or a scalar) % containing samples of a 2D square wave, with given PERIOD (in % pixels), DIRECTION (radians, CW from X-axis, default = 0), AMPLITUDE % (default = 1), and PHASE (radians, relative to ORIGIN, default = 0). % ORIGIN defaults to the center of the image. TWIDTH specifies width % of raised-cosine edges on the bars of the grating (default = % min(2,period/3)). % % In the second form, FREQ is a 2-vector of frequencies (radians/pixel). % Eero Simoncelli, 6/96. % TODO: Add duty cycle. function [res] = mkSquare(sz, per_freq, dir_amp, amp_phase, phase_orig, orig_twidth, twidth) %------------------------------------------------------------ %% OPTIONAL ARGS: if (prod(size(per_freq)) == 2) frequency = norm(per_freq); direction = atan2(per_freq(1),per_freq(2)); if (exist('dir_amp') == 1) amplitude = dir_amp; else amplitude = 1; end if (exist('amp_phase') == 1) phase = amp_phase; else phase = 0; end if (exist('phase_orig') == 1) origin = phase_orig; end if (exist('orig_twidth') == 1) transition = orig_twidth; else transition = min(2,2*pi/(3*frequency)); end if (exist('twidth') == 1) error('Too many arguments for (second form) of mkSine'); end else frequency = 2*pi/per_freq; if (exist('dir_amp') == 1) direction = dir_amp; else direction = 0; end if (exist('amp_phase') == 1) amplitude = amp_phase; else amplitude = 1; end if (exist('phase_orig') == 1) phase = phase_orig; else phase = 0; end if (exist('orig_twidth') == 1) origin = orig_twidth; end if (exist('twidth') == 1) transition = twidth; else transition = min(2,2*pi/(3*frequency)); end end %------------------------------------------------------------ if (exist('origin') == 1) res = mkRamp(sz, direction, frequency, phase, origin) - pi/2; else res = mkRamp(sz, direction, frequency, phase) - pi/2; end [Xtbl,Ytbl] = rcosFn(transition*frequency,pi/2,[-amplitude amplitude]); res = pointOp(abs(mod(res+pi, 2*pi)-pi),Ytbl,Xtbl(1),Xtbl(2)-Xtbl(1),0); % OLD threshold version: %res = amplitude * (mod(res,2*pi) < pi);
github
jacksky64/imageProcessing-master
spyrNumBands.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/spyrNumBands.m
480
utf_8
4a10cb68438c7dfc197ec00066f48fd4
% [NBANDS] = spyrNumBands(INDICES) % % Compute number of orientation bands in a steerable pyramid with % given index matrix. If the pyramid contains only the highpass and % lowpass bands (i.e., zero levels), returns 0. % Eero Simoncelli, 2/97. function [nbands] = spyrNumBands(pind) if (size(pind,1) == 2) nbands = 0; else % Count number of orientation bands: b = 3; while ((b <= size(pind,1)) & all( pind(b,:) == pind(2,:)) ) b = b+1; end nbands = b-2; end
github
jacksky64/imageProcessing-master
reconSpyr.m
.m
imageProcessing-master/Matlab imaging/matlabPyrTools/reconSpyr.m
2,671
utf_8
ea9e71a5f8a76eadbe8c1a2472d89344
% RES = reconSpyr(PYR, INDICES, FILTFILE, EDGES, LEVS, BANDS) % % Reconstruct image from its steerable pyramid representation, as created % by buildSpyr. % % PYR is a vector containing the N pyramid subbands, ordered from fine % to coarse. INDICES is an Nx2 matrix containing the sizes of % each subband. This is compatible with the MatLab Wavelet toolbox. % % FILTFILE (optional) should be a string referring to an m-file that returns % the rfilters. examples: sp0Filters, sp1Filters, sp3Filters % (default = 'sp1Filters'). % EDGES specifies edge-handling, and defaults to 'reflect1' (see % corrDn). % % LEVS (optional) should be a list of levels to include, or the string % 'all' (default). 0 corresonds to the residual highpass subband. % 1 corresponds to the finest oriented scale. The lowpass band % corresponds to number spyrHt(INDICES)+1. % % BANDS (optional) should be a list of bands to include, or the string % 'all' (default). 1 = vertical, rest proceeding anti-clockwise. % Eero Simoncelli, 6/96. function res = reconSpyr(pyr, pind, filtfile, edges, levs, bands) %%------------------------------------------------------------ %% DEFAULTS: if (exist('filtfile') ~= 1) filtfile = 'sp1Filters'; end if (exist('edges') ~= 1) edges= 'reflect1'; end if (exist('levs') ~= 1) levs = 'all'; end if (exist('bands') ~= 1) bands = 'all'; end %%------------------------------------------------------------ if (isstr(filtfile) & (exist(filtfile) == 2)) [lo0filt,hi0filt,lofilt,bfilts,steermtx,harmonics] = eval(filtfile); nbands = spyrNumBands(pind); if ((nbands > 0) & (size(bfilts,2) ~= nbands)) error('Number of pyramid bands is inconsistent with filter file'); end else error('filtfile argument must be the name of an M-file containing SPYR filters.'); end maxLev = 1+spyrHt(pind); if strcmp(levs,'all') levs = [0:maxLev]'; else if (any(levs > maxLev) | any(levs < 0)) error(sprintf('Level numbers must be in the range [0, %d].', maxLev)); end levs = levs(:); end if strcmp(bands,'all') bands = [1:nbands]'; else if (any(bands < 1) | any(bands > nbands)) error(sprintf('Band numbers must be in the range [1,3].', nbands)); end bands = bands(:); end if (spyrHt(pind) == 0) if (any(levs==1)) res1 = pyrBand(pyr,pind,2); else res1 = zeros(pind(2,:)); end else res1 = reconSpyrLevs(pyr(1+prod(pind(1,:)):size(pyr,1)), ... pind(2:size(pind,1),:), ... lofilt, bfilts, edges, levs, bands); end res = upConv(res1, lo0filt, edges); %% residual highpass subband if any(levs == 0) res = upConv( subMtx(pyr, pind(1,:)), hi0filt, edges, [1 1], [1 1], size(res), res); end
github
jacksky64/imageProcessing-master
PSMF.m
.m
imageProcessing-master/Matlab imaging/Nonlinear Image filter Matlab/Total variation/PSMF.m
1,729
utf_8
475d67192dff5927c8e02dd0c73206fe
%% Implementation of Progressive Switching Median Filter %% Base Paper : Zhou Wang and David Zhang, "Progressive Switching Median %% Filter for the Removal of Impulse Noise from Highly Corrupted Images", %% IEEE Trans. on Cir. and Sys., vol. 46, no. 1, Jan. 1999. %% Function Y = PSMF(x) %% input x = Image is corrupted by Salt & Pepper Noise %% %% Example: Y = PSMF(x); %% Posted date : 16 - 10 - 2008 %% Modified date : %% %% Developed By : K.Kannan ([email protected]) %% & Jeny Rajan ([email protected]) %% Medical Imaging Research Group (MIRG), NeST, %% Trivandrum. %% Progressive Switching Median Filter function Y = PSMF(x) x = double(x); WF = 3; ND = 3;T = 40;a = 65;b = -50; M = medfilt2(x,[3 3]); N = abs(x - M); N(N>T)=0; N = N ~= 0; N = double(N); R = sum(N(:))/(size(x,1) * size(x,2)); if R <= 0.25 WD = 3; else WD = 5; end TD = a + (b * R); z = IMPDET(x,ND,WD,TD); Y = NF(x,z,WF); %% Impulse Detection function F1 = IMPDET(x,ND,WD,TD) X = x; M = medfilt2(X,[WD WD]); D = abs(X - M); F = zeros(size(x)); F(D>=TD)=1; F1 = F; X(F1==F)=X(F1==F); X(F1~=F)=M(F1~=F); for i = 1:ND-1 M = medfilt2(X,[WD WD]); F1(abs(X - M)<TD)=F(abs(X - M)<TD); F1((X - M)>=TD)=1; X(F1==F)=X(F1==F); X(F1~=F)=M(F1~=F); F = F1; end return; %% Noise Filtering function Y = NF(x,f,WF) g = f; Y = x; Y1 = Y; g1 = g; s = sum(g(:)); while s ~= 0 M = medfilt2(Y,[WF WF]); Y1(g==1)=M(g==1); g1(Y~=Y1)=0; Y = Y1; g = g1; s1 = sum(g(:)); if s1 ~= s s = s1; else s = 0; end end return;
github
jacksky64/imageProcessing-master
Hessian3D.m
.m
imageProcessing-master/frangifilter/Hessian3D.m
1,938
utf_8
9204648b80240369948918e5b591d037
function [Dxx, Dyy, Dzz, Dxy, Dxz, Dyz] = Hessian3D(Volume,Sigma) % This function Hessian3D filters the image with an Gaussian kernel % followed by calculation of 2nd order gradients, which aprroximates the % 2nd order derivatives of the image. % % [Dxx, Dyy, Dzz, Dxy, Dxz, Dyz] = Hessian3D(I,Sigma) % % inputs, % I : The image volume, class preferable double or single % Sigma : The sigma of the gaussian kernel used. If sigma is zero % no gaussian filtering. % % outputs, % Dxx, Dyy, Dzz, Dxy, Dxz, Dyz: The 2nd derivatives % % Function is written by D.Kroon University of Twente (June 2009) % defaults if nargin < 2, Sigma = 1; end if(Sigma>0) F=imgaussian(Volume,Sigma); else F=Volume; end % Create first and second order diferentiations Dz=gradient3(F,'z'); Dzz=(gradient3(Dz,'z')); clear Dz; Dy=gradient3(F,'y'); Dyy=(gradient3(Dy,'y')); Dyz=(gradient3(Dy,'z')); clear Dy; Dx=gradient3(F,'x'); Dxx=(gradient3(Dx,'x')); Dxy=(gradient3(Dx,'y')); Dxz=(gradient3(Dx,'z')); clear Dx; function D = gradient3(F,option) % This function does the same as the default matlab "gradient" function % but with one direction at the time, less cpu and less memory usage. % % Example: % % Fx = gradient3(F,'x'); [k,l,m] = size(F); D = zeros(size(F),class(F)); switch lower(option) case 'x' % Take forward differences on left and right edges D(1,:,:) = (F(2,:,:) - F(1,:,:)); D(k,:,:) = (F(k,:,:) - F(k-1,:,:)); % Take centered differences on interior points D(2:k-1,:,:) = (F(3:k,:,:)-F(1:k-2,:,:))/2; case 'y' D(:,1,:) = (F(:,2,:) - F(:,1,:)); D(:,l,:) = (F(:,l,:) - F(:,l-1,:)); D(:,2:l-1,:) = (F(:,3:l,:)-F(:,1:l-2,:))/2; case 'z' D(:,:,1) = (F(:,:,2) - F(:,:,1)); D(:,:,m) = (F(:,:,m) - F(:,:,m-1)); D(:,:,2:m-1) = (F(:,:,3:m)-F(:,:,1:m-2))/2; otherwise disp('Unknown option') end
github
jacksky64/imageProcessing-master
gkdeb.m
.m
imageProcessing-master/gkde/gkdeb.m
4,605
utf_8
9d82eb477f61ff42700f0fa30bf20f71
function p=gkdeb(x,p) % GKDEB Gaussian Kernel Density Estimation with Bounded Support % % Usage: % p = gkdeb(d) returns an estmate of pdf of the given random data d in p, % where p.pdf and p.cdf are the pdf and cdf vectors estimated at % p.x locations, respectively and p.h is the bandwidth used for % the estimation. % p = gkdeb(d,p) specifies optional parameters for the estimation: % p.h - bandwidth % p.x - locations to make estimation % p.uB - upper bound % p.lB - lower bound. % p.alpha - to calculate inverse cdfs at p.alpha locations % % Without output, gkdeb(d) and gkdeb(d,p) will disply the pdf and cdf % (cumulative distribution function) plot. % % See also: hist, histc, ksdensity, ecdf, cdfplot, ecdfhist % Example 1: Normal distribution %{ gkdeb(randn(1e4,1)); %} % Example 2: Uniform distribution %{ clear p p.uB=1; p.lB=0; gkdeb(rand(1e3,1),p); %} % Example 3: Exponential distribution %{ clear p p.lB=0; gkdeb(-log(1-rand(1,1000)),p); %} % Example 4: Rayleigh distribution %{ clear p p.lB=0; gkdeb(sqrt(randn(1,1000).^2 + randn(1,1000).^2),p); %} % V3.2 by Yi Cao at Cranfield University on 7th April 2010 % % Check input and output error(nargchk(1,2,nargin)); error(nargoutchk(0,1,nargout)); n=length(x); % Default parameters if nargin<2 N=100; h=median(abs(x-median(x)))/0.6745*(4/3/n)^0.2; xmax=max(x); xmin=min(x); xmax=xmax+3*h; xmin=xmin-3*h; dx=(xmax-xmin)/(N-1); p.x=xmin+(0:N-1)*dx; p.pdf=zeros(1,N); p.cdf=zeros(1,N); p.h=h; dxdz=ones(size(p.x)); z=p.x; else [p,x,dxdz,z]=checkp(x,p); N=numel(p.x); h=p.h; end % Gaussian kernel function kerf=@(z)exp(-z.*z/2); ckerf=@(z)(1+erf(z/sqrt(2)))/2; nh=n*h*sqrt(2*pi); for k=1:N p.pdf(k)=sum(kerf((p.x(k)-x)/h)); p.cdf(k)=sum(ckerf((p.x(k)-x)/h)); end p.x=z; p.pdf=p.pdf.*dxdz/nh; dx=[0 diff(p.x)]; p.cdf=p.cdf/n; % p.cdf=cumsum(p.pdf.*dx); if isfield(p,'alpha') n=numel(p.alpha); p.icdf=p.alpha; for k=1:n alpha=p.alpha(k); ix=find(p.cdf>alpha,1)-1; x1=p.x(ix); x2=p.x(ix+1); F1=p.cdf(ix); F2=p.cdf(ix+1); p.icdf(k)=x1+(alpha-F1)*(x2-x1)/(F2-F1); end end % Plot if ~nargout subplot(211) plot(p.x,p.pdf,'linewidth',2) grid % set(gca,'ylim',[0 max(p.pdf)*1.1]) ylabel('f(x)') title('Estimated Probability Density Function'); subplot(212) plot(p.x,p.cdf,'linewidth',2) ylabel('F(x)') title('Cumulative Distribution Function') xlabel('x') grid meanx = sum(p.x.*p.pdf.*dx); varx = sum((p.x-meanx).^2.*p.pdf.*dx); text(min(p.x),0.6,sprintf('mean(x) = %g\n var(x) = %g\n',meanx,varx)); if isfield(p,'alpha') && numel(p.alpha)==1 text(min(p.x),0.85,sprintf('icdf at %g = %g',p.alpha,p.icdf)); end end function [p,x,dxdz,z]=checkp(x,p) n=numel(x); %check structure p if ~isstruct(p) error('p is not a structure.'); end if ~isfield(p,'uB') p.uB=Inf; end if ~isfield(p,'lB') p.lB=-Inf; end if p.lB>-Inf || p.uB<Inf [p,x,dxdz,z]=bounded(x,p); else if ~isfield(p,'h') p.h=median(abs(x-median(x)))/0.6745*(4/3/n)^0.2; end error(varchk(eps, inf, p.h, 'Bandwidth, p.h is not positive.')); if ~isfield(p,'x') N=100; xmax=max(x); xmin=min(x); xmax=xmax+3*p.h; xmin=xmin-3*p.h; dx=(xmax-xmin)/(N-1); p.x=xmin+(0:N-1)*dx; end dxdz=ones(N,1); z=p.x; end p.pdf=zeros(size(p.x)); p.cdf=zeros(size(p.x)); function [p,x,dxdz,z]=bounded(x,p) if p.lB==-Inf dx=@(t)1./(p.uB-t); y=@(t)-log(p.uB-t); zf=@(t)(p.uB-exp(-t)); elseif p.uB==Inf dx=@(t)1./(t-p.lB); y=@(t)log(t-p.lB); zf=@(t)exp(t)+p.lB; else dx=@(t)(p.uB-p.lB)./(t-p.lB)./(p.uB-t); y=@(t)log((t-p.lB)./(p.uB-t)); zf=@(t)(exp(t)*p.uB+p.lB)./(exp(t)+1); end x=y(x); n=numel(x); if ~isfield(p,'h') p.h=median(abs(x-median(x)))/0.6745*(4/3/n)^0.2; end h=p.h; if ~isfield(p,'x') N=100; xmax=max(x); xmin=min(x); xmax=xmax+3*h; xmin=xmin-3*h; p.x=xmin+(0:N-1)*(xmax-xmin)/(N-1); z=zf(p.x); else z=p.x; p.x=y(p.x); end dxdz=dx(z); function msg=varchk(low,high,n,msg) % check if variable n is not between low and high, returns msg, otherwise % empty matrix if n>=low && n<=high msg=[]; end
github
jacksky64/imageProcessing-master
filter_function.m
.m
imageProcessing-master/ImageDiffusionFiltering/ImageDenoising/filter_function.m
398
utf_8
503e499f9e7a72b3417c25f62aa6fb32
% CAP 6516 Medical Image Processing Programming Assignment 1 % Author: Ritwik K Kumar, Dept. of CISE, UFL % (c) 2006 Ritwik K Kumar % this function is called by other m files function [smth] = filter_function(image, sigma); % This function smooths the image with a Gaussian filter of width sigma smask = fspecial('gaussian', ceil(3*sigma), sigma); smth = filter2(smask, image, 'same');
github
jacksky64/imageProcessing-master
imagine.m
.m
imageProcessing-master/matlab imagine/imagine_2016/imagine.m
167,700
utf_8
30fbbb9031cf1ff3577fe03ddd20e8ad
function argout = imagine2(varargin) % IMAGINE IMAGe visualization, analysis and evaluation engINE % % IMAGINE starts the IMAGINE user interface without initial data % % IMAGINE(DATA) Starts the IMAGINE user interface with one (DATA is 3D) % or multiple panels (DATA is 4D). % % IMAGINE(DATA, PROPERTY1, VALUE1, ...)) Starts the IMAGINE user % interface with data DATA plus supplying some additional information % about the dataset in the usual property/value pair format. Possible % combinations are: % PROPERTY VALUE % 'Name' String: A name for the dataset % 'Voxelsize' [3x1] or [1x3] double: The voxel size of the first % three dimensions of DATA. % 'Units' String: The physical unit of the pixels (e.g. 'mm') % % IMAGINE(DATA1, DATA2, ...) Starts the IMAGINE user interface with % multiple panels, where each input can be either a 3D- or 4D-array. Each % dataset can be defined more detailedly with the properties above. % % % Examples: % % 1. >> load mri % Gives variable D % >> imagine(squeeze(D)); % squeeze because D is in rgb format % % 2. >> load mri % Gives variable D % >> imagine(squeeze(D), 'Name', 'Head T1', 'Voxelsize', [1 1 2.7]); % This syntax gives a more realistic aspect ration if you rotate the data. % % For more information about the IMAGINE functions refer to the user's % guide file in the documentation folder supplied with the code. % % Copyright 2012-2015 Christian Wuerslin, Stanford University % Contact: [email protected] % ========================================================================= % Warp Zone! (using Cntl + D) % ------------------------------------------------------------------------- % *** The callbacks *** % fCloseGUI % On figure close % fResizeFigure % On figure resize % fIconClick % On clicking menubar or tool icons % fWindowMouseHoverFcn % Standard figure mouse move callback % fWindowButtonDownFcn % Figure mouse button down function % fWindowMouseMoveFcn % Figure mouse move function when button is pressed or ROI drawing active % fWindowButtonUpFcn % Figure mouse button up function: Starts most actions % fKeyPressFcn % Keyboard callback % fContextFcn % Context menu callback % fSetWindow % Callback of the colorbars % % ------------------------------------------------------------------------- % *** IMAGINE Core *** % fFillPanels % fUpdateActivation % fZoom % fWindow % fChangeImage % fEval % % ------------------------------------------------------------------------- % *** Lengthy subfunction *** % fLoadFiles % fParseInputs % fAddImageToData % fSaveToFiles % % ------------------------------------------------------------------------- % *** Helpers *** % fCreatePanels % fGetPanel % fServesSizeCriterion % fIsOn % fGetNActiveVisibleSeries % fGetNVisibleSeries % fGetImg % fGetData % fPrintNumber % fBackgroundImg % fReplicate % % ------------------------------------------------------------------------- % *** GUIS *** % fGridSelect % fColormapSelect % fSelectEvalFcns % ========================================================================= % ========================================================================= % *** FUNCTION imagine % *** % *** Main GUI function. Creates the figure and all its contents and % *** registers the callbacks. % *** % ========================================================================= % ------------------------------------------------------------------------- % Control the figure's appearance SAp.sVERSION = '2.2 - Belly Jeans'; SAp.sTITLE = ['IMAGINE ',SAp.sVERSION];% Title of the figure SAp.iICONSIZE = 24; % Size if the icons SAp.iICONPADDING = SAp.iICONSIZE/2; % Padding between icons SAp.iMENUBARHEIGHT = SAp.iICONSIZE*2; % Height of the menubar (top) SAp.iTOOLBARWIDTH = SAp.iICONSIZE*2; % Width of the toolbar (left) SAp.iTITLEBARHEIGHT = 24; % Height of the titles (above each image) SAp.iCOLORBARHEIGHT = 12; % Height of the colorbar SAp.iCOLORBARPADDING = 60; % The space on the left and right of the colorbar for the min/max values SAp.iEVALBARHEIGHT = 16; % Height of the evaluation bar SAp.iDISABLED_SCALE = 0.3; % Brightness of disabled buttons (decrease to make darker) SAp.iINACTIVE_SCALE = 0.6; % Brightness of inactive buttons (toggle buttons and radio groups) SAp.dBGCOLOR = [0.2 0.3 0.4]; % Color scheme SAp.dEmptyImg = 0; % The background image (is calculated in fResizeFigure); SAp.iCOLORMAPLENGTH = 2.^12; % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Set some paths. SPref.sMFILEPATH = fileparts(mfilename('fullpath')); % This is the path of this m-file SPref.sICONPATH = [SPref.sMFILEPATH, filesep, 'icons', filesep]; % That's where the icons are SPref.sSaveFilename = [SPref.sMFILEPATH, filesep, 'imagineSave.mat']; % A .mat-file to save the GUI settings addpath([SPref.sMFILEPATH, filesep, 'EvalFunctions'], ... [SPref.sMFILEPATH, filesep, 'colormaps'], ... [SPref.sMFILEPATH, filesep, 'import'], ... [SPref.sMFILEPATH, filesep, 'tools']); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Define some preferences S = load('mylines.mat'); SPref.dCOLORMAP = S.mylines;% The color scheme of the overlays and lines SPref.dWINDOWSENSITIVITY = 0.02; % Defines mouse sensitivity for windowing operation SPref.dZOOMSENSITIVITY = 0.02; % Defines mouse sensitivity for zooming operation SPref.dROTATION_THRESHOLD = 50; % Defines the number of pixels the cursor has to move to rotate an image SPref.dLWRADIUS = 200; % The radius in which the path maps are calculated in the livewire algorithm SPref.lGERMANEXPORT = false; % Not a beer! Determines whether the data is exported with a period or a comma as decimal point % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % This is the definition of the menubar. If a radiobutton-like % functionality is to implemented, the GroupIndex parameter of all % icons within the group has to be set to the same positive integer % value. Normal Buttons have group index -1, toggel switches have group % index 0. The toolbar has the GroupIndex 255. SIcons = struct( ... 'Name', {'folder_open', 'doc_import', 'save', 'doc_delete', 'exchange', 'grid', 'colormap', 'link', 'link1', 'reset', 'phase', 'max', 'min', 'record', 'stop', 'rewind', 'clock', 'line1', 'cursor_arrow', 'rotate', 'line', 'roi', 'lw', 'rg', 'ic', 'tag'}, ... 'Spacer', { 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, ... 'GroupIndex', { -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 1, 1, 1, -1, -1, -1, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255}, ... 'Enabled', { 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, ... 'Active', { 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0}, ... 'Accelerator', { 'o', 'i', 's', 'delete', 'x', '', '', 'l', '', '0', '', '', '', 'r', 'r', 'z', 't', 'w', 'm', 'r', 'l', 'o', 'w', 'g', 'i', 'p'}, ... 'Modifier', { 'Cntl', 'Cntl', 'Cntl', '', 'Cntl', '', '', 'Cntl', '', 'Cntl', '', '', '', 'Cntl', 'Alt', 'Cntl', 'Cntl', 'Cntl', '', '', '', '', '', '', '', ''}, ... 'Tooltip', {'Open Files' , 'Import Workspace Variables', 'Save To Files', 'Delete', 'Exchange', 'Change Layout', 'Colormap', 'Link Actions', 'Link Windowing','Reset View', 'Phase Image', 'Maximum Intensity Projection', 'Minimum Intensity Projection', 'Log Evaluation', 'Stop Logging Evaluation', 'Undo Last Evaluation', 'Eval Timeseries', 'Show Line Plots', 'Move/Zoom/Window', 'Rotate', 'Profile Evaluation', 'ROI Evaluation', 'Livewire ROI Evaluation', 'Region Growing Volume Evaluation', 'Isocontour Evaluation', 'Properties'}); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------ % Reset the GUI's state variable SState.iLastSeries = 0; SState.iStartSeries = 1; SState.sTool = 'cursor_arrow'; SState.sPath = [SPref.sMFILEPATH, filesep]; SState.csEvalLineFcns = {}; SState.csEvalROIFcns = {}; SState.csEvalVolFcns = {}; SState.sEvalFilename = []; SState.iROIState = 0; % The ROI state machine SState.dROILineX = []; SState.dROILineY = []; SState.iPanels = [0, 0]; SState.lShowColorbar = true; SState.lShowEvalbar = true; SState.dColormapBack = gray(SAp.iCOLORMAPLENGTH); SState.dColormapMask = S.mylines; SState.dMaskOpacity = 0.3; SState.sDrawMode = 'mag'; SState.dTolerance = 1.0; SState.hEvalFigure = 0.1; % ------------------------------------------------------------------------ % ------------------------------------------------------------------------ % Create some globals SData = []; % A struct for hoding the data (image data + visualization parameters) SImg = []; % A struct for the image component handles SLines = []; % A struct for the line component handles SMouse = []; % A Struct to hold parameters of the mouse operations % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Read the preferences from the save file iPosition = [100 100 1000 600]; if exist(SPref.sSaveFilename, 'file') load(SPref.sSaveFilename); SState.sPath = SSaveVar.sPath; SState.csEvalLineFcns = SSaveVar.csEvalLineFcns; SState.csEvalROIFcns = SSaveVar.csEvalROIFcns; SState.csEvalVolFcns = SSaveVar.csEvalVolFcns; iPosition = SSaveVar.iPosition; SPref.lGERMANEXPORT = SSaveVar.lGermanExport; clear SSaveVar; % <- no one needs you anymore! :(( else % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % First-time call: Do some setup sAns = questdlg('Do you want to use periods (anglo-american) or commas (german) as decimal separator in the exported .csv spreadsheet files? This is important for a smooth Excel import.', 'IMAGINE First-Time Setup', 'Stick to the point', 'Use se commas', 'Stick to the point'); SPref.lGERMANEXPORT = strcmp(sAns, 'Use se commas'); fCompileMex; % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - end % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Make sure the figure fits on the screen iScreenSize = get(0, 'ScreenSize'); if (iPosition(1) + iPosition(3) > iScreenSize(3)) || ... (iPosition(2) + iPosition(4) > iScreenSize(4)) iPosition(1:2) = 50; iPosition(3:4) = iScreenSize(3:4) - 100; end % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Create the figure. Mouse scroll wheel is supported since Version 7.4 (I think). hF = figure(... 'BusyAction' , 'cancel', ... 'Interruptible' , 'off', ... 'Position' , iPosition, ... 'Units' , 'pixels', ... 'Color' , SAp.dBGCOLOR/2, ... 'ResizeFcn' , @fResizeFigure, ... 'DockControls' , 'on', ... 'MenuBar' , 'none', ... 'Name' , SAp.sTITLE, ... 'NumberTitle' , 'off', ... 'KeyPressFcn' , @fKeyPressFcn, ... 'CloseRequestFcn' , @fCloseGUI, ... 'WindowButtonDownFcn' , @fWindowButtonDownFcn, ... 'WindowButtonMotionFcn' , @fWindowMouseHoverFcn, ... 'Visible' , 'off'); try set(hF, 'WindowScrollWheelFcn' , @fChangeImage); catch warning('IMAGINE: No scroll wheel functionality!'); end colormap(gray(256)); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Crate context menu for the region growing hContextMenu = uicontextmenu; uimenu(hContextMenu, 'Label', 'Tolerance +50%', 'Callback', @fContextFcn); uimenu(hContextMenu, 'Label', 'Tolerance +10%', 'Callback', @fContextFcn); uimenu(hContextMenu, 'Label', 'Tolerance -10%', 'Callback', @fContextFcn); uimenu(hContextMenu, 'Label', 'Tolerance -50%', 'Callback', @fContextFcn); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Create the menubar and the toolbar including their components SAxes.hMenu = axes('Parent', hF, 'Color', 'k', 'Units', 'pixels', 'YDir', 'reverse', 'XTick', [], 'YTick', []); SAxes.hTools = axes('Parent', hF, 'Color', 'k', 'Units', 'pixels', 'YDir', 'reverse', 'XTick', [], 'YTick', []); SImg .hIcons = zeros(length(SIcons), 1); iXStart = SAp.iTOOLBARWIDTH - SAp.iICONSIZE; iYStart = SAp.iICONPADDING; for iI = 1:length(SIcons) if SIcons(iI).GroupIndex ~= 255, iXStart = iXStart + SAp.iICONPADDING + SAp.iICONSIZE; end dImage = double(imread([SPref.sICONPATH, SIcons(iI).Name, '.png'])); % icon file name (.png) has to be equal to icon name if size(dImage, 3) == 1, dImage = repmat(dImage, [1 1 3]); end dImage = imresize(dImage, [SAp.iICONSIZE SAp.iICONSIZE]); dImage(dImage < 0) = 0; dImage(dImage > 255) = 255; SIcons(iI).dImg = dImage./255; if SIcons(iI).GroupIndex == 255 hParent = SAxes.hTools; iX = SAp.iICONPADDING; iY = iYStart; else hParent = SAxes.hMenu; iX = iXStart; iY = SAp.iICONPADDING; end SImg.hIcons(iI) = image(... 'CData' , SIcons(iI).dImg, ... 'XData' , iX, ... 'YData' , iY, ... 'Parent' , hParent, ... 'ButtonDownFcn' , @fIconClick); if SIcons(iI).Spacer && SIcons(iI).GroupIndex ~= 255, iXStart = iXStart + SAp.iICONSIZE; end if SIcons(iI).GroupIndex == 255, iYStart = iYStart + SAp.iICONSIZE + SAp.iICONPADDING; end end SState.dIconEnd = iXStart + SAp.iICONPADDING + SAp.iICONSIZE; STexts.hStatus = uicontrol(... % Create the text element 'Style' ,'Text', ... 'FontName' , 'Helvetica Neue', ... 'FontWeight' , 'light', ... 'Parent' , hF, ... 'FontUnits' , 'normalized', ... 'FontSize' , 0.7, ... 'BackgroundColor' , 'k', ... 'ForegroundColor' , 'w', ... 'HorizontalAlignment' , 'right', ... 'Units' , 'pixels'); clear iStartPos hParent iI dImage % ------------------------------------------------------------------------- dLogo = [0 0 0 1 1 0 0 0; ... 0 0 0 1 1 0 0 0; ... 0 0 0 0 0 0 0 0; ... 0 0 1 1 1 0 0 0; ... 0 0 0 1 1 0 0 0; ... 0 0 0 1 1 0 0 0; ... 0 0 1 1 1 1 0 0; ... 0 0 0 0 0 0 0 0;]; % dPattern = max(cat(3, rand(12), padarray(dLogo, [2 2], 0, 'both')), [], 3); dPattern = 0.2*rand(16) + 0.3*padarray(dLogo, [4 4], 0, 'both'); dPattern = dPattern.*repmat(linspace(1, 0, 16)', [1, 16]); SAp.dBGImg = fBlend(SAp.dBGCOLOR, dPattern, 'multiply', 0.5); % ------------------------------------------------------------------------- % Parse Inputs and determine and create the initial amount of panels if ~isempty(varargin), fParseInputs(varargin); end if ~prod(SState.iPanels), SState.iPanels = [1 1]; end fCreatePanels; clear varargin; % <- no one needs you anymore! :(( % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Update the figure components fUpdateActivation(); % Acitvate/deactivate some buttons according to the gui state set(hF, 'Visible', 'on', 'UserData', @fGetData); fDraw; % Resize only calls fPosition argout = hF; % ------------------------------------------------------------------------- % The 'end' of the IMAGINE main function. The real end is, of course, after % all the nested functions. Using the nested functions, shared varaiables % (the variables of the IMAGINE function) can be used which makes the usage % of the 'guidata' commands obsolete. % ========================================================================= % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fCloseGUI (nested in imagine) % * * % * * Figure callback % * * % * * Closes the figure and saves the settings % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fCloseGUI(hObject, eventdata) %#ok<*INUSD> eventdata is repeatedly unused % ----------------------------------------------------------------- % Save the settings SSaveVar.sPath = SState.sPath; SSaveVar.csEvalLineFcns = SState.csEvalLineFcns; SSaveVar.csEvalROIFcns = SState.csEvalROIFcns; SSaveVar.csEvalVolFcns = SState.csEvalVolFcns; SSaveVar.iPosition = get(hObject, 'Position'); SSaveVar.lGermanExport = SPref.lGERMANEXPORT; try save(SPref.sSaveFilename, 'SSaveVar'); catch warning('Could not save the settings! Is the IMAGINE folder protected?'); end % ----------------------------------------------------------------- delete(hObject); % Bye-bye figure end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fCloseGUI % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fCreatePanels (nested in imagine) % * * % * * Create the panels and its child object. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fCreatePanels % ----------------------------------------------------------------- % Delete panels and their handles if necessary if isfield(SAxes, 'hImg') delete(SAxes.hImg); % Deletes hImgFrame and its children delete(SAxes.hColorbar); STexts = rmfield(STexts, {'hImg1', 'hImg2', 'hColorbarMin', 'hColorbarMax','hEval', 'hVal'}); SAxes = rmfield(SAxes, {'hImg', 'hColorbar'}); SImg = rmfield(SImg, {'hImg', 'hColorbar'}); end % ----------------------------------------------------------------- % ----------------------------------------------------------------- % For each panel create panels, axis, image and text objects for i = 1:prod(SState.iPanels) SAxes.hImg(i) = axes(... 'Parent' , hF, ... 'Units' , 'pixels', ... 'Color' , 'k', ... 'XTick' , [], ... 'YTick' , [], ... 'YDir' , 'reverse', ... 'XColor' , SAp.dBGCOLOR, ... 'YColor' , SAp.dBGCOLOR, ... 'Box' , 'on'); SImg.hImg(i) = image(... 'CData' , 0, ... 'Parent' , SAxes.hImg(i), ... 'HitTest' , 'off'); STexts.hImg1(i) = text('Units', 'pixels', 'FontSize', 14, 'Color', 'w', 'HorizontalAlignment', 'left', 'VerticalAlignment', 'top', 'Interpreter', 'none'); STexts.hImg2(i) = text('Units', 'pixels', 'FontSize', 14, 'Color', 'w', 'HorizontalAlignment', 'right', 'VerticalAlignment', 'top'); STexts.hColorbarMin(i) = text('Units', 'pixels', 'FontSize', 12, 'Color', 'w', 'HorizontalAlignment', 'right', 'VerticalAlignment', 'middle'); STexts.hColorbarMax(i) = text('Units', 'pixels', 'FontSize', 12, 'Color', 'w', 'HorizontalAlignment', 'left', 'VerticalAlignment', 'middle'); STexts.hEval(i) = text('Units', 'pixels', 'FontSize', 12, 'Color', 'w', 'HorizontalAlignment', 'left', 'VerticalAlignment', 'bottom'); STexts.hVal(i) = text('Units', 'pixels', 'FontSize', 12, 'Color', 'w', 'HorizontalAlignment', 'right', 'VerticalAlignment', 'bottom'); SAxes.hColorbar(i) = axes(... 'Parent' , hF, ... 'XTick' , [], ... 'YTick' , [], ... 'Units' , 'pixels', ... 'XLim' , [0 256] + 0.5, ... 'YLim' , [0.5 1.5], ... 'Visible' , 'off'); SImg.hColorbar(i) = image(... 'CData' , uint8(0:255), ... 'Parent' , SAxes.hColorbar(i), ... 'ButtonDownFcn' , @fSetWindow); iDataInd = i + SState.iStartSeries - 1; if (iDataInd > 0) && (iDataInd <= length(SData)) set(STexts.hColorbarMin(i), 'String', sprintf('%s', fPrintNumber(SData(iDataInd).dWindowCenter - SData(iDataInd).dWindowWidth./2))); set(STexts.hColorbarMax(i), 'String', sprintf('%s', fPrintNumber(SData(iDataInd).dWindowCenter + SData(iDataInd).dWindowWidth./2))); end end % of loop over pannels % ----------------------------------------------------------------- if strcmp(SState.sTool, 'rg'), set(SAxes.hImg, 'uicontextmenu', hContextMenu); end end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fCreatePanels % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fResizeFigure (nested in imagine) % * * % * * Figure callback % * * % * * Re-arranges all the GUI elements after a figure resize % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fResizeFigure(hObject, eventdata) % ----------------------------------------------------------------- % Get figure dimensions iFigureSize = get(hF, 'Position'); iViewWidth = round((iFigureSize(3) - SAp.iTOOLBARWIDTH ) / SState.iPanels(2)); iViewHeight = round((iFigureSize(4) - SAp.iMENUBARHEIGHT) / SState.iPanels(1)); % ----------------------------------------------------------------- % Arrange the panels and all their contents iYStart = 2; for iY = SState.iPanels(1):-1:1 % Start from the bottom if iY > 1 iHeight = iViewHeight; else iHeight = iFigureSize(4) - iYStart - SAp.iMENUBARHEIGHT; end iXStart = SAp.iTOOLBARWIDTH + 2; for iX = 1:SState.iPanels(2) iLinInd = (iY - 1).*SState.iPanels(2) + iX; if iX == SState.iPanels(2) iWidth = iFigureSize(3) - iXStart; else iWidth = iViewWidth; end set(STexts.hEval(iLinInd), 'Position', [5, 5]); set(STexts.hVal(iLinInd), 'Position', [iWidth - 5, 5]); set(SAxes.hImg(iLinInd), 'Position', [iXStart, iYStart, iWidth, iHeight]); set(STexts.hImg1(iLinInd), 'Position', [5, iHeight - 5]); set(STexts.hImg2(iLinInd), 'Position', [iWidth - 5, iHeight - 5]); set(SAxes.hColorbar(iLinInd), 'Position', [iXStart + SAp.iCOLORBARPADDING, iYStart + iHeight - SAp.iCOLORBARHEIGHT - SAp.iTITLEBARHEIGHT + 4, max([iWidth - 2*SAp.iCOLORBARPADDING, 1]), SAp.iCOLORBARHEIGHT - 3]); set(STexts.hColorbarMin(iLinInd), 'Position', [SAp.iCOLORBARPADDING - 5, iHeight - SAp.iTITLEBARHEIGHT - SAp.iCOLORBARHEIGHT + 6]); set(STexts.hColorbarMax(iLinInd), 'Position', [iWidth - SAp.iCOLORBARPADDING + 5, iHeight - SAp.iTITLEBARHEIGHT - SAp.iCOLORBARHEIGHT + 6]); iXStart = iXStart + iWidth; end iYStart = iYStart + iHeight; end % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Arrange the menubar dTextWidth = max([iFigureSize(3) - SState.dIconEnd - 48, 1]); set(SAxes.hMenu, 'Position', [1, iFigureSize(4) - SAp.iMENUBARHEIGHT + 1, iFigureSize(3), SAp.iMENUBARHEIGHT], ... 'XLim', [0 iFigureSize(3)] + 0.5, 'YLim', [0 SAp.iMENUBARHEIGHT] + 0.5); set(STexts.hStatus, 'Position', [SState.dIconEnd + 5, iFigureSize(4) - SAp.iMENUBARHEIGHT + 1 + 10, dTextWidth, 28]); % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Arrange the toolbar set(SAxes.hTools, 'Position', [1, 1, SAp.iTOOLBARWIDTH, iFigureSize(4) - SAp.iMENUBARHEIGHT], ... 'XLim', [0 SAp.iTOOLBARWIDTH] + 0.5, 'YLim', [0 iFigureSize(4) - SAp.iMENUBARHEIGHT] + 0.5); % ----------------------------------------------------------------- fPosition; end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fResizeFigure % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fFillPanels (nested in imagine) % * * % * * Display the current data in all panels. % * * The holy grail of Imagine! % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fFillPanels fDraw; fPosition; end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fFillPanels % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fDraw for i = 1:length(SAxes.hImg) iSeriesInd = SState.iStartSeries + i - 1; if iSeriesInd <= length(SData) % Panel not empty if strcmp(SState.sDrawMode, 'phase') dMin = -pi; dMax = pi; else dMin = SData(SState.iStartSeries).dWindowCenter - 0.5.*SData(SState.iStartSeries).dWindowWidth; dMax = SData(SState.iStartSeries).dWindowCenter + 0.5.*SData(SState.iStartSeries).dWindowWidth; end % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Get the image data, do windowing and apply colormap if ~fIsOn('link1') && ~strcmp(SState.sDrawMode, 'phase') dMin = SData(iSeriesInd).dWindowCenter - 0.5.*SData(iSeriesInd).dWindowWidth; dMax = SData(iSeriesInd).dWindowCenter + 0.5.*SData(iSeriesInd).dWindowWidth; end dImg = fGetImg(iSeriesInd); dImg = dImg - dMin; iImg = round(dImg./(dMax - dMin).*(SAp.iCOLORMAPLENGTH - 1)) + 1; iImg(iImg < 1) = 1; iImg(iImg > SAp.iCOLORMAPLENGTH) = SAp.iCOLORMAPLENGTH; dImg = reshape(SState.dColormapBack(iImg, :), [size(iImg, 1) ,size(iImg, 2), 3]); % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Apply mask if any if ~isempty(SData(iSeriesInd).lMask) % dColormap = [0 0 0; SPref.dCOLORMAP(i, :)] dColormap = [0 0 0; lines(max(SData(iSeriesInd).lMask(:)))]; switch SState.sDrawMode case {'mag', 'phase'}, iMask = uint8(SData(iSeriesInd).lMask(:,:,SData(iSeriesInd).iActiveImage)) + 1; case {'max', 'min'} , iMask = uint8(max(SData(iSeriesInd).lMask, [], 3)) + 1; end dMask = reshape(dColormap(iMask, :), [size(iMask, 1) ,size(iMask, 2), 3]); dImg = 1 - (1 - dImg).*(1 - SState.dMaskOpacity.*dMask); % The 'screen' overlay mode end set(SImg.hImg(i), 'CData', dImg, 'Visible', 'on'); % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Update the text elements set(STexts.hColorbarMin(i), 'String', sprintf('%s', fPrintNumber(dMin))); set(STexts.hColorbarMax(i), 'String', sprintf('%s', fPrintNumber(dMax))); set(STexts.hImg1(i), 'String', ['[', int2str(iSeriesInd), ']: ', SData(iSeriesInd).sName]); if strcmp(SState.sDrawMode, 'max') || strcmp(SState.sDrawMode, 'min') iMin = max(1, SData(iSeriesInd).iActiveImage - 3); iMax = min(size(SData(iSeriesInd).dImg, 3), SData(iSeriesInd).iActiveImage + 3); set(STexts.hImg2(i), 'String', sprintf('[%u - %u]/%u', iMin, iMax, size(SData(iSeriesInd).dImg, 3))); else set(STexts.hImg2(i), 'String', sprintf('%u/%u', SData(iSeriesInd).iActiveImage, size(SData(iSeriesInd).dImg, 3))); end set(STexts.hEval(i), 'String', SData(iSeriesInd).sEvalText); set(SImg.hColorbar(i), 'Visible', 'on'); % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else % Panel is empty % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Set image to the background image (RGB) set(SImg.hImg(i), 'CData', SAp.dBGImg, 'Visible', 'on'); set([STexts.hImg1(i), STexts.hEval(i), STexts.hVal(i), STexts.hImg2(i), STexts.hColorbarMin(i), STexts.hColorbarMax(i)], 'String', ''); set(SImg.hColorbar(i), 'Visible', 'off'); % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - end end end function fPosition for i = 1:length(SAxes.hImg) iSeriesInd = SState.iStartSeries + i - 1; dAxesPos = get(SAxes.hImg(i), 'Position'); if iSeriesInd <= length(SData) % Panel not empty % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Handle zoom and shift dScale = SData(iSeriesInd).dPixelSpacing; dScale = dScale(1, 1:2)./min(dScale); % Smallest Entry scaled to 1 dDelta_mm = dAxesPos([4, 3])./SData(iSeriesInd).dZoomFactor./dScale; set(SAxes.hImg(i), ... 'XLim', SData(iSeriesInd).dDrawCenter(2) + 0.5 * [-dDelta_mm(2) dDelta_mm(2)], ... 'YLim', SData(iSeriesInd).dDrawCenter(1) + 0.5 * [-dDelta_mm(1) dDelta_mm(1)]); % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - else dSize = dAxesPos(4:-1:3); dLim = size(SAp.dBGImg(:,:,1))./max(dSize).*dSize; set(SAxes.hImg(i), 'XLim', size(SAp.dBGImg, 2)/2 + 0.5*[-dLim(2) dLim(2)] + 0.5, ... 'YLim', size(SAp.dBGImg, 1)/2 + 0.5*[-dLim(1) dLim(1)] + 0.5); end end end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fIconClick (nested in imagine) % * * % * * Common callback for all buttons in the menubar % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fIconClick(hObject, eventdata) % ----------------------------------------------------------------- % Get the source's (pressed buttton) data and exit if disabled iInd = find(SImg.hIcons == hObject); if ~SIcons(iInd).Enabled, return, end; % ----------------------------------------------------------------- sActivate = []; % ----------------------------------------------------------------- % Distinguish the idfferent button types (normal, toggle, radio) switch SIcons(iInd).GroupIndex % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % NORMAL pushbuttons case -1 switch(SIcons(iInd).Name) % - - - - - - - - - - - - - - - - - - - - - - - - - - - % LOAD new FILES using file dialog case 'folder_open' if strcmp(get(hF, 'SelectionType'), 'normal') % Load Files [csFilenames, sPath] = uigetfile( ... {'*.*', 'All Files'; ... '*.dcm; *.DCM; *.mat; *.MAT; *.jpg; *.jpeg; *.JPG; *.JPEG; *.tif; *.tiff; *.TIF; *.TIFF; *.gif; *.GIF; *.bmp; *.BMP; *.png; *.PNG; *.nii; *.NII; *.gipl; *.GIPL', 'All images'; ... '*.mat; *.MAT', 'Matlab File (*.mat)'; ... '*.jpg; *.jpeg; *.JPG; *.JPEG', 'JPEG-Image (*.jpg)'; ... '*.tif; *.tiff; *.TIF; *.TIFF;', 'TIFF-Image (*.tif)'; ... '*.gif; *.GIF', 'Gif-Image (*.gif)'; ... '*.bmp; *.BMP', 'Bitmaps (*.bmp)'; ... '*.png; *.PNG', 'Portable Network Graphics (*.png)'; ... '*.dcm; *.DCM', 'DICOM Files (*.dcm)'; ... '*.nii; *.NII', 'NifTy Files (*.nii)'; ... '*.gipl; *.GIPL', 'Guys Image Processing Lab Files (*.gipl)'}, ... 'OpenLocation' , SState.sPath, ... 'Multiselect' , 'on'); if isnumeric(sPath), return, end; % Dialog aborted else % Load a folder sPath = uigetdir(SState.sPath); if isnumeric(sPath), return, end; sPath = [sPath, filesep]; SFiles = dir(sPath); SFiles = SFiles(~[SFiles.isdir]); csFilenames = cell(length(SFiles), 1); for i = 1:length(SFiles), csFilenames{i} = SFiles(i).name; end end SState.sPath = sPath; fLoadFiles(csFilenames); fFillPanels(); % - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - % IMPORT workspace (base) VARIABLE(S) case 'doc_import' csVars = fWSImport(); if isempty(csVars), return, end % Dialog aborted for i = 1:length(csVars) dVar = evalin('base', csVars{i}); fAddImageToData(dVar, csVars{i}, 'workspace'); end fFillPanels(); % - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - % SAVE panel data to file(s) case 'save' if strcmp(get(hF, 'SelectionType'), 'normal') [sFilename, sPath] = uiputfile( ... {'*.jpg', 'JPEG-Image (*.jpg)'; ... '*.tif', 'TIFF-Image (*.tif)'; ... '*.gif', 'Gif-Image (*.gif)'; ... '*.bmp', 'Bitmaps (*.bmp)'; ... '*.png', 'Portable Network Graphics (*.png)'}, ... 'Save selected series to files', ... [SState.sPath, filesep, '%SeriesName%_%ImageNumber%']); if isnumeric(sPath), return, end; % Dialog aborted SState.sPath = sPath; fSaveToFiles(sFilename, sPath); else [sFilename, sPath] = uiputfile( ... {'*.jpg', 'JPEG-Image (*.jpg)'; ... '*.tif', 'TIFF-Image (*.tif)'; ... '*.gif', 'Gif-Image (*.gif)'; ... '*.bmp', 'Bitmaps (*.bmp)'; ... '*.png', 'Portable Network Graphics (*.png)'}, ... 'Save MASK of selected series to files', ... [SState.sPath, filesep, '%SeriesName%_%ImageNumber%_Mask']); if isnumeric(sPath), return, end; % Dialog aborted SState.sPath = sPath; fSaveMaskToFiles(sFilename, sPath); end % - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - % DELETE DATA from structure case 'doc_delete' iSeriesInd = find([SData.lActive]); % Get indices of selected axes iSeriesInd = iSeriesInd(iSeriesInd >= SState.iStartSeries); SData(iSeriesInd) = []; % Delete the visible active data fFillPanels(); fUpdateActivation(); % To make sure panels without data are not selected % - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - % EXCHANGE SERIES case 'exchange' iSeriesInd = find([SData.lActive]); % Get indices of selected axes SData1 = SData(iSeriesInd(1)); SData(iSeriesInd(1)) = SData(iSeriesInd(2)); % Exchange the data SData(iSeriesInd(2)) = SData1; fFillPanels(); fUpdateActivation(); % To make sure panels without data are not selected % - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - % Determine the NUMBER OF PANELS and their LAYOUT case 'grid' iPanels = fGridSelect(4, 4); if ~sum(iPanels), return, end % Dialog aborted SState.iPanels = iPanels; fCreatePanels; % also updates the SState.iPanels fFillPanels; fUpdateActivation; fResizeFigure(hF, []); % - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - % Select the COLORMAP case 'colormap' sColormap = fColormapSelect(STexts.hStatus); if ~isempty(sColormap) eval(sprintf('dColormap = %s(SAp.iCOLORMAPLENGTH);', sColormap)); SState.dColormapBack = dColormap; fFillPanels; eval(sprintf('colormap(%s(256));', sColormap)); set(SAxes.hImg, 'Color', dColormap(1,:)); end % - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - % RESET the view (zoom/window/center) case 'reset' % Reset the view properties of all data for i = 1:length(SData) SData(i).dZoomFactor = 1; SData(i).dWindowCenter = mean(SData(i).dDynamicRange); SData(i).dWindowWidth = SData(i).dDynamicRange(2) - SData(i).dDynamicRange(1); SData(i).dDrawCenter = [0.5 0.5]; end fFillPanels(); % - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - % RECORD Start recording data case 'record' [sName, sPath] = uiputfile( ... {'*.csv', 'Comma-separated File (*.csv)'}, ... 'Chose Logfile', SState.sPath); if isnumeric(sPath) SState.sEvalFilename = ''; else SState.sEvalFilename = [sPath, sName]; end SState.sPath = sPath; fUpdateActivation; % - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - % STOP logging data case 'stop' SState.sEvalFilename = ''; fUpdateActivation; % - - - - - - - - - - - - - - - - - - - - - - - - - - - % REWIND last measurement case 'rewind' iPosDel = fGetEvalFilePos; if iPosDel < 0 fprintf('File ''%s''does not exist yet or is write-protexted!\n', SState.sEvalFilename); return end if iPosDel == 0 fprintf('Log file ''%s'' is empty!\n', SState.sEvalFilename); return end fid = fopen(SState.sEvalFilename, 'r'); sLine = fgets(fid); i = 1; lLast = false; while ischar(sLine) csText{i} = sLine; i = i + 1; sLine = fgets(fid); csPos = textscan(sLine, '"%d"'); if isempty(csPos{1}) iPos = 0; else iPos = csPos{1}; end if iPos == iPosDel - 1, lLast = true; end if iPos ~= iPosDel - 1 && lLast, break, end end fclose(fid); iEnd = length(csText); if iPosDel == 1, iEnd = 3; end fid = fopen(SState.sEvalFilename, 'w'); for i = 1:iEnd fprintf(fid, '%s', csText{i}); end fprintf('Removed entry %d from ''%s''!\n', iPosDel, SState.sEvalFilename); fclose(fid); % - - - - - - - - - - - - - - - - - - - - - - - - - - - otherwise end % End of NORMAL buttons % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % TOGGLE buttons: Invert the state case 0 SIcons(iInd).Active = ~SIcons(iInd).Active; fUpdateActivation(); fFillPanels; % Because of link button % End of TOGGLE buttons % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % The render-mode group case 1 % The render-mode group if ~strcmp(SState.sDrawMode, SIcons(iInd).Name) SState.sDrawMode = SIcons(iInd).Name; sActivate = SIcons(iInd).Name; else SState.sDrawMode = 'mag'; end fFillPanels; case 255 % The toolbar % - - - - - - - - - - - - - % Right-click setup menus if strcmp(get(hF, 'SelectionType'), 'alt') && ~isfield(eventdata, 'Character')% Right click, open tool settings in neccessary switch SIcons(iInd).Name case 'line', csFcns = fSelectEvalFcns(SState.csEvalLineFcns, [SPref.sMFILEPATH, filesep, 'EvalFunctions']); if iscell(csFcns), SState.csEvalLineFcns = csFcns; end case {'roi', 'lw'}, csFcns = fSelectEvalFcns(SState.csEvalROIFcns, [SPref.sMFILEPATH, filesep, 'EvalFunctions']); if iscell(csFcns), SState.csEvalROIFcns = csFcns; end case 'rg' csFcns = fSelectEvalFcns(SState.csEvalVolFcns, [SPref.sMFILEPATH, filesep, 'EvalFunctions']); if iscell(csFcns), SState.csEvalVolFcns = csFcns; end end end % - - - - - - - - - - - - - % - - - - - - - - - - - - - if ~strcmp(SState.sTool, SIcons(iInd).Name) % Tool change % Try to delete the lines of the ROI and line eval tools if isfield(SLines, 'hEval') try delete(SLines.hEval); end %#ok<TRYNC> SLines = rmfield(SLines, 'hEval'); end % Set tool-specific context menus switch SIcons(iInd).Name case 'rg', set(SAxes.hImg, 'uicontextmenu', hContextMenu); otherwise, set(SAxes.hImg, 'uicontextmenu', []); end % Remove the masks, if a new eval tool is selected switch SIcons(iInd).Name case {'line', 'roi', 'lw', 'rg', 'ic'} for i = 1:length(SData), SData(i).lMask = []; end fFillPanels; end % ----------------------------------------------------------------- % Reset the ROI painting state machine and Mouse callbacks SState.iROIState = 0; set(gcf, 'WindowButtonDownFcn' , @fWindowButtonDownFcn); set(gcf, 'WindowButtonMotionFcn', @fWindowMouseHoverFcn); set(gcf, 'WindowButtonUpFcn' , ''); % ----------------------------------------------------------------- end SState.sTool = SIcons(iInd).Name; sActivate = SIcons(iInd).Name; % - - - - - - - - - - - - - end % - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - % Common code for all radio groups if SIcons(iInd).GroupIndex > 0 for i = 1:length(SIcons) if SIcons(i).GroupIndex == SIcons(iInd).GroupIndex SIcons(i).Active = strcmp(SIcons(i).Name, sActivate); end end end fUpdateActivation(); % - - - - - - - - - - - - - - - - - - - end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fIconClick % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fWindowMouseHoverFcn (nested in imagine) % * * % * * Figure callback % * * % * * The standard mouse move callback. Displays cursor coordinates and % * * intensity value of corresponding pixel. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fWindowMouseHoverFcn(hObject, eventdata) iAxisInd = fGetPanel(); if iAxisInd % ------------------------------------------------------------- % Cursor is over a panel -> show coordinates and intensity iPos = uint16(get(SAxes.hImg(iAxisInd), 'CurrentPoint')); % Get cursor poition in axis coordinate system for i = 1:length(SAxes.hImg) iSeriesInd = SState.iStartSeries + i - 1; if iSeriesInd > length(SData), continue, end if iPos(1, 1) > 0 && iPos(1, 2) > 0 && iPos(1, 1) <= size(SData(iSeriesInd).dImg, 2) && iPos(1, 2) <= size(SData(iSeriesInd).dImg, 1) switch SState.sDrawMode case {'mag', 'phase'} dImg = fGetImg(iSeriesInd); dVal = dImg(iPos(1, 2), iPos(1, 1)); case 'max' if isreal(SData(iSeriesInd).dImg) dVal = max(SData(iSeriesInd).dImg(iPos(1, 2), iPos(1, 1), :), [], 3); else dVal = max(abs(SData(iSeriesInd).dImg(iPos(1, 2), iPos(1, 1), :)), [], 3); end case 'min' if isreal(SData(iSeriesInd).dImg) dVal = min(SData(iSeriesInd).dImg(iPos(1, 2), iPos(1, 1), :), [], 3); else dVal = min(abs(SData(iSeriesInd).dImg(iPos(1, 2), iPos(1, 1), :)), [], 3); end end if i == iAxisInd, set(STexts.hStatus, 'String', sprintf('I(%u,%u) = %s', iPos(1, 1), iPos(1, 2), fPrintNumber(dVal))); end set(STexts.hVal(i), 'String', sprintf('%s', fPrintNumber(dVal))); else if i == iAxisInd, set(STexts.hStatus, 'String', ''); end set(STexts.hVal(i), 'String', ''); end end % ------------------------------------------------------------- else % ------------------------------------------------------------- % Cursor is not over a panel -> Check if tooltip has to be shown hOver = hittest; iInd = find([SImg.hIcons] == hOver); if iInd sText = SIcons(iInd).Tooltip; sAccelerator = SIcons(iInd).Accelerator; if ~isempty(SIcons(iInd).Modifier), sAccelerator = sprintf('%s+%s', SIcons(iInd).Modifier, SIcons(iInd).Accelerator); end if ~isempty(SIcons(iInd).Accelerator), sText = sprintf('%s [%s]', sText, sAccelerator); end set(STexts.hStatus, 'String', sText); else set(STexts.hStatus, 'String', ''); end % ------------------------------------------------------------- end drawnow update end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fWindowMouseHoverFcn % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fWindowButtonDownFcn (nested in imagine) % * * % * * Figure callback % * * % * * Starting callback for mouse button actions. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fWindowButtonDownFcn(hObject, eventdata) iAxisInd = fGetPanel(); if ~iAxisInd, return, end % Exit if event didn't occurr in a panel % ----------------------------------------------------------------- % Save starting parameters dPos = get(SAxes.hImg(iAxisInd), 'CurrentPoint'); SMouse.iStartAxis = iAxisInd; SMouse.iStartPos = get(hObject, 'CurrentPoint'); SMouse.dAxesStartPos = [dPos(1, 1), dPos(1, 2)]; % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Backup the display settings of all data SMouse.dDrawCenter = reshape([SData.dDrawCenter], [2, length(SData)]); SMouse.dZoomFactor = [SData.dZoomFactor]; SMouse.dWindowCenter = [SData.dWindowCenter]; SMouse.dWindowWidth = [SData.dWindowWidth]; % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Delete existing line objects, clear masks if isfield(SLines, 'hEval') try delete(SLines.hEval); end %#ok<TRYNC> SLines = rmfield(SLines, 'hEval'); end switch SState.sTool case {'line', 'roi', 'lw', 'rg', 'ic'} for i = 1:length(SData), SData(i).lMask = []; end fFillPanels; end % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Activate the callbacks for drag operations set(hObject, 'WindowButtonUpFcn', @fWindowButtonUpFcn); set(hObject, 'WindowButtonMotionFcn', @fWindowMouseMoveFcn); % ----------------------------------------------------------------- drawnow update end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fWindowButtonDownFcn % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fWindowMouseMoveFcn (nested in imagine) % * * % * * Figure callback % * * % * * Callback for mouse movement while button is pressed. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fWindowMouseMoveFcn(hObject, eventdata) iAxesInd = fGetPanel(); % ----------------------------------------------------------------- % Get some frequently used values lLinked = fIsOn('link'); % Determines whether axes are linked iD = get(hF, 'CurrentPoint') - SMouse.iStartPos; % Mouse distance travelled since button down % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Tool-specific code switch SState.sTool % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % The NORMAL CURSOR: select, move, zoom, window case 'cursor_arrow' switch get(hF, 'SelectionType') % - - - - - - - - - - - - - - - - - - - - - - - - - - - % Normal, left mouse button -> MOVE operation case 'normal' dD = double(iD); % Scale mouse movement to panel size (since DrawCenter is a relative value) dD(2) = -dD(2); for i = 1:length(SData) iAxisInd = i - SState.iStartSeries + 1; if ~((lLinked) || (iAxisInd == SMouse.iStartAxis)), continue, end % Skip if axes not linked and current figure not active dScale = SData(i).dPixelSpacing(1:2)./min(SData(i).dPixelSpacing); dNewPos = SMouse.dDrawCenter(:, i)' - flip(dD)./dScale./SData(i).dZoomFactor; % Calculate new draw center relative to saved one SData(i).dDrawCenter = dNewPos; % Save DrawCenter data end fPosition; % - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - % Shift key or right mouse button -> ZOOM operation case 'alt' for i = 1:length(SData) if (~fIsOn('link')) && i ~= (SMouse.iStartAxis + SState.iStartSeries - 1), continue, end % Skip if axes not linked and current figure not active dZoom = min(100, max(0.25, SMouse.dZoomFactor(i).*exp(SPref.dZOOMSENSITIVITY.*iD(2)))); dOldDrawCenter = SMouse.dDrawCenter(:, i)'; dMouseStart = flip(SMouse.dAxesStartPos, 2); dD = dOldDrawCenter - dMouseStart; SData(i).dDrawCenter = dMouseStart + SMouse.dZoomFactor(i)./dZoom.*dD; SData(i).dZoomFactor = dZoom; % Save ZoomFactor data end fPosition; case 'extend' % Control key or middle mouse button -> WINDOW operation for i = 1:length(SData) if (~fIsOn('link')) && (i ~= SMouse.iStartAxis + SState.iStartSeries - 1), continue, end % Skip if axes not linked and current figure not active SData(i).dWindowWidth = SMouse.dWindowWidth(i) .*exp(SPref.dWINDOWSENSITIVITY*(-iD(2))); SData(i).dWindowCenter = SMouse.dWindowCenter(i).*exp(SPref.dWINDOWSENSITIVITY* iD(1)); iAxisInd = i - SState.iStartSeries + 1; if iAxisInd < 1 || iAxisInd > length(SAxes.hImg), continue, end % Do not update images outside the figure's scope (will be done with next call of fFillPanels) if iAxisInd == SMouse.iStartAxis % Show windowing information for the starting axes set(STexts.hStatus, 'String', sprintf('C: %s, W: %s', fPrintNumber(SData(i).dWindowCenter), fPrintNumber(SData(i).dWindowWidth))); end end fFillPanels; end % end of the NORMAL CURSOR % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % The ROTATION tool case 'rotate' if ~any(abs(iD) > SPref.dROTATION_THRESHOLD), return, end % Only proceed if action required iStartSeries = SMouse.iStartAxis + SState.iStartSeries - 1; for i = 1:length(SData) if ~(lLinked || i == iStartSeries || SData(i).iGroupIndex == SData(iStartSeries).iGroupIndex), continue, end % Skip if axes not linked and current figure not active switch get(hObject, 'SelectionType') % - - - - - - - - - - - - - - - - - - - - - - - - - - - % Normal, left mouse button -> volume rotation operation case 'normal' if iD(1) > SPref.dROTATION_THRESHOLD % Moved mouse to left SData(i).iActiveImage = uint16(SMouse.dAxesStartPos(1, 1)); iPermutation = [1 3 2]; iFlipdim = 2; end if iD(1) < -SPref.dROTATION_THRESHOLD % Moved mouse to right SData(i).iActiveImage = uint16(size(SData(i).dImg, 2) - SMouse.dAxesStartPos(1, 1) + 1); iPermutation = [1 3 2]; iFlipdim = 3; end if iD(2) > SPref.dROTATION_THRESHOLD SData(i).iActiveImage = uint16(size(SData(i).dImg, 1) - SMouse.dAxesStartPos(1, 2) + 1); iPermutation = [3 2 1]; iFlipdim = 3; end if iD(2) < -SPref.dROTATION_THRESHOLD SData(i).iActiveImage = uint16(SMouse.dAxesStartPos(1, 2)); iPermutation = [3 2 1]; iFlipdim = 1; end % - - - - - - - - - - - - - - - - - - - - - - - - - % Shift key or right mouse button -> rotate in-plane case 'alt' if any(iD > SPref.dROTATION_THRESHOLD) iPermutation = [2 1 3]; iFlipdim = 2; end if any(iD < -SPref.dROTATION_THRESHOLD) iPermutation = [2 1 3]; iFlipdim = 1; end % - - - - - - - - - - - - - - - - - - - - - - - - - case 'extend' return end % Switch statement % - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - % Apply the transformation SData(i).dImg = flipdim(permute(SData(i).dImg, iPermutation), iFlipdim); SData(i).lMask = flipdim(permute(SData(i).lMask, iPermutation), iFlipdim); SData(i).dPixelSpacing = SData(i).dPixelSpacing(iPermutation); set(hObject, 'WindowButtonMotionFcn', @fWindowMouseHoverFcn); % - - - - - - - - - - - - - - - - - - - - - - - % Limit active image range to image dimensions if SData(i).iActiveImage < 1, SData(i).iActiveImage = 1; end if SData(i).iActiveImage > size(SData(i).dImg, 3), SData(i).iActiveImage = size(SData(i).dImg, 3); end end % Loop over the data % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fFillPanels(); % END of the rotate tool % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % The LINE EVALUATION tool case 'line' if ~iAxesInd, return, end % Exit if event didn't occurr in a panel dPos = get(SAxes.hImg(iAxesInd), 'CurrentPoint'); if ~isfield(SLines, 'hEval') % Make sure line object exists for i = 1:length(SAxes.hImg) if i + SState.iStartSeries - 1 > length(SData), continue, end SLines.hEval(i) = line([SMouse.dAxesStartPos(1, 1), dPos(1, 1)], [SMouse.dAxesStartPos(1, 2), dPos(1, 2)], ... 'Parent' , SAxes.hImg(i), ... 'Color' , SPref.dCOLORMAP(i,:), ... 'LineStyle' , '-'); end else set(SLines.hEval, 'XData', [SMouse.dAxesStartPos(1, 1), dPos(1, 1)], 'YData', [SMouse.dAxesStartPos(1, 2), dPos(1, 2)]); end fWindowMouseHoverFcn(hF, []); % Update the position display by triggering the mouse hover callback % end of the LINE EVALUATION tool % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Handle special case of ROI drawing (update the lines), ellipse case 'roi' if ~iAxesInd || iAxesInd + SState.iStartSeries - 1 > length(SData), return, end switch SState.iROIState case 0 % No drawing -> Check if one should start an elliplse or rectangle dPos = get(SAxes.hImg(SMouse.iStartAxis), 'CurrentPoint'); if sum((dPos(1, 1:2) - SMouse.dAxesStartPos).^2) > 4 for i = 1:length(SAxes.hImg) if i + SState.iStartSeries - 1 > length(SData), continue, end SLines.hEval(i) = line(dPos(1, 1), dPos(1, 2), ... 'Parent' , SAxes.hImg(i), ... 'Color' , SPref.dCOLORMAP(i,:),... 'LineStyle' , '-'); end switch(get(hF, 'SelectionType')) case 'normal', SState.iROIState = 2; % -> Rectangle case {'alt', 'extend'}, SState.iROIState = 3; % -> Ellipse end end case 1 % Polygon mode dPos = get(SAxes.hImg(iAxesInd), 'CurrentPoint'); dROILineX = [SState.dROILineX; dPos(1, 1)]; % Draw a line to the cursor position dROILineY = [SState.dROILineY; dPos(1, 2)]; set(SLines.hEval, 'XData', dROILineX, 'YData', dROILineY); case 2 % Rectangle mode dPos = get(SAxes.hImg(iAxesInd), 'CurrentPoint'); SState.dROILineX = [SMouse.dAxesStartPos(1); SMouse.dAxesStartPos(1); dPos(1, 1); dPos(1, 1); SMouse.dAxesStartPos(1)]; SState.dROILineY = [SMouse.dAxesStartPos(2); dPos(1, 2); dPos(1, 2); SMouse.dAxesStartPos(2); SMouse.dAxesStartPos(2)]; set(SLines.hEval, 'XData', SState.dROILineX, 'YData', SState.dROILineY); case 3 % Ellipse mode dPos = get(SAxes.hImg(iAxesInd), 'CurrentPoint'); dDX = dPos(1, 1) - SMouse.dAxesStartPos(1); dDY = dPos(1, 2) - SMouse.dAxesStartPos(2); if strcmp(get(hF, 'SelectionType'), 'extend') dD = max(abs([dDX, dDY])); dDX = sign(dDX).*dD; dDY = sign(dDY).*dD; end dT = linspace(-pi, pi, 100)'; SState.dROILineX = SMouse.dAxesStartPos(1) + dDX./2.*(1 + cos(dT)); SState.dROILineY = SMouse.dAxesStartPos(2) + dDY./2.*(1 + sin(dT)); set(SLines.hEval, 'XData', SState.dROILineX, 'YData', SState.dROILineY); end fWindowMouseHoverFcn(hF, []); % Update the position display by triggering the mouse hover callback % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Handle special case of LW drawing (update the lines) case 'lw' if iAxesInd == SMouse.iStartAxis if SState.iROIState == 1 && sum(abs(SState.iPX(:))) > 0 % ROI drawing in progress dPos = get(SAxes.hImg(SMouse.iStartAxis), 'CurrentPoint'); [iXPath, iYPath] = fLiveWireGetPath(SState.iPX, SState.iPY, dPos(1, 1), dPos(1, 2)); if isempty(iXPath) iXPath = dPos(1, 1); iYPath = dPos(1, 2); end set(SLines.hEval, 'XData', [SState.dROILineX; double(iXPath(:))], ... 'YData', [SState.dROILineY; double(iYPath(:))]); drawnow update end end fWindowMouseHoverFcn(hF, []); % Update the position display by triggering the mouse hover callback % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - otherwise end % end of the TOOL switch statement % ----------------------------------------------------------------- drawnow update end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fWindowMouseMoveFcn % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fWindowButtonUpFcn (nested in imagine) % * * % * * Figure callback % * * % * * End of mouse operations. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fWindowButtonUpFcn(hObject, eventdata) iAxisInd = fGetPanel(); iCursorPos = get(hF, 'CurrentPoint'); % ----------------------------------------------------------------- % Stop the operation by disabling the corresponding callbacks set(hF, 'WindowButtonMotionFcn' ,@fWindowMouseHoverFcn); set(hF, 'WindowButtonUpFcn' ,''); set(STexts.hStatus, 'String', ''); % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Tool-specific code switch SState.sTool % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % The NORMAL CURSOR: select, move, zoom, window % In this function, only the select case has to be handled case 'cursor_arrow' if ~sum(abs(iCursorPos - SMouse.iStartPos)) % Proceed only if mouse was moved switch get(hF, 'SelectionType') % - - - - - - - - - - - - - - - - - - - - - - - - - % NORMAL selection: Select only current series case 'normal' iN = fGetNActiveVisibleSeries(); for iSeries = 1:length(SData) if SMouse.iStartAxis + SState.iStartSeries - 1 == iSeries SData(iSeries).lActive = ~SData(iSeries).lActive || iN > 1; else SData(iSeries).lActive = false; end end SState.iLastSeries = SMouse.iStartAxis + SState.iStartSeries - 1; % The lastAxis is needed for the shift-click operation % end of normal selection % - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - % Shift key or right mouse button: Select ALL axes % between last selected axis and current axis case 'extend' iSeriesInd = SMouse.iStartAxis + SState.iStartSeries - 1; if sum([SData.lActive] == true) == 0 % If no panel active, only select the current axis SData(iSeriesInd).lActive = true; SState.iLastSeries = iSeriesInd; else if SState.iLastSeries ~= iSeriesInd iSortedInd = sort([SState.iLastSeries, iSeriesInd], 'ascend'); for i = 1:length(SData) SData(i).lActive = (i >= iSortedInd(1)) && (i <= iSortedInd(2)); end end end % end of shift key/right mouse button % - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - % Cntl key or middle mouse button: ADD/REMOVE axis % from selection case 'alt' iSeriesInd = SMouse.iStartAxis + SState.iStartSeries - 1; SData(iSeriesInd).lActive = ~SData(iSeriesInd).lActive; SState.iLastSeries = iSeriesInd; % end of alt/middle mouse buttton % - - - - - - - - - - - - - - - - - - - - - - - - - end end % end of the NORMAL CURSOR % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % The LINE EVALUATION tool case 'line' fEval(SState.csEvalLineFcns); % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % End of the LINE EVALUATION tool % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % The ROI EVALUATION tool case 'roi' set(hF, 'WindowButtonMotionFcn', @fWindowMouseMoveFcn); set(hF, 'WindowButtonDownFcn', ''); set(hF, 'WindowButtonUpFcn', @fWindowButtonUpFcn); % But keep the button up function if iAxisInd && iAxisInd + SState.iStartSeries - 1 <= length(SData) % ROI drawing in progress dPos = get(SAxes.hImg(iAxisInd), 'CurrentPoint'); if SState.iROIState > 1 || any(strcmp({'extend', 'open'}, get(hF, 'SelectionType'))) SState.dROILineX = [SState.dROILineX; SState.dROILineX(1)]; % Close line SState.dROILineY = [SState.dROILineY; SState.dROILineY(1)]; delete(SLines.hEval); SState.iROIState = 0; set(hF, 'WindowButtonMotionFcn',@fWindowMouseHoverFcn); set(hF, 'WindowButtonDownFcn', @fWindowButtonDownFcn); set(hF, 'WindowButtonUpFcn', ''); fEval(SState.csEvalROIFcns); return end switch get(hF, 'SelectionType') % - - - - - - - - - - - - - - - - - - - - - - - - - - - % NORMAL selection: Add point to roi case 'normal' if ~SState.iROIState % This is the first polygon point SState.dROILineX = dPos(1, 1); SState.dROILineY = dPos(1, 2); for i = 1:length(SAxes.hImg) if i + SState.iStartSeries - 1 > length(SData), continue, end SLines.hEval(i) = line(SState.dROILineX, SState.dROILineY, ... 'Parent' , SAxes.hImg(i), ... 'Color' , SPref.dCOLORMAP(i,:),... 'LineStyle' , '-'); end SState.iROIState = 1; else % Add point to existing polygone SState.dROILineX = [SState.dROILineX; dPos(1, 1)]; SState.dROILineY = [SState.dROILineY; dPos(1, 2)]; set(SLines.hEval, 'XData', SState.dROILineX, 'YData', SState.dROILineY); end % End of NORMAL selection % - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - % Right mouse button/shift key: UNDO last point, quit % if is no point remains case 'alt' if ~SState.iROIState, return, end % Only perform action if painting in progress if length(SState.dROILineX) > 1 SState.dROILineX = SState.dROILineX(1:end-1); % Delete last point SState.dROILineY = SState.dROILineY(1:end-1); dROILineX = [SState.dROILineX; dPos(1, 1)]; % But draw line to current cursor position dROILineY = [SState.dROILineY; dPos(1, 2)]; set(SLines.hEval, 'XData', dROILineX, 'YData', dROILineY); else % Abort drawing ROI SState.iROIState = 0; delete(SLines.hEval); SLines = rmfield(SLines, 'hEval'); set(hF, 'WindowButtonMotionFcn',@fWindowMouseHoverFcn); set(hF, 'WindowButtonDownFcn', @fWindowButtonDownFcn); % Disable the button down function end % End of right click/shift-click % - - - - - - - - - - - - - - - - - - - - - - - - - - - end end % End of the ROI EVALUATION tool % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % The LIVEWIRE EVALUATION tool case 'lw' set(hF, 'WindowButtonMotionFcn', @fWindowMouseMoveFcn); set(hF, 'WindowButtonDownFcn', ''); set(hF, 'WindowButtonUpFcn', @fWindowButtonUpFcn); % But keep the button up function if iAxisInd ~= SMouse.iStartAxis, return, end dPos = get(SAxes.hImg(SMouse.iStartAxis), 'CurrentPoint'); switch get(hF, 'SelectionType') % - - - - - - - - - - - - - - - - - - - - - - - - - - - % NORMAL selection: Add point to roi case 'normal' if ~SState.iROIState % This is the first polygon point dImg = SData(SMouse.iStartAxis + SState.iStartSeries - 1).dImg(:,:,SData(SMouse.iStartAxis + SState.iStartSeries - 1).iActiveImage); SState.dLWCostFcn = fLiveWireGetCostFcn(dImg); SState.dROILineX = dPos(1, 1); SState.dROILineY = dPos(1, 2); for i = 1:length(SAxes.hImg) if i + SState.iStartSeries - 1 > length(SData), continue, end SLines.hEval(i) = line(SState.dROILineX, SState.dROILineY, ... 'Parent' , SAxes.hImg(i), ... 'Color' , SPref.dCOLORMAP(i,:),... 'LineStyle' , '-'); end SState.iROIState = 1; SState.iLWAnchorList = zeros(200, 1); SState.iLWAnchorInd = 0; else % Add point to existing polygone [iXPath, iYPath] = fLiveWireGetPath(SState.iPX, SState.iPY, dPos(1, 1), dPos(1, 2)); if isempty(iXPath) iXPath = dPos(1, 1); iYPath = dPos(1, 2); end SState.dROILineX = [SState.dROILineX; double(iXPath(:))]; SState.dROILineY = [SState.dROILineY; double(iYPath(:))]; set(SLines.hEval, 'XData', SState.dROILineX, 'YData', SState.dROILineY); end SState.iLWAnchorInd = SState.iLWAnchorInd + 1; SState.iLWAnchorList(SState.iLWAnchorInd) = length(SState.dROILineX); % Save the previous path length for the undo operation [SState.iPX, SState.iPY] = fLiveWireCalcP(SState.dLWCostFcn, dPos(1, 1), dPos(1, 2), SPref.dLWRADIUS); % End of NORMAL selection % - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - % Right mouse button/shift key: UNDO last point, quit % if is no point remains case 'alt' if SState.iROIState SState.iLWAnchorInd = SState.iLWAnchorInd - 1; if SState.iLWAnchorInd SState.dROILineX = SState.dROILineX(1:SState.iLWAnchorList(SState.iLWAnchorInd)); % Delete last point SState.dROILineY = SState.dROILineY(1:SState.iLWAnchorList(SState.iLWAnchorInd)); set(SLines.hEval, 'XData', SState.dROILineX, 'YData', SState.dROILineY); drawnow; [SState.iPX, SState.iPY] = fLiveWireCalcP(SState.dLWCostFcn, SState.dROILineX(end), SState.dROILineY(end), SPref.dLWRADIUS); fWindowMouseMoveFcn(hObject, []); else % Abort drawing ROI SState.iROIState = 0; delete(SLines.hEval); SLines = rmfield(SLines, 'hEval'); set(hF, 'WindowButtonMotionFcn',@fWindowMouseHoverFcn); set(hF, 'WindowButtonDownFcn', @fWindowButtonDownFcn); end end % End of right click/shift-click % - - - - - - - - - - - - - - - - - - - - - - - - - - - % Middle mouse button/double-click/cntl-click: CLOSE % POLYGONE and quit roi action case {'extend', 'open'} % Middle mouse button or double-click -> if ~SState.iROIState, return, end % Only perform action if painting in progress [iXPath, iYPath] = fLiveWireGetPath(SState.iPX, SState.iPY, dPos(1, 1), dPos(1, 2)); if isempty(iXPath) iXPath = dPos(1, 1); iYPath = dPos(1, 2); end SState.dROILineX = [SState.dROILineX; double(iXPath(:))]; SState.dROILineY = [SState.dROILineY; double(iYPath(:))]; [SState.iPX, SState.iPY] = fLiveWireCalcP(SState.dLWCostFcn, dPos(1, 1), dPos(1, 2), SPref.dLWRADIUS); [iXPath, iYPath] = fLiveWireGetPath(SState.iPX, SState.iPY, SState.dROILineX(1), SState.dROILineY(1)); if isempty(iXPath) iXPath = SState.dROILineX(1); iYPath = SState.dROILineX(2); end SState.dROILineX = [SState.dROILineX; double(iXPath(:))]; SState.dROILineY = [SState.dROILineY; double(iYPath(:))]; set(SLines.hEval, 'XData', SState.dROILineX, 'YData', SState.dROILineY); delete(SLines.hEval); SState.iROIState = 0; set(hF, 'WindowButtonMotionFcn',@fWindowMouseHoverFcn); set(hF, 'WindowButtonDownFcn', @fWindowButtonDownFcn); set(hF, 'WindowButtonUpFcn', ''); fEval(SState.csEvalROIFcns); % End of middle mouse button/double-click/cntl-click % - - - - - - - - - - - - - - - - - - - - - - - - - - - end % End of the LIVEWIRE EVALUATION tool % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % The REGION GROWING tool case 'rg' if ~strcmp(get(hF, 'SelectionType'), 'normal'), return, end; % Otherwise calling the context menu starts a rg if ~iAxisInd || iAxisInd > length(SData), return, end; iSeriesInd = iAxisInd + SState.iStartSeries - 1; iSize = size(SData(iSeriesInd).dImg); dPos = get(SAxes.hImg(iAxisInd), 'CurrentPoint'); if dPos(1, 1) < 1 || dPos(1, 2) < 1 || dPos(1, 1) > iSize(2) || dPos(1, 2) > iSize(1), return, end fEval(SState.csEvalVolFcns); % End of the REGION GROWING tool % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % The ISOCONTOUR tool case 'ic' if ~iAxisInd || iAxisInd > length(SData), return, end; iSeriesInd = iAxisInd + SState.iStartSeries - 1; iSize = size(SData(iSeriesInd).dImg); dPos = get(SAxes.hImg(iAxisInd), 'CurrentPoint'); if dPos(1, 1) < 1 || dPos(1, 2) < 1 || dPos(1, 1) > iSize(2) || dPos(1, 2) > iSize(1), return, end fEval(SState.csEvalVolFcns); % End of the ISOCONTOUR tool % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % The PROPERTIES tool: Rename the data case 'tag' if ~iAxisInd || iAxisInd > length(SData), return, end; iSeriesInd = SState.iStartSeries + iAxisInd - 1; csPrompt = {'Name', 'Voxel Size', 'Units'}; dDim = SData(iSeriesInd).dPixelSpacing; sDim = sprintf('%4.2f x ', dDim([2, 1, 3])); csVal = {SData(iSeriesInd).sName, sDim(1:end-3), SData(iSeriesInd).sUnits}; csAns = inputdlg(csPrompt, sprintf('Change %s', SData(iSeriesInd).sName), 1, csVal); if isempty(csAns), return, end sName = csAns{1}; iInd = find([SData.iGroupIndex] == SData(iSeriesInd).iGroupIndex); if length(iInd) > 1 if ~isnan(str2double(sName(end - 1:end))), sName = sName(1:end - 2); end % Crop the number end dDim = cell2mat(textscan(csAns{2}, '%fx%fx%f')); iCnt = 1; for i = iInd if length(iInd) > 1 SData(i).sName = sprintf('%s%02d', sName, iCnt); else SData(i).sName = sName; end SData(i).dPixelSpacing = dDim([2, 1, 3]); SData(i).sUnits = csAns{3}; iCnt = iCnt + 1; end fFillPanels; % End of the TAG tool % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - end % end of the tool switch-statement % ----------------------------------------------------------------- fUpdateActivation(); end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fWindowButtonUpFcn % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fKeyPressFcn (nested in imagine) % * * % * * Figure callback % * * % * * Callback for keyboard actions. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fKeyPressFcn(hObject, eventdata) % ----------------------------------------------------------------- % Bail if only a modifier has been pressed switch eventdata.Key case {'shift', 'control', 'alt'}, return end % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Get the modifier (shift, cntl, alt) keys and determine whether % the control key was pressed csModifier = eventdata.Modifier; sModifier = ''; for i = 1:length(csModifier) if strcmp(csModifier{i}, 'shift' ), sModifier = 'Shift'; end if strcmp(csModifier{i}, 'control'), sModifier = 'Cntl'; end if strcmp(csModifier{i}, 'alt' ), sModifier = 'Alt'; end end % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Look for buttons with corresponding accelerators/modifiers for i = 1:length(SIcons) if strcmp(SIcons(i).Accelerator, eventdata.Key) && ... strcmp(SIcons(i).Modifier, sModifier) fIconClick(SImg.hIcons(i), eventdata); end end % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Functions not implemented by buttons switch eventdata.Key case {'numpad1', 'leftarrow'} % Image up fChangeImage(hObject, -1); case {'numpad2', 'rightarrow'} % Image down fChangeImage(hObject, 1); case {'numpad4', 'uparrow'} % Series up SState.iStartSeries = max([1 SState.iStartSeries - 1]); fFillPanels(); fUpdateActivation(); fWindowMouseHoverFcn(hObject, eventdata); % Update the cursor value case {'numpad5', 'downarrow'} % Series down SState.iStartSeries = min([SState.iStartSeries + 1 length(SData)]); SState.iStartSeries = max([SState.iStartSeries 1]); fFillPanels(); fUpdateActivation(); fWindowMouseHoverFcn(hObject, eventdata); % Update the cursor value case 'period' SState.iStartSeries = SState.iStartSeries + 1; if SState.iStartSeries > length(SData), SState.iStartSeries = 1; end fFillPanels(); fUpdateActivation(); fWindowMouseHoverFcn(hObject, eventdata); % Update the cursor value case 'space' % Cycle Tools iTools = find([SIcons.GroupIndex] == 255 & [SIcons.Enabled]); iToolInd = find(strcmp({SIcons.Name}, SState.sTool)); iToolIndInd = find(iTools == iToolInd); iTools = [iTools(end), iTools, iTools(1)]; if ~strcmp(sModifier, 'Shift'), iToolIndInd = iToolIndInd + 2; end iToolInd = iTools(iToolIndInd); fIconClick(SImg.hIcons(iToolInd), eventdata); end % ----------------------------------------------------------------- set(hF, 'SelectionType', 'normal'); end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fKeyPressFcn % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fContextFcn (nested in imagine) % * * % * * Menu callback % * * % * * Callback for context menu clicks % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fContextFcn(hObject, eventdata) switch get(hObject, 'Label') case 'Tolerance +50%', SState.dTolerance = SState.dTolerance.*1.5; case 'Tolerance +10%', SState.dTolerance = SState.dTolerance.*1.1; case 'Tolerance -10%', SState.dTolerance = SState.dTolerance./1.1; case 'Tolerance -50%', SState.dTolerance = SState.dTolerance./1.5; end end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fContextFcn % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fEval (nested in imagine) % * * % * * Do the evaluation of line/ROIs % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fEval(csFcns) dPos = get(SAxes.hImg(fGetPanel), 'CurrentPoint'); % ----------------------------------------------------------------- % Depending on the time series setting, eval only visible or all data if fIsOn('clock') iSeries = 1:length(SData); % Eval all series else iSeries = 1:length(SData); iSeries = iSeries(iSeries >= SState.iStartSeries & iSeries < SState.iStartSeries + length(SAxes.hImg)); end % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Get the rawdata for evaluation and the distance/area/volume csSeriesName = cell(length(iSeries), 1); cData = cell(length(iSeries), 1); dMeasures = zeros(length(iSeries), length(csFcns) + 1); csName = cell(1, length(csFcns) + 1); csUnitString = cell(1, length(csFcns) + 1); % ----------------------------------------------------------------- % Series Loop for i = 1:length(iSeries) iSeriesInd = iSeries(i); csSeriesName{i} = SData(i).sName; % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Tool dependent code switch SState.sTool case 'line' dXStart = SMouse.dAxesStartPos(1,1); dYStart = SMouse.dAxesStartPos(1,2); dXEnd = dPos(1,1); dYEnd = dPos(1,2); dDist = sqrt(((dXStart - dXEnd).*SData(iSeriesInd).dPixelSpacing(2)).^2 + ((dYStart - dYEnd).*SData(iSeriesInd).dPixelSpacing(1)).^2); if dDist < 1.0, return, end % In case of a misclick csName{1} = 'Length'; csUnitString{1} = sprintf('%s', SData(iSeriesInd).sUnits); dMeasures(i, 1) = dDist; cData{i} = improfile(fGetImg(iSeriesInd), [dXStart dXEnd], [dYStart, dYEnd], round(dDist), 'bilinear'); case {'roi', 'lw'} csName{1} = 'Area'; csUnitString{1} = sprintf('%s^2', SData(iSeriesInd).sUnits); dImg = fGetImg(iSeriesInd); lMask = poly2mask(SState.dROILineX, SState.dROILineY, size(dImg, 1), size(dImg, 2)); dMeasures(i, 1) = nnz(lMask).*SData(iSeriesInd).dPixelSpacing(2).*SData(iSeriesInd).dPixelSpacing(1); cData{i} = dImg(lMask); SData(iSeriesInd).lMask = false(size(SData(iSeriesInd).dImg)); SData(iSeriesInd).lMask(:,:,SData(iSeriesInd).iActiveImage) = lMask; fFillPanels; case 'rg' csName{1} = 'Volume'; csUnitString{1} = sprintf('%s^3', SData(iSeriesInd).sUnits); if strcmp(SState.sDrawMode, 'phase') dImg = angle(SData(iSeriesInd).dImg); else dImg = SData(iSeriesInd).dImg; if ~isreal(dImg), dImg = abs(dImg); end end if i == 1 % In the first series detrmine the tolerance and use the same tolerance in the other series [lMask, dTol] = fRegionGrowingAuto_mex(dImg, int16([dPos(1, 2); dPos(1, 1); SData(iSeriesInd).iActiveImage]), -1, SState.dTolerance); else lMask = fRegionGrowingAuto_mex(dImg, int16([dPos(1, 2); dPos(1, 1); SData(iSeriesInd).iActiveImage]), dTol); end dMeasures(i, 1) = nnz(lMask).*prod(SData(iSeriesInd).dPixelSpacing); cData{i} = dImg(lMask); SData(iSeriesInd).lMask = lMask; fFillPanels; case 'ic' csName{1} = 'Volume'; csUnitString{1} = sprintf('%s^3', SData(iSeriesInd).sUnits); if strcmp(SState.sDrawMode, 'phase') dImg = angle(SData(iSeriesInd).dImg); else dImg = SData(iSeriesInd).dImg; if ~isreal(dImg), dImg = abs(dImg); end end lMask = fIsoContour_mex(dImg, int16([dPos(1, 2); dPos(1, 1); SData(iSeriesInd).iActiveImage]), 0.5); dMeasures(i, 1) = nnz(lMask).*prod(SData(iSeriesInd).dPixelSpacing); cData{i} = dImg(lMask); SData(iSeriesInd).lMask = lMask; fFillPanels; end % End of switch SState.sTool % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Do the evaluation sEvalString = sprintf('%s = %s %s\n', csName{1}, num2str(dMeasures(i, 1)), csUnitString{1}); for iJ = 2:length(csFcns) + 1 [dMeasures(i, iJ), csName{iJ}, sUnitFormat] = eval([csFcns{iJ - 1}, '(cData{i});']); csUnitString{iJ} = sprintf(sUnitFormat, SData(iSeriesInd).sUnits); if isempty(csUnitString{iJ}), csUnitString{iJ} = ''; end sEvalString = sprintf('%s%s = %s %s\n', sEvalString, csName{iJ}, num2str(dMeasures(i, iJ)), csUnitString{iJ}); end SData(iSeriesInd).sEvalText = sEvalString(1:end-1); % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - end % End of series loop % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Plot the line profile and add name to legend % Check for presence of plot figure and create if necessary. if (fIsOn('line1') && fIsOn('clock')) || (fIsOn('line1') && ~fIsOn('clock') && strcmp(SState.sTool, 'line')) if ~ishandle(SState.hEvalFigure) SState.hEvalFigure = figure('Units', 'pixels', 'Position', [100 100 600, 400], 'NumberTitle', 'off'); axes('Parent', SState.hEvalFigure); hold on; end figure(SState.hEvalFigure); hL = findobj(SState.hEvalFigure, 'Type', 'line'); hAEval = gca; delete(hL); if fIsOn('clock') for i = 2:size(dMeasures, 2) plot(dMeasures(:,i), 'Color', SPref.dCOLORMAP(i - 1,:)); end legend(csName{2:end}); % Show legend set(SState.hEvalFigure, 'Name', 'Time Series'); set(get(hAEval, 'XLabel'), 'String', 'Time Point'); set(get(hAEval, 'YLabel'), 'String', 'Value'); else for i = 1:length(cData); plot(cData{i}, 'Color', SPref.dCOLORMAP(i,:)); end legend(csSeriesName); % Show legend set(SState.hEvalFigure, 'Name', 'Line Profile'); set(get(hAEval, 'XLabel'), 'String', sprintf('x [%s]', SData(SState.iStartSeries).sUnits)); set(get(hAEval, 'YLabel'), 'String', 'Intensity'); end end fFillPanels; % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Export to file if enabled if isempty(SState.sEvalFilename), return, end iPos = fGetEvalFilePos; if iPos < 0 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % File does not exist -> Write header fid = fopen(SState.sEvalFilename, 'w'); if fid < 0, warning('IMAGINE: Cannot write to file ''%s''!', SState.sEvalFilename); return, end if fIsOn('clock') fprintf(fid, '\n'); % First line (series names) empty fprintf(fid, ['"";"";', fPrintCell('"%s";', csName), '\n']); % The eval function names fprintf(fid, ['"";"";', fPrintCell('"%s";', csUnitString), '\n']); % The eval function names else sFormatString = ['"%s";', repmat('"";', [1, length(csName) - 1])]; fprintf(fid, ['"";"";', fPrintCell(sFormatString, csSeriesName), '\n']); fprintf(fid, ['"";"";', fPrintCell('"%s";', repmat(csName, [1, length(csSeriesName)])), '\n']); % The eval function names fprintf(fid, ['"";"";', fPrintCell('"%s";', repmat(csUnitString, [1, length(csSeriesName)])), '\n']); % The eval function names end fclose(fid); fprintf('Created file ''%s''!\n', SState.sEvalFilename); iPos = 0; % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - end % ---------------------------------------------------------------- % Write the measurements to file fid = fopen(SState.sEvalFilename, 'a'); if fid < 0, warning('IMAGINE: Cannot write to file ''%s''!', SState.sEvalFilename); return, end iPos = iPos + 1; if fIsOn('clock') fprintf(fid, '\n'); for i = 1:length(csSeriesName) fprintf(fid, '"%d";"%s";', iPos, csSeriesName{i}); if SPref.lGERMANEXPORT for iJ = 1:size(dMeasures, 2), fprintf(fid, '"%s";', strrep(num2str(dMeasures(i, iJ)), '.', ',')); end else for iJ = 1:size(dMeasures, 2), fprintf(fid, '"%s";', num2str(dMeasures(i, iJ))); end end fprintf(fid, '\n'); end else fprintf(fid, '"%d";"";', iPos); dMeasures = dMeasures'; dMeasures = dMeasures(:); if SPref.lGERMANEXPORT for i = 1:length(dMeasures), fprintf(fid, '"%s";', strrep(num2str(dMeasures(i)), '.', ',')); end else for i = 1:length(dMeasures), fprintf(fid, '"%s";', num2str(dMeasures(i))); end end fprintf(fid, '\n'); end fclose(fid); fprintf('Written to position %d in file ''%s''!\n', iPos, SState.sEvalFilename); % ----------------------------------------------------------------- end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fEval % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function sString = fPrintCell(sFormatString, csCell) sString = ''; for i = 1:length(csCell); sString = sprintf(['%s', sFormatString], sString, csCell{i}); end end function iPos = fGetEvalFilePos iPos = -1; if ~exist(SState.sEvalFilename, 'file'), return, end fid = fopen(SState.sEvalFilename, 'r'); if fid < 0, return, end iPos = 0; i = 1; sLine = fgets(fid); while ischar(sLine) csText{i} = sLine; sLine = fgets(fid); i = 1 + 1; end fclose(fid); csPos = textscan(csText{end}, '"%d"'); if ~isempty(csPos{1}), iPos = csPos{1}; end end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fChangeImage (nested in imagine) % * * % * * Change image index of all series (if linked) or all selected % * * series. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fChangeImage(hObject, iCnt) % ----------------------------------------------------------------- % Return if projection image selected or ROI drawing in progress % if strcmp(SState.sDrawMode, 'max') || strcmp(SState.sDrawMode, 'min') || SState.iROIState, return, end if SState.iROIState, return, end % ----------------------------------------------------------------- if isstruct(iCnt), iCnt = iCnt.VerticalScrollCount; end % Origin is mouse wheel if isobject(iCnt), iCnt = iCnt.VerticalScrollCount; end % Origin is mouse wheel, R2014b % ----------------------------------------------------------------- % Loop over all data (visible or not) for iSeriesInd = 1:length(SData) if (~fIsOn('link')) && (~SData(iSeriesInd).lActive), continue, end % Skip if axes not linked and current figure not active % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Calculate new image index and make sure it's not out of bounds iNewImgInd = SData(iSeriesInd).iActiveImage + iCnt; iNewImgInd = max([iNewImgInd, 1]); iNewImgInd = min([iNewImgInd, size(SData(iSeriesInd).dImg, 3)]); SData(iSeriesInd).iActiveImage = iNewImgInd; % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Update corresponding axes if necessary (visible) iAxisInd = iSeriesInd - SState.iStartSeries + 1; if (iAxisInd) > 0 && (iAxisInd <= length(SAxes.hImg)) % Update Corresponding Axis set(STexts.hImg2(iAxisInd), 'String', sprintf('%u/%u', iNewImgInd, size(SData(iSeriesInd).dImg, 3))); end end fFillPanels; % fWindowMouseHoverFcn(hObject, []); % Update the cursor value % ----------------------------------------------------------------- end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fChangeImage % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fSaveToFiles (nested in imagine) % * * % * * Save image data of selected panels to file(s) % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fSaveToFiles(sFilename, sPath) set(hF, 'Pointer', 'watch'); drawnow [~, ~, sExt] = fileparts(sFilename); if strcmp(sExt, '.gif') iImg = zeros([size(SData(1).dImg(:,:,1)), 1, length(SData)], 'uint8'); for i = 1:length(SData) if strcmp(SState.sDrawMode, 'phase') dMin = -pi; dMax = pi; else dMin = SData(1).dWindowCenter - 0.5.*SData(1).dWindowWidth; dMax = SData(1).dWindowCenter + 0.5.*SData(1).dWindowWidth; end if ~fIsOn('link1') && ~strcmp(SState.sDrawMode, 'phase') dMin = SData(i).dWindowCenter - 0.5.*SData(i).dWindowWidth; dMax = SData(i).dWindowCenter + 0.5.*SData(i).dWindowWidth; end dImg = fGetImg(i); dImg = dImg - dMin; dImg = round(dImg./(dMax - dMin).*(SAp.iCOLORMAPLENGTH - 1)) + 1; dImg(dImg < 1) = 1; dImg(dImg > SAp.iCOLORMAPLENGTH) = SAp.iCOLORMAPLENGTH; dImg = reshape(SState.dColormapBack(dImg, :), [size(iImg, 1) ,size(iImg, 2), 3]); iImg(:,:,1,i) = uint8(dImg(:,:,1).*255); end imwrite(iImg, [sPath, sFilename], 'LoopCount', Inf, 'DelayTime', 0.05); else iNSeries = fGetNVisibleSeries; dMin = SData(SState.iStartSeries).dWindowCenter - 0.5.*SData(SState.iStartSeries).dWindowWidth; dMax = SData(SState.iStartSeries).dWindowCenter + 0.5.*SData(SState.iStartSeries).dWindowWidth; for i = 1:iNSeries iSeriesInd = i + SState.iStartSeries - 1; if ~fIsOn('link1') dMin = SData(iSeriesInd).dWindowCenter - 0.5.*SData(iSeriesInd).dWindowWidth; dMax = SData(iSeriesInd).dWindowCenter + 0.5.*SData(iSeriesInd).dWindowWidth; end if strcmp(SState.sDrawMode, 'phase') dMin = -pi; dMax = pi; end switch SState.sDrawMode case {'mag', 'phase'} dImg = zeros(size(SData(iSeriesInd).dImg)); for iJ = 1:size(SData(iSeriesInd).dImg, 3); dImg(:,:,iJ) = fGetImg(iSeriesInd, iJ); end case {'min', 'max'} dImg = fGetImg(iSeriesInd); end dImg = dImg - dMin; iImg = round(dImg./(dMax - dMin).*(SAp.iCOLORMAPLENGTH - 1)) + 1; iImg(iImg < 1) = 1; iImg(iImg > SAp.iCOLORMAPLENGTH) = SAp.iCOLORMAPLENGTH; dImg = reshape(SState.dColormapBack(iImg, :), [size(iImg, 1), size(iImg, 2), size(iImg, 3), 3]); dImg = permute(dImg, [1 2 4 3]); % rgb mode dImg = dImg.*255; dImg(dImg < 0) = 0; dImg(dImg > 255) = 255; sSeriesFilename = strrep(sFilename, '%SeriesName%', SData(iSeriesInd).sName); switch SState.sDrawMode case {'mag', 'phase'} hW = waitbar(0, sprintf('Saving Stack ''%s''', SData(iSeriesInd).sName)); for iImgInd = 1:size(dImg, 4) sImgFilename = strrep(sSeriesFilename, '%ImageNumber%', sprintf('%03u', iImgInd)); imwrite(uint8(dImg(:,:,:,iImgInd)), [sPath, filesep, sImgFilename]); waitbar(iImgInd./size(dImg, 4), hW); drawnow; end close(hW); case {'max', 'min'} sImgFilename = strrep(sSeriesFilename, '%ImageNumber%', sprintf('%sProjection', SState.sDrawMode)); imwrite(uint8(dImg), [sPath, filesep, sImgFilename]); end end end set(hF, 'Pointer', 'arrow'); end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fSaveToFiles % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fSaveToFiles (nested in imagine) % * * % * * Save image data of selected panels to file(s) % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fSaveMaskToFiles(sFilename, sPath) set(hF, 'Pointer', 'watch'); drawnow expose iNSeries = fGetNVisibleSeries; for i = 1:iNSeries iSeriesInd = i + SState.iStartSeries - 1; lImg = SData(iSeriesInd).lMask; if isempty(lImg), continue, end lMask = max(max(lImg, [], 1), [], 2); dImg = double(lImg); switch nnz(lMask) case 0, continue % no mask case 1 % its a 2D mask iInd = find(lMask); sSeriesFilename = strrep(sFilename, '%SeriesName%', SData(iSeriesInd).sName); sImgFilename = strrep(sSeriesFilename, '%ImageNumber%', sprintf('%03d', iInd)); imwrite(dImg(:,:,iInd), [sPath, filesep, sImgFilename]); otherwise sSeriesFilename = strrep(sFilename, '%SeriesName%', SData(iSeriesInd).sName); for iInd = 1:size(dImg, 3) sImgFilename = strrep(sSeriesFilename, '%ImageNumber%', sprintf('%03d', iInd)); imwrite(dImg(:,:,iInd), [sPath, filesep, sImgFilename]); end end end set(hF, 'Pointer', 'arrow'); end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fSaveToFiles % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fGetImg (nested in imagine) % * * % * * Return data for view according to drawmode % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function dImg = fGetImg(iInd, iImgInd) if nargin < 2, iImgInd = SData(iInd).iActiveImage; end if strcmp(SState.sDrawMode, 'phase') dImg = angle(SData(iInd).dImg(:,:,iImgInd)); return end dImg = SData(iInd).dImg; if ~isreal(dImg), dImg = abs(dImg); end switch SState.sDrawMode case 'mag', dImg = dImg(:,:,iImgInd); case 'max' iMin = max(1, iImgInd - 3); iMax = min(size(dImg, 3), iImgInd + 3); dImg = max(dImg(:,:,iMin:iMax), [], 3); case 'min', dImg = min(dImg, [], 3); end end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fGetImg % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fSetWindow(hObject, eventdata) iAxisInd = find(SImg.hColorbar == hObject); iSeriesInd = iAxisInd + SState.iStartSeries - 1; if iSeriesInd > length(SData), return, end dMin = SData(iSeriesInd).dWindowCenter - 0.5.*SData(iSeriesInd).dWindowWidth; dMax = SData(iSeriesInd).dWindowCenter + 0.5.*SData(iSeriesInd).dWindowWidth; csVal{1} = fPrintNumber(dMin); csVal{2} = fPrintNumber(dMax); csAns = inputdlg({'Min', 'Max'}, sprintf('Change %s windowing', SData(iSeriesInd).sName), 1, csVal); if isempty(csAns), return, end csVal = textscan([csAns{1}, ' ', csAns{2}], '%f %f'); if ~isempty(csVal{1}), dMin = csVal{1}; end if ~isempty(csVal{2}), dMax = csVal{2}; end SData(iSeriesInd).dWindowCenter = (dMin + dMax)./2; SData(iSeriesInd).dWindowWidth = (dMax - dMin); fFillPanels; end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fUpdateActivation (nested in imagine) % * * % * * Set the activation and availability of some switches according to % * * the GUI state. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fUpdateActivation % ----------------------------------------------------------------- % Update states of some menubar buttons according to panel selection csLabels = {SIcons.Name}; SIcons(strcmp(csLabels, 'save')) .Enabled = fGetNActiveVisibleSeries() > 0; SIcons(strcmp(csLabels, 'doc_delete')).Enabled = fGetNActiveVisibleSeries() > 0; SIcons(strcmp(csLabels, 'exchange')) .Enabled = fGetNActiveVisibleSeries() == 2; SIcons(strcmp(csLabels, 'record')) .Enabled = isempty(SState.sEvalFilename); SIcons(strcmp(csLabels, 'stop')) .Enabled = ~isempty(SState.sEvalFilename); SIcons(strcmp(csLabels, 'rewind')) .Enabled = ~isempty(SState.sEvalFilename); % ----------------------------------------------------------------- SIcons(strcmp(csLabels, 'lw')).Enabled = exist('fLiveWireCalcP') == 3; % Compiled mex file SIcons(strcmp(csLabels, 'rg')).Enabled = exist('fRegionGrowingAuto_mex') == 3; % Compiled mex file SIcons(strcmp(csLabels, 'ic')).Enabled = exist('fIsoContour_mex') == 3; % Compiled mex file % ----------------------------------------------------------------- % Treat the menubar items dScale = ones(length(SIcons)); dScale(~[SIcons.Enabled]) = SAp.iDISABLED_SCALE; dScale( [SIcons.Enabled] & ~[SIcons.Active]) = SAp.iINACTIVE_SCALE; for i = 1:length(SIcons), set(SImg.hIcons(i), 'CData', SIcons(i).dImg.*dScale(i)); end % ----------------------------------------------------------------- % ----------------------------------------------------------------- % Treat the panels for i = 1:length(SAxes.hImg) iSeriesInd = i + SState.iStartSeries - 1; if iSeriesInd > length(SData) || ~SData(iSeriesInd).lActive set(STexts.hImg1(i), 'FontWeight', 'normal'); else set(STexts.hImg1(i), 'FontWeight', 'bold'); end end % ----------------------------------------------------------------- end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fUpdateActivation % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fGetNActiveVisibleSeries (nested in imagine) % * * % * * Returns the number of visible active series. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function iNActiveSeries = fGetNActiveVisibleSeries() iNActiveSeries = 0; if isempty(SData), return, end iStartInd = SState.iStartSeries; iEndInd = min([iStartInd + length(SAxes.hImg) - 1, length(SData)]); iNActiveSeries = nnz([SData(iStartInd:iEndInd).lActive]); end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fGetNActiveVisibleSeries % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fGetNVisibleSeries (nested in imagine) % * * % * * Returns the number of visible active series. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function iNVisibleSeries = fGetNVisibleSeries() if isempty(SData) iNVisibleSeries = 0; else iNVisibleSeries = min([length(SAxes.hImgFrame), length(SData) - SState.iStartSeries + 1]); end end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fGetNVisibleSeries % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fParseInputs (nested in imagine) % * * % * * Parse the varargin input variable. It can be either pairs of % * * data/captions or just data. Data can be either 2D, 3D or 4D. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fParseInputs(cInput) iInd = 1; iDataInd = 0; % xInput = cInput{iInd}; % if ~(isnumeric(xInput) || islogical(xInput)), error('First input must be image data of some kind!'); end % iDataInd = iDataInd + 1; % dImg = xInput; % sName = sprintf('Input_%02d', iDataInd); % dDim = [1 1 1]; % sUnits = 'px'; % dWindow = []; % lMask = []; % iInd = iInd + 1; while iInd <= length(cInput); xInput = cInput{iInd}; if ~(isnumeric(xInput) || islogical(xInput) || iscell(xInput) || ischar(xInput)), error('Argument %d expected to be either property or data!', iInd); end if isnumeric(xInput) || islogical(xInput) || iscell(xInput)% New image data if iDataInd, fAddImageToData(dImg, sName, 'startup', dDim, sUnits, dWindow, lMask, dZoom); end% Add the last Dataset iDataInd = iDataInd + 1; sName = sprintf('Input_%02d', iDataInd); dDim = [1 1 1]; dZoom = 1; sUnits = 'px'; dWindow = []; lMask = []; if iscell(xInput) iNDims = ndims(xInput{1}); xInput = xInput(:); xInput = shiftdim(xInput, -iNDims); dImg = cell2mat(xInput); else dImg = xInput; end end if ischar(xInput) iInd = iInd + 1; if iInd > length(cInput), error('Argument %d (property) must be followed by a value!', iInd - 1); end xVal = cInput{iInd}; switch lower(xInput) case {'n', 'name'} if ~ischar(xVal), error('Name property must be a string!'); end sName = xVal; case {'v', 'voxelsize'} if ~isnumeric(xVal) || numel(xVal) ~= 3, error('Voxelsize property must be a [3x1] or [1x3] numeric vector!'); end dDim = xVal; case {'z', 'zoom'} if ~isnumeric(xVal), error('Zoom property must be a numeric scalar!'); end dZoom = xVal; case {'u', 'units'} if ~ischar(xVal), error('Units property must be a string!'); end sUnits = xVal; case {'w', 'window'} if ~isnumeric(xVal) || numel(xVal) ~= 2, error('Window limits property must be a [2x1] or [1x2] numeric vector!'); end dWindow = xVal; case {'m', 'mask'} if ndims(xVal) ~= ndims(dImg), error('Mask must have same number of dimensions as the image!'); end if any(size(dImg) ~= size(xVal)), error('Mask must have same size as image'); end lMask = xVal; case {'p', 'panels'} if ~isnumeric(xVal) || numel(xVal) ~= 2, error('Panel size must be a [2x1] or [1x2] numeric vector!'); end SState.iPanels = xVal(:)'; otherwise, error('Unknown property ''%s''!', xInput); end end iInd = iInd + 1; end if iDataInd, fAddImageToData(dImg, sName, 'startup', dDim, sUnits, dWindow, lMask, dZoom); end if sum(SState.iPanels) == 0 iNumImages = length(SData); dRoot = sqrt(iNumImages); iPanelsN = ceil(dRoot); iPanelsM = ceil(dRoot); while iPanelsN*iPanelsM >= iNumImages iPanelsN = iPanelsN - 1; end iPanelsN = iPanelsN + 1; iPanelsN = min([4, iPanelsN]); iPanelsM = min([4, iPanelsM]); SState.iPanels = [iPanelsN, iPanelsM]; end end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fParseInputs % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fLoadFiles (nested in imagine) % * * % * * Load image files from disk and sort into series. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fLoadFiles(csFilenames) if ~iscell(csFilenames), csFilenames = {csFilenames}; end % If only one file lLoaded = false(length(csFilenames), 1); SImageData = []; hW = waitbar(0, 'Loading files'); for i = 1:length(csFilenames) [sPath, sName, sExt] = fileparts(csFilenames{i}); %#ok<ASGLU> switch lower(sExt) % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Standard image data: Try to group according to size case {'.jpg', '.jpeg', '.tif', '.tiff', '.gif', '.bmp', '.png'} try dImg = double(imread([SState.sPath, csFilenames{i}]))./255; lLoaded(i) = true; catch %#ok<CTCH> disp(['Error when loading "', SState.sPath, csFilenames{i}, '": File extenstion and type do not match']); continue; end dImg = mean(dImg, 3); iInd = fServesSizeCriterion(size(dImg), SImageData); if iInd dImg = cat(3, SImageData(iInd).dImg, dImg); SImageData(iInd).dImg = dImg; else iLength = length(SImageData) + 1; SImageData(iLength).dImg = dImg; SImageData(iLength).sOrigin = 'Image File'; SImageData(iLength).sName = csFilenames{i}; SImageData(iLength).dPixelSpacing = [1 1 1]; end % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % NifTy Data case '.nii' set(hF, 'Pointer', 'watch'); drawnow; [dImg, dDim] = fNifTyRead([SState.sPath, csFilenames{i}]); if ndims(dImg) > 4, error('Only 4D data supported'); end lLoaded(i) = true; fAddImageToData(dImg, csFilenames{i}, 'NifTy File', dDim, 'mm'); set(hF, 'Pointer', 'arrow'); % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - case '.gipl' set(hF, 'Pointer', 'watch'); drawnow; [dImg, dDim] = fGIPLRead([SState.sPath, csFilenames{i}]); lLoaded(i) = true; fAddImageToData(dImg, csFilenames{i}, 'GIPL File', dDim, 'mm'); set(hF, 'Pointer', 'arrow'); % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - case '.mat' csVars = fMatRead([SState.sPath, csFilenames{i}]); lLoaded(i) = true; if isempty(csVars), continue, end % Dialog aborted set(hF, 'Pointer', 'watch'); drawnow; for iJ = 1:length(csVars) S = load([SState.sPath, csFilenames{i}], csVars{iJ}); eval(['dImg = S.', csVars{iJ}, ';']); fAddImageToData(dImg, sprintf('%s in %s', csVars{iJ}, csFilenames{i}), 'MAT File'); end set(hF, 'Pointer', 'arrow'); % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - end waitbar(i/length(csFilenames), hW); end close(hW); for i = 1:length(SImageData) fAddImageToData(SImageData(i).dImg, SImageData.sName, 'Image File', [1 1 1]); end set(hF, 'Pointer', 'watch'); drawnow; SDicomData = fDICOMRead(csFilenames(~lLoaded), SState.sPath); for i = 1:length(SDicomData) fAddImageToData(SDicomData(i).dImg, SDicomData(i).SeriesDescriptions, 'DICOM', SDicomData(i).Aspect, 'mm'); end set(hF, 'Pointer', 'arrow'); end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fLoadFiles % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fAddImageToData (nested in imagine) % * * % * * Add image data to the global SDATA variable. Can handle 2D, 3D or % * * 4D data. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fAddImageToData(dImage, sName, sOrigin, dDim, sUnits, dWindow, lMask, dZoom) if nargin < 8, dZoom = 1; end if nargin < 7, lMask = []; end if nargin < 6, dWindow = []; end if nargin < 5, sUnits = 'px'; end if nargin < 4, dDim = [1 1 1]; end if islogical(dImage), dImage = ones(size(dImage)).*dImage; end dImage = double(dImage); dImage(isnan(dImage)) = 0; iInd = length(SData) + 1; iGroupIndex = 1; if ~isempty(SData) iExistingGroups = unique([SData.iGroupIndex]); if ~isempty(iExistingGroups) while nnz(iExistingGroups == iGroupIndex), iGroupIndex = iGroupIndex + 1; end end end if size(dImage, 3) == 3 SData(iInd).dImg = dImage; if ~isempty(dWindow) dMin = dWindow(1); dMax = dWindow(2); else if isreal(SData(iInd).dImg) if numel(SData(iInd).dImg) > 1E6 dMin = min(SData(iInd).dImg(1:100:end)); dMax = max(SData(iInd).dImg(1:100:end)); else dMin = min(SData(iInd).dImg(:)); dMax = max(SData(iInd).dImg(:)); end else if numel(SData(iInd).dImg) > 1E6 dMin = min(abs(SData(iInd).dImg(1:100:end))); dMax = max(abs(SData(iInd).dImg(1:100:end))); else dMin = min(abs(SData(iInd).dImg(:))); dMax = max(abs(SData(iInd).dImg(:))); end end end if dMax == dMin, dMax = dMin + 1; end SData(iInd).dDynamicRange = [dMin, dMax]; SData(iInd).sOrigin = sOrigin; SData(iInd).dWindowCenter = (dMax + dMin)./2; SData(iInd).dWindowWidth = dMax - dMin; SData(iInd).dZoomFactor = dZoom; SData(iInd).dDrawCenter = [size(SData(iInd).dImg, 1), size(SData(iInd).dImg, 2)]/2; SData(iInd).iActiveImage = max(1, round(size(SData(iInd).dImg, 3)/2)); SData(iInd).lActive = false; if dDim(end) == 0, dDim(end) = min(dDim(1:2)); end SData(iInd).dPixelSpacing = dDim(:)'; SData(iInd).sUnits = sUnits; SData(iInd).lMask = []; SData(iInd).iGroupIndex = iGroupIndex; SData(iInd).sEvalText = ''; SData(iInd).sName = sName; iInd = iInd + 1; else for i = 1:size(dImage, 4) SData(iInd).dImg = dImage(:,:,:,i); if ~isempty(dWindow) dMin = dWindow(1); dMax = dWindow(2); else if isreal(SData(iInd).dImg) if numel(SData(iInd).dImg) > 1E6 dMin = min(SData(iInd).dImg(1:100:end)); dMax = max(SData(iInd).dImg(1:100:end)); else dMin = min(SData(iInd).dImg(:)); dMax = max(SData(iInd).dImg(:)); end else if numel(SData(iInd).dImg) > 1E6 dMin = min(abs(SData(iInd).dImg(1:100:end))); dMax = max(abs(SData(iInd).dImg(1:100:end))); else dMin = min(abs(SData(iInd).dImg(:))); dMax = max(abs(SData(iInd).dImg(:))); end end end if dMax == dMin, dMax = dMin + 1; end SData(iInd).dDynamicRange = [dMin, dMax]; SData(iInd).sOrigin = sOrigin; SData(iInd).dWindowCenter = (dMax + dMin)./2; SData(iInd).dWindowWidth = dMax - dMin; SData(iInd).dZoomFactor = dZoom; SData(iInd).dDrawCenter = [size(SData(iInd).dImg, 1), size(SData(iInd).dImg, 2)]/2; SData(iInd).iActiveImage = max(1, round(size(SData(iInd).dImg, 3)/2)); SData(iInd).lActive = false; if dDim(end) == 0, dDim(end) = min(dDim(1:2)); end SData(iInd).dPixelSpacing = dDim(:)'; SData(iInd).sUnits = sUnits; if isempty(lMask) SData(iInd).lMask = []; else SData(iInd).lMask = lMask(:,:,:,i); end SData(iInd).iGroupIndex = iGroupIndex; SData(iInd).sEvalText = ''; if ndims(dImage) > 3 SData(iInd).sName = sprintf('%s_%02u', sName, i); else SData(iInd).sName = sName; end iInd = iInd + 1; end end end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fAddImageToData % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fGetPanel (nested in imagine) % * * % * * Determine the panelnumber under the mouse cursor. Returns 0 if % * * not over a panel at all. % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function iPanelInd = fGetPanel() iCursorPos = get(hF, 'CurrentPoint'); iPanelInd = uint8(0); for i = 1:min([length(SAxes.hImg), length(SData) - SState.iStartSeries + 1]) dPos = get(SAxes.hImg(i), 'Position'); if ((iCursorPos(1) >= dPos(1)) && (iCursorPos(1) < dPos(1) + dPos(3)) && ... (iCursorPos(2) >= dPos(2) + SAp.iEVALBARHEIGHT) && (iCursorPos(2) < dPos(2) + dPos(4) - SAp.iTITLEBARHEIGHT - SAp.iCOLORBARHEIGHT)) iPanelInd = uint8(i); end end end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fGetPanel % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fServesSizeCriterion (nested in imagine) % * * % * * Determines, whether the data structure contains an image series % * * with the same x- and y-dimensions as iSize % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function iInd = fServesSizeCriterion(iSize, SNewData) iInd = 0; for i = 1:length(SNewData) if (iSize(1) == size(SNewData(i).dImg, 1)) && ... (iSize(2) == size(SNewData(i).dImg, 2)) iInd = i; return; end end end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fServesSizeCriterion % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fIsOn (nested in imagine) % * * % * * Determine whether togglebutton is active % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function lOn = fIsOn(sTag) lOn = SIcons(strcmp({SIcons.Name}, sTag)).Active; end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fIsOn % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION SDataOut (nested in imagine) % * * % * * Thomas' hack function to get the data structure % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function SDataOut = fGetData SDataOut = SData; end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION SDataOut % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fPrintNumber (nested in imagine3D) % * * % * * Display a value in adequate format % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function sString = fPrintNumber(xNumber) if ((abs(xNumber) < 0.01) && (xNumber ~= 0)) || (abs(xNumber) > 1E4) sString = sprintf('%2.1E', xNumber); else sString = sprintf('%4.2f', xNumber); end end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fPrintNumber % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fReplicate (nested in imagine) % * * % * * Scale image by power of 2 by nearest neighbour interpolation % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function dImgOut = fReplicate(dImg, iIter) dImgOut = zeros(2.*size(dImg)); dImgOut(1:2:end, 1:2:end) = dImg; dImgOut(2:2:end, 1:2:end) = dImg; dImgOut(1:2:end, 2:2:end) = dImg; dImgOut(2:2:end, 2:2:end) = dImg; iIter = iIter - 1; if iIter > 0, dImgOut = fReplicate(dImgOut, iIter); end end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fReplicate % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * NESTED FUNCTION fCompileMex (nested in imagine) % * * % * * Scale image by power of 2 by nearest neighbour interpolation % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fCompileMex fprintf('Imagine will try to compile some mex files!\n'); sToolsPath = [SPref.sMFILEPATH, filesep, 'tools']; S = dir([sToolsPath, filesep, '*.cpp']); sPath = cd; cd(sToolsPath); lSucc = true; for i = 1:length(S) [temp, sName] = fileparts(S(i).name); %#ok<ASGLU> if exist(sName, 'file') == 3, continue, end try eval(['mex ', S(i).name]); catch warning('Could nor compile ''%s''!', S(i).name); lSucc = false; end end cd(sPath); if ~lSucc warndlg(sprintf('Not all mex files could be compiled, thus some tools will not be available. Try to setup the mex-compiler using ''mex -setup'' and compile the *.cpp files in the ''tools'' folder manually.'), 'IMAGINE'); else fprintf('Hey, it worked!\n'); end end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fCompileMex % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function dOut = fBlend(dBot, dTop, sMode, dAlpha) % ------------------------------------------------------------------------- % Parse the inputs if nargin < 4, dAlpha = 1.0; end % Top is fully opaque if nargin < 3, sMode = 'overlay'; end if nargin < 2, error('At least 2 input arguments required!'); end if isa(dBot, 'uint8') dBot = double(dBot); dBot = dBot./255; end if isa(dTop, 'uint8') dTop = double(dTop); dTop = dTop./255; end % ------------------------------------------------------------------------- % Check Inputs if numel(dTop) == 3 % if isscalar(dAlpha), error('If top layer is given as a color, alpha map must be supplied!'); end dTop = repmat(permute(dTop(:), [3 2 1]), [size(dAlpha) 1]); end dTopSize = [size(dTop, 1), size(dTop, 2), size(dTop, 3), size(dTop, 4)]; % Check if background is monochrome if numel(dBot) == 1 % grayscale background dBot = dBot.*ones(dTopSize); end if numel(dBot) == 3 % rgb background color dBot = repmat(permute(dBot(:), [2 3 1]), [dTopSize(1), dTopSize(2), 1, dTopSize(4)]); end dBotSize = [size(dBot, 1), size(dBot, 2), size(dBot, 3), size(dBot, 4)]; if dBotSize(3) ~= 1 && dBotSize(3) ~= 3, error('Bottom layer must be either grayscale or RGB!'); end if dTopSize(3) > 4, error('Size of 3rd top layer dimension must not exceed 4!'); end if any(dBotSize(1, 2) ~= dTopSize(1, 2)), error('Size of image data does not match'); end if dBotSize(4) ~= dTopSize(4) if dBotSize(4) > 1 && dTopSize(4) > 1, error('4th dimension of image data mismatch!'); end if dBotSize(4) == 1, dBot = repmat(dBot, [1, 1, 1, dTopSize(4)]); end if dTopSize(4) == 1, dTop = repmat(dTop, [1, 1, 1, dBotSize(4)]); end end %% Handle the alpha map if dTopSize(3) == 2 || dTopSize(3) == 4 % Alpha channel included dAlpha = dTop(:,:,end, :); dTop = dTop(:,:,1:end-1,:); else if isscalar(dAlpha) dAlpha = dAlpha.*ones(dTopSize(1), dTopSize(2), 1, dTopSize(4)); else dAlphaSize = [size(dAlpha, 1), size(dAlpha, 2), size(dAlpha, 3), size(dAlpha, 4)]; if any(dAlphaSize(1:2) ~= dTopSize(1:2)), error('Top layer alpha map dimension mismatch!'); end if dAlphaSize(3) > 1, error('3rd dimension of alpha map must have size 1!'); end if dAlphaSize(4) > 1 if dAlphaSize(4) ~= dTopSize(4), error('Alpha map dimension mismatch!'); end else dAlpha = repmat(dAlpha, [1, 1, 1, dTopSize(4)]); end end end % Bring data into the right format dMaxDim = max([size(dBot, 3), size(dTop, 3)]); if dMaxDim > 2, lRGB = true; else lRGB = false; end if lRGB && dBotSize(3) == 1, dBot = repmat(dBot, [1, 1, 3, 1]); end if lRGB && dTopSize(3) == 1, dTop = repmat(dTop, [1, 1, 3, 1]); end if lRGB, dAlpha = repmat(dAlpha, [1, 1, 3, 1]); end % Check Range dBot = fCheckRange(dBot); dTop = fCheckRange(dTop); dAlpha = fCheckRange(dAlpha); % Do the blending switch lower(sMode) case 'normal', dOut = dTop; case 'multiply', dOut = dBot.*dTop; case 'screen', dOut = 1 - (1 - dBot).*(1 - dTop); case 'overlay' lMask = dBot < 0.5; dOut = 1 - 2.*(1 - dBot).*(1 - dTop); dOut(lMask) = 2.*dBot(lMask).*dTop(lMask); case 'hard_light' lMask = dTop < 0.5; dOut = 1 - 2.*(1 - dBot).*(1 - dTop); dOut(lMask) = 2.*dBot(lMask).*dTop(lMask); case 'soft_light', dOut = (1 - 2.*dTop).*dBot.^2 + 2.*dTop.*dBot; % pegtop case 'darken', dOut = min(cat(4, dTop, dBot), [], 4); case 'lighten', dOut = max(cat(4, dTop, dBot), [], 4); otherwise, error('Unknown blend mode ''%s''!', sMode); end dOut = dAlpha.*dOut + (1 - dAlpha).*dBot; dOut(dOut > 1) = 1; dOut(dOut < 0) = 0; end function dData = fCheckRange(dData) dData(dData < 0) = 0; dData(dData > 1) = 1; end end % ========================================================================= % *** END FUNCTION imagine (and its nested functions) % ========================================================================= % ######################################################################### % *** % *** Helper GUIS and their callbacks % *** % ######################################################################### % ========================================================================= % *** FUNCTION fGridSelect % *** % *** Creates a tiny GUI to select the GUI layout, i.e. the number of % *** panels and the grid dimensions. % *** % ========================================================================= function iSizeOut = fGridSelect(iM, iN) iGRIDSIZE = 30; iSizeOut = [0 0]; % ------------------------------------------------------------------------- % Create a new figure at the current mouse pointer position iPos = get(0, 'PointerLocation'); hGridFig = figure(... 'Position' , [iPos(1), iPos(2) - iGRIDSIZE*iM, iGRIDSIZE*iN, iGRIDSIZE*iM], ... 'Units' , 'pixels', ... 'DockControls' , 'off', ... 'WindowStyle' , 'modal', ... 'Name' , '', ... 'WindowButtonMotionFcn' , @fGridMouseMoveFcn, ... 'WindowButtonDownFcn' , 'uiresume(gcbf)', ... % continues the execution of this function after the uiwait when the mousebutton is pressed 'NumberTitle' , 'off', ... 'Resize' , 'off', ... 'Colormap' , [0.2 0.3 0.4; ... 0.3 0.4 0.5], ... 'Visible' , 'off'); hA = axes(... 'Units' , 'normalized', ... 'Position' , [0 0 1 1], ... 'Parent' , hGridFig, ... 'XLim' , [0 iM] + 0.5, ... 'YLim' , [0 iN] + 0.5, ... 'YDir' , 'reverse', ... 'XGrid' , 'on', ... 'YGrid' , 'on', ... 'Layer' , 'top', ... 'XTick' , (1:iN) + 0.5, ... 'YTick' , (1:iM) + 0.5, ... 'TickLength', [0 0]); hI = image(... 'CData' , zeros(iM, iN, 'uint8'), ... 'CDataMapping' , 'direct'); set(hGridFig, 'Visible', 'on'); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Handle GUI interaction uiwait(hGridFig); % Wait until the uiresume function is called (happens when mouse button is pressed, see creation of the figure above) try % Button was pressed, return the amount of selected panels delete(hGridFig); % close the figure catch %#ok<CTCH> % if figure could not be deleted (dialog aborted), return [0 0] iSizeOut = [0 0]; end % ------------------------------------------------------------------------- % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fGridMouseMoveFcn (nested in fGridSelect) % * * % * * Determine whether axes are linked % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fGridMouseMoveFcn(hObject, eventdata) dCursorPos = get(hA, 'CurrentPoint'); iSizeOut = round(dCursorPos(1, 2:-1:1)); dCData = zeros(iM, iN, 'uint8'); dCData(1:iSizeOut(1), 1:iSizeOut(2)) = 1; set(hI, 'CData', dCData); drawnow update end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fGridMouseMoveFcn % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = end % ========================================================================= % *** END FUNCTION fGridSelect (and its nested functions) % ========================================================================= % ========================================================================= % *** FUNCTION fColormapSelect % *** % *** Creates a tiny GUI to select the colormap. % *** % ========================================================================= function sColormap = fColormapSelect(hText) iWIDTH = 128; iBARHEIGHT = 32; % ------------------------------------------------------------------------- % List the MATLAB built-in colormaps csColormaps = {'gray', 'bone', 'copper', 'pink', 'hot', 'jet', 'hsv', 'cool'}; iNColormaps = length(csColormaps); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Add custom colormaps (if any) sColormapPath = [fileparts(mfilename('fullpath')), filesep, 'colormaps']; SDir = dir([sColormapPath, filesep, '*.m']); for iI = 1:length(SDir) iNColormaps = iNColormaps + 1; [sPath, sName] = fileparts(SDir(iI).name); %#ok<ASGLU> csColormaps{iNColormaps} = sName; end % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Create a new figure at the current mouse pointer position iPos = get(0, 'PointerLocation'); iHeight = iNColormaps.*iBARHEIGHT; hColormapFig = figure(... 'Position' , [iPos(1), iPos(2) - iHeight, iWIDTH, iHeight], ... 'WindowStyle' , 'modal', ... 'Name' , '', ... 'WindowButtonMotionFcn', @fColormapMouseMoveFcn, ... 'WindowButtonDownFcn' , 'uiresume(gcbf)', ... % continues the execution of this function after the uiwait when the mousebutton is pressed 'NumberTitle' , 'off', ... 'Resize' , 'off'); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Make the true-color image with the colormaps dImg = zeros(iNColormaps, iWIDTH, 3); dLine = zeros(iWIDTH, 3); for iI = 1:iNColormaps eval(['dLine = ', csColormaps{iI}, '(iWIDTH);']); dImg(iI, :, :) = permute(dLine, [3, 1, 2]); end % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Create axes and image for selection hA = axes(... 'Units' , 'pixels', ... 'Position' , [1, 1, iWIDTH, iHeight], ... 'Parent' , hColormapFig, ... 'Color' , 'w', ... 'XLim' , [0.5 128.5], ... 'YLim' , [0.5 length(csColormaps) + 0.5]); image(dImg, 'Parent', hA); axis(hA, 'off'); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Handle GUI interaction iLastInd = 0; uiwait(hColormapFig); % Wait until the uiresume function is called (happens when mouse button is pressed, see creation of the figure above) try % Button was pressed, return the amount of selected panels dPos = get(hA, 'CurrentPoint'); iInd = round(dPos(1, 2)); sColormap = csColormaps{iInd}; delete(hColormapFig); % close the figure catch %#ok<CTCH> % if figure could not be deleted (dialog aborted), return [0 0] sColormap = 'gray'; end % ------------------------------------------------------------------------- % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fColormapMouseMoveFcn (nested in fColormapSelect) % * * % * * Determine whether axes are linked % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fColormapMouseMoveFcn(hObject, eventdata) % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Determine over which colormap the mouse pointer is located dPos = get(hA, 'CurrentPoint'); iInd = round(dPos(1, 2)); % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Update the figure's colormap if desired if iInd ~= iLastInd set(hText, 'String', csColormaps{iInd}); iLastInd = iInd; end % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fColormapMouseMoveFcn % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = end % ========================================================================= % *** END FUNCTION fColormapSelect (and its nested functions) % ========================================================================= % ========================================================================= % *** FUNCTION fSelectEvalFcns % *** % *** Lets the user select the eval functions for evaluation % *** % ========================================================================= function csFcns = fSelectEvalFcns(csActive, sPath) iFIGUREWIDTH = 300; iFIGUREHEIGHT = 400; iBUTTONHEIGHT = 24; csFcns = 0; iPos = get(0, 'ScreenSize'); SDir = dir([sPath, filesep, '*.m']); lActive = false(length(SDir), 1); csNames = cell(length(SDir), 1); for iI = 1:length(SDir) csNames{iI} = SDir(iI).name(1:end-2); for iJ = 1:length(csActive); if strcmp(csNames{iI}, csActive{iJ}), lActive(iI) = true; end end end % ------------------------------------------------------------------------- % Create figure and GUI elements hF = figure( ... 'Position' , [(iPos(3) - iFIGUREWIDTH)/2, (iPos(4) - iFIGUREHEIGHT)/2, iFIGUREWIDTH, iFIGUREHEIGHT], ... 'WindowStyle' , 'modal', ... 'Name' , 'Select Eval Functions...', ... 'NumberTitle' , 'off', ... 'KeyPressFcn' , @SelectEvalCallback, ... 'Resize' , 'off'); hList = uicontrol(hF, ... 'Style' , 'listbox', ... 'Position' , [1 iBUTTONHEIGHT + 1 iFIGUREWIDTH iFIGUREHEIGHT - iBUTTONHEIGHT], ... 'String' , csNames, ... 'Min' , 0, ... 'Max' , 2, ... 'Value' , find(lActive), ... 'KeyPressFcn' , @SelectEvalCallback, ... 'Callback' , @SelectEvalCallback); hButOK = uicontrol(hF, ... 'Style' , 'pushbutton', ... 'Position' , [1 1 iFIGUREWIDTH/2 iBUTTONHEIGHT], ... 'Callback' , @SelectEvalCallback, ... 'String' , 'OK'); uicontrol(hF, ... 'Style' , 'pushbutton', ... 'Position' , [iFIGUREWIDTH/2 + 1 1 iFIGUREWIDTH/2 iBUTTONHEIGHT], ... 'Callback' , 'uiresume(gcf);', ... 'String' , 'Cancel'); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Set default action and enable gui interaction sAction = 'Cancel'; uiwait(hF); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % uiresume was triggered (in fMouseActionFcn) -> return if strcmp(sAction, 'OK') iList = get(hList, 'Value'); csFcns = cell(length(iList), 1); for iI = 1:length(iList) csFcns(iI) = csNames(iList(iI)); end end try %#ok<TRYNC> close(hF); end % ------------------------------------------------------------------------- % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION SelectEvalCallback (nested in fSelectEvalFcns) % * * % * * Determine whether axes are linked % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function SelectEvalCallback(hObject, eventdata) if isfield(eventdata, 'Key') switch eventdata.Key case 'escape', uiresume(hF); case 'return' sAction = 'OK'; uiresume(hF); end end % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % React on action depending on its source component switch(hObject) case hList if strcmp(get(hF, 'SelectionType'), 'open') sAction = 'OK'; uiresume(hF); end case hButOK sAction = 'OK'; uiresume(hF); otherwise end % End of switch statement % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION SelectEvalCallback % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = end % ========================================================================= % *** END FUNCTION fSelectEvalFcns (and its nested functions) % =========================================================================
github
jacksky64/imageProcessing-master
fMatRead.m
.m
imageProcessing-master/matlab imagine/imagine_2016/import/fMatRead.m
5,941
utf_8
2813566ac29fd2282b28bc24f561112e
% ========================================================================= % *** FUNCTION fMatRead % *** % *** Lets the user select one or multiple variables from the base % *** workspace for import into imagine % *** % ========================================================================= function csVarOut = fMatRead(sFilename) iFIGUREWIDTH = 300; iFIGUREHEIGHT = 400; iBUTTONHEIGHT = 24; csVarOut = {}; iPos = get(0, 'ScreenSize'); % ------------------------------------------------------------------------- % Get variables in the mat file set(gcf, 'Pointer', 'watch'); drawnow SInfo = whos('-file', sFilename); set(gcf, 'Pointer', 'arrow'); csNames = {}; csNamesDims = {}; for iI = 1:length(SInfo) if length(SInfo(iI).size) < 2 || length(SInfo(iI).size) > 4, continue, end if strcmp(SInfo(iI).class, 'struct') || ... strcmp(SInfo(iI).class, 'cell') continue end csNames{iI} = SInfo(iI).name; sString = sprintf('%s (%s', SInfo(iI).name, sprintf('%ux', SInfo(iI).size)); sString = [sString(1:end-1), ')']; csNamesDims{iI} = sString; end % ------------------------------------------------------------------------- if isempty(csNames) fprintf('fMatRead: No matching variables stored in ''%s''\n!', sFilename); return end if length(csNames) == 1 csVarOut(1) = csNames(1); return end % ------------------------------------------------------------------------- % Create figure and GUI elements hF = figure( ... 'Position' , [(iPos(3) - iFIGUREWIDTH)/2, (iPos(4) - iFIGUREHEIGHT)/2, iFIGUREWIDTH, iFIGUREHEIGHT], ... 'Units' , 'pixels', ... 'DockControls' , 'off', ... 'WindowStyle' , 'modal', ... 'Name' , 'Load variables from mat-File...', ... 'NumberTitle' , 'off', ... 'KeyPressFcn' , @fMatMouseActionFcn, ... 'Resize' , 'off'); hList = uicontrol(hF, ... 'Style' , 'listbox', ... 'Units' , 'pixels', ... 'Position' , [1 iBUTTONHEIGHT + 1 iFIGUREWIDTH iFIGUREHEIGHT - iBUTTONHEIGHT], ... 'HitTest' , 'on', ... 'Min' , 0, ... 'Max' , 2, ... 'String' , csNamesDims, ... 'KeyPressFcn' , @fMatMouseActionFcn, ... 'Callback' , @fMatMouseActionFcn); hButOK = uicontrol(hF, ... 'Style' , 'pushbutton', ... 'Units' , 'pixels', ... 'Position' , [1 1 iFIGUREWIDTH/2 iBUTTONHEIGHT], ... 'Callback' , @fMatMouseActionFcn, ... 'HitTest' , 'on', ... 'String' , 'OK'); hButCancel = uicontrol(hF, ... 'Style' , 'pushbutton', ... 'Units' , 'pixels', ... 'Position' , [iFIGUREWIDTH/2 + 1 1 iFIGUREWIDTH/2 iBUTTONHEIGHT], ... 'Callback' , 'uiresume(gcf);', ... 'HitTest' , 'on', ... 'String' , 'Cancel'); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Set default action and enable gui interaction sAction = 'Cancel'; uiwait(hF); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % uiresume was triggered (in fMouseActionFcn) -> return if strcmp(sAction, 'OK') iList = get(hList, 'Value'); csVarOut = cell(length(iList), 1); for iI = 1:length(iList) csVarOut(iI) = csNames(iList(iI)); end end close(hF); % ------------------------------------------------------------------------- % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fMatMouseActionFcn (nested in fGetMatFileVar) % * * % * * Determine whether axes are linked % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fMatMouseActionFcn(hObject, eventdata) if isfield(eventdata, 'Key') switch eventdata.Key case 'escape', uiresume(hF); case 'return' sAction = 'OK'; uiresume(hF); end end % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % React on action depending on its source component switch(hObject) % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Click in LISBOX: return if double-clicked case hList if strcmp(get(hF, 'SelectionType'), 'open') sAction = 'OK'; uiresume(hF); end % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % OK button case hButOK sAction = 'OK'; uiresume(hF); % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - otherwise end % End of switch statement % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fMatMouseActionFcn % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = end % ========================================================================= % *** END FUNCTION fMatRead (and its nested functions) % =========================================================================
github
jacksky64/imageProcessing-master
fWSImport.m
.m
imageProcessing-master/matlab imagine/imagine_2016/import/fWSImport.m
5,071
utf_8
1a1a9b39e2ced78065ea7a3ae96d8df3
% ========================================================================= % *** FUNCTION fWSImport % *** % *** Lets the user select one or multiple variables from the base % *** workspace for import into imagine % *** % ========================================================================= function csVarOut = fWSImport() iFIGUREWIDTH = 300; iFIGUREHEIGHT = 400; iBUTTONHEIGHT = 24; csVarOut = {}; iPos = get(0, 'ScreenSize'); % ------------------------------------------------------------------------- % Create figure and GUI elements hF = figure( ... 'Position' , [(iPos(3) - iFIGUREWIDTH)/2, (iPos(4) - iFIGUREHEIGHT)/2, iFIGUREWIDTH, iFIGUREHEIGHT], ... 'Units' , 'pixels', ... 'DockControls' , 'off', ... 'WindowStyle' , 'modal', ... 'Name' , 'Load workspace variable...', ... 'NumberTitle' , 'off', ... 'KeyPressFcn' , @fMouseActionFcn, ... 'Resize' , 'off'); csVars = evalin('base', 'who'); hList = uicontrol(hF, ... 'Style' , 'listbox', ... 'Units' , 'pixels', ... 'Position' , [1 iBUTTONHEIGHT + 1 iFIGUREWIDTH iFIGUREHEIGHT - iBUTTONHEIGHT], ... 'HitTest' , 'on', ... 'String' , csVars, ... 'Min' , 0, ... 'Max' , 2, ... 'KeyPressFcn' , @fMouseActionFcn, ... 'Callback' , @fMouseActionFcn); hButOK = uicontrol(hF, ... 'Style' , 'pushbutton', ... 'Units' , 'pixels', ... 'Position' , [1 1 iFIGUREWIDTH/2 iBUTTONHEIGHT], ... 'Callback' , @fMouseActionFcn, ... 'HitTest' , 'on', ... 'String' , 'OK'); hButCancel = uicontrol(hF, ... 'Style' , 'pushbutton', ... 'Units' , 'pixels', ... 'Position' , [iFIGUREWIDTH/2 + 1 1 iFIGUREWIDTH/2 iBUTTONHEIGHT], ... 'Callback' , 'uiresume(gcf);', ... 'HitTest' , 'on', ... 'String' , 'Cancel'); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % Set default action and enable gui interaction sAction = 'Cancel'; uiwait(hF); % ------------------------------------------------------------------------- % ------------------------------------------------------------------------- % uiresume was triggered (in fMouseActionFcn) -> return if strcmp(sAction, 'OK') iList = get(hList, 'Value'); csVarOut = cell(length(iList), 1); for iI = 1:length(iList) csVarOut(iI) = csVars(iList(iI)); end end try close(hF); catch %#ok<CTCH> csVarOut = {}; end % ------------------------------------------------------------------------- % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * % * * NESTED FUNCTION fMouseActionFcn (nested in fGetWorkspaceVar) % * * % * * Determine whether axes are linked % * * % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = function fMouseActionFcn(hObject, eventdata) if isfield(eventdata, 'Key') switch eventdata.Key case 'escape', uiresume(hF); case 'return' sAction = 'OK'; uiresume(hF); end end % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % React on action depending on its source component switch(hObject) % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % Click in LISBOX: return if double-clicked case hList if strcmp(get(hF, 'SelectionType'), 'open') sAction = 'OK'; uiresume(hF); end % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % OK button case hButOK sAction = 'OK'; uiresume(hF); % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - otherwise end % End of switch statement % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - end % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % * * END NESTED FUNCTION fGridMouseMoveFcn % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = end % ========================================================================= % *** END FUNCTION fWSImport (and its nested functions) % =========================================================================
github
jacksky64/imageProcessing-master
viewer3d.m
.m
imageProcessing-master/Matlab Viewer3D/viewer3d.m
242,127
utf_8
54313e095ad9115e782e9c7c86fd600b
function varargout = viewer3d(varargin) % VIEWER3D is a Matlab GUI for fast shearwarp volume rendering. It also % allows segmentation and measurements in the imagedata. % % % Just start with % VIEWER3D % % Or to display one or more matlab volumes % % VIEWER3D(V); VIEWER3D(V1,V2,V3 ....); % % % inputs, % V : 2D, 3D or 4D Input image, of type double, single, uint8, % uint16, uint32, int8, int16 or int32 % (the render process uses only double calculations) % % example, % % Load data % load('ExampleData\CommandlineData.mat'); % viewer3d(V); % % See also: render % % Function is written by D.Kroon University of Twente (January 2008 - January 2011) % Edit the above text to modify the response to help viewer3ds % Last Modified by GUIDE v2.5 12-Jan-2011 14:34:37 % Begin initialization code - DO NOT EDIT gui_Singleton = 0; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d is made visible. function viewer3d_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d (see VARARGIN) % Choose default command line output for viewer3d handles.output = hObject; % Update handles structure guidata(hObject, handles); % addpath mexcode and help functiondir=getFunctionFolder(); addpath(functiondir); addpath([functiondir '/Help']); addpath([functiondir '/ReadData3D']); addpath(genpath([functiondir '/SubFunctions'])); data.Menu=showmenu(hObject); % Store handles to the figure menu for i=1:length(data.Menu) z2=data.Menu(i); data.handles.(z2.Tag)=z2.Handle; if(isfield(z2,'Children')&&~isempty(z2.Children)) for j=1:length(z2.Children) z3=z2.Children(j); data.handles.(z3.Tag)=z3.Handle; end end end data.handles.figure1=hObject; % Disable warning warning('off', 'MATLAB:maxNumCompThreads:Deprecated') data.mouse.pressed=false; data.mouse.button='arrow'; data.mouse.action=''; % Save the default config filename_config=[functiondir '/default_config.mat']; if(exist(filename_config,'file')) load(filename_config,'config') data.config=config; else data.config.VolumeScaling=100; data.config.VolumeSize=32; data.config.ImageSizeRender=400; data.config.PreviewVolumeSize=32; data.config.ShearInterpolation= 'bilinear'; data.config.WarpInterpolation= 'bilinear'; data.config.PreRender= 0; data.config.StoreXYZ=0; end % Check if history information is present from a previous time historyfile=[functiondir '/lastfiles.mat']; if(exist(historyfile,'file')), load(historyfile); data.history=history; else for i=1:5, data.history.filenames{i}=''; end end data.history.historyfile=historyfile; data.rendertypes(1).label='None'; data.rendertypes(1).type='black'; data.rendertypes(2).label='View X slice'; data.rendertypes(2).type='slicex'; data.rendertypes(3).label='View Y slice'; data.rendertypes(3).type='slicey'; data.rendertypes(4).label='View Z slice'; data.rendertypes(4).type='slicez'; data.rendertypes(5).label='MIP'; data.rendertypes(5).type='mip'; data.rendertypes(6).label='Greyscale'; data.rendertypes(6).type='vr'; data.rendertypes(7).label='Color'; data.rendertypes(7).type='vrc'; data.rendertypes(8).label='Shaded'; data.rendertypes(8).type='vrs'; data.figurehandles.viewer3d=gcf; data.figurehandles.histogram=[]; data.figurehandles.console=[]; data.figurehandles.voxelsize=[]; data.figurehandles.lightvector=[]; data.figurehandles.contrast=[]; data.figurehandles.qualityspeed=[]; data.volumes=[]; data.substorage=[]; data.axes_select=[]; data.volume_select=[]; data.subwindow=[]; data.NumberWindows=0; data.MenuVolume=[]; data=loadmousepointershapes(data); data.NumberWindows=1; data=addWindows(data); setMyData(data); showhistory(data); allshow3d(false,true); % Get input voxel volume and convert to double if (~isempty(varargin)), if(ndims(varargin{1})>=2) for i=1:length(varargin); V=varargin{i}; volumemax=double(max(V(:))); volumemin=double(min(V(:))); info=struct; info.WindowWidth=volumemax-volumemin; info.WindowLevel=0.5*(volumemax+volumemin); if(isnumeric(V)), addVolume(V,[1 1 1],info); end end else error('viewer3d:inputs', 'Input image not 3 dimensional'); end end function addVolume(V,Scales,Info,Editable) if(nargin<2), Scales=[1 1 1]; end if(nargin<3), Info=[]; end if(nargin<4), Editable=false; end data=getMyData(); if(isempty(data)), return, end for i=1:size(V,4) data=addOneVolume(data,V(:,:,:,i),Scales,Info,Editable); end data=addWindowsMenus(data); setMyData(data); addMenuVolume(); function data=addOneVolume(data,V,Scales,Info,Editable) nv=length(data.volumes)+1; data.volumes(nv).Editable=Editable; data.volumes(nv).WindowWidth=1; data.volumes(nv).WindowLevel=0.5; data.volumes(nv).volume_original=V; data.volumes(nv).volume_scales=[1 1 1]; data.volumes(nv).info=Info; data.volumes(nv).id=rand; data.volumes(nv).Scales=Scales; if(ndims(V)==2) data.volumes(nv).Size_original=[size(V) 1]; else data.volumes(nv).Size_original=size(V); end name=['Volume ' num2str(nv)]; while(~isempty(structfind(data.volumes,'name',name))) name=['Volume ' num2str(round(rand*10000))]; end data.volumes(nv).name=name; data.volumes(nv).MeasureList=[]; data.volumes(nv).histogram_pointselected=[]; data=checkvolumetype(data,nv); data=makeVolumeXY(data,nv); data=computeNormals(data,nv); data=makePreviewVolume(data,nv); data=makeRenderVolume(data,nv); if(~isempty(Info)), if(isfield(Info,'WindowWidth')); data.volumes(nv).WindowWidth=Info.WindowWidth; end if (isfield(Info,'WindowCenter')); data.volumes(nv).WindowLevel=Info.WindowCenter; end if (isfield(Info,'WindowLevel')); data.volumes(nv).WindowLevel=Info.WindowLevel; end end data.volumes(nv).histogram_positions = [0 0.2 0.4 0.6 1]; data.volumes(nv).histogram_positions= data.volumes(nv).histogram_positions*(data.volumes(nv).volumemax-data.volumes(nv).volumemin)+data.volumes(nv).volumemin; data.volumes(nv).histogram_alpha = [0 0.03 0.1 0.35 1]; data.volumes(nv).histogram_colors= [0 0 0; 0.7 0 0; 1 0 0; 1 1 0; 1 1 1]; data=createAlphaColorTable(nv,data); function data=makePreviewVolume(data,dvs) if(data.config.PreviewVolumeSize==100) data.volumes(dvs).volume_preview=data.volumes(dvs).volume_original; else t=data.config.PreviewVolumeSize; data.volumes(dvs).volume_preview=imresize3d(data.volumes(dvs).volume_original,[],[t t t],'linear'); end if(ndims(data.volumes(dvs).volume_preview)==2) data.volumes(dvs).Size_preview=[size(data.volumes(dvs).volume_preview) 1]; else data.volumes(dvs).Size_preview=size(data.volumes(dvs).volume_preview); end function functiondir=getFunctionFolder() functionname='viewer3d.m'; functiondir=which(functionname); functiondir=functiondir(1:end-length(functionname)); function data=makeRenderVolume(data,dvs) if(data.config.VolumeScaling==100) data.volumes(dvs).volume=data.volumes(dvs).volume_original; else data.volumes(dvs).volume=imresize3d(data.volumes(dvs).volume_original,data.config.VolumeScaling/100,[],'linear'); end if(ndims(data.volumes(dvs).volume)==2) data.volumes(dvs).Size=[size(data.volumes(dvs).volume) 1]; else data.volumes(dvs).Size=size(data.volumes(dvs).volume); end function data=createAlphaColorTable(i,data) % This function creates a Matlab colormap and alphamap from the markers if(nargin<2) data=getMyData(); if(isempty(data)), return, end end if(nargin>0), dvs=i; else dvs=data.volume_select; end check=~isfield(data.volumes(dvs),'histogram_positions'); if(~check), check=isempty(data.volumes(dvs).histogram_positions); end if(check) data.volumes(dvs).histogram_positions = [0 0.2 0.4 0.6 1]; data.volumes(dvs).histogram_positions= data.volumes(dvs).histogram_positions*(data.volumes(dvs).volumemax-data.volumes(dvs).volumemin)+data.volumes(dvs).volumemin; data.volumes(dvs).histogram_alpha = [0 0.03 0.1 0.35 1]; data.volumes(dvs).histogram_colors= [0 0 0; 0.7 0 0; 1 0 0; 1 1 0; 1 1 1]; setMyData(data); end histogram_positions=data.volumes(dvs).histogram_positions; data.volumes(dvs).colortable=zeros(1000,3); data.volumes(dvs).alphatable=zeros(1000,1); % Loop through all 256 color/alpha indexes i=linspace(data.volumes(dvs).volumemin,data.volumes(dvs).volumemax,1000); for j=1:1000 if (i(j)< histogram_positions(1)), alpha=0; color=data.volumes(dvs).histogram_colors(1,:); elseif(i(j)> histogram_positions(end)), alpha=0; color=data.volumes(dvs).histogram_colors(end,:); elseif(i(j)==histogram_positions(1)), alpha=data.volumes(dvs).histogram_alpha(1); color=data.volumes(dvs).histogram_colors(1,:); elseif(i(j)==histogram_positions(end)), alpha=data.volumes(dvs).histogram_alpha(end); color=data.volumes(dvs).histogram_colors(end,:); else % Linear interpolate the color and alpha between markers index_down=find(histogram_positions<=i(j)); index_down=index_down(end); index_up =find(histogram_positions>i(j) ); index_up=index_up(1); perc= (i(j)-histogram_positions(index_down)) / (histogram_positions(index_up) - histogram_positions(index_down)); color=(1-perc)*data.volumes(dvs).histogram_colors(index_down,:)+perc*data.volumes(dvs).histogram_colors(index_up,:); alpha=(1-perc)*data.volumes(dvs).histogram_alpha(index_down)+perc*data.volumes(dvs).histogram_alpha(index_up); end data.volumes(dvs).colortable(j,:)=color; data.volumes(dvs).alphatable(j)=alpha; end if(nargin<2) setMyData(data); end function data=loadmousepointershapes(data) I=[0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0; 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0; 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0; 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0; 0 0 1 0 0 0 1 1 1 1 0 0 0 0 0 0; 0 1 1 1 1 1 0 1 0 0 1 1 1 1 1 1; 1 1 1 1 0 0 0 1 0 0 0 0 0 0 1 1; 1 1 1 1 0 0 0 1 0 0 0 0 0 1 1 1; 1 0 0 0 0 0 0 0 1 0 1 0 0 0 1 1; 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1; 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0; 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0]; I(I==0)=NaN; data.icons.icon_mouse_rotate1=I; I=[1 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0; 1 1 0 1 1 1 1 1 1 1 1 1 1 0 0 0; 1 1 1 1 1 1 0 0 0 0 0 1 1 1 0 0; 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0; 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0; 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0; 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 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0 0 1 1 0 0; 1 0 0 1 1 1 1 1 1 1 1 1 0 0 1 0; 0 1 1 0 0 0 0 1 0 0 0 0 1 1 0 0; 0 0 1 1 0 0 0 1 0 0 0 1 1 0 0 0; 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0; 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0; 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0; 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; I(I==0)=NaN; data.icons.icon_mouse_pan=I; function allshow3d(preview,render_new_image) data=getMyData(); if(isempty(data)), return, end for i=1:data.NumberWindows show3d(preview,render_new_image,i); end function show3d(preview,render_new_image,wsel) data=getMyData(); if(isempty(data)), return, end tic; if(nargin<3) wsel=data.axes_select; else data.axes_select=wsel; end dvss=structfind(data.volumes,'id',data.subwindow(wsel).volume_id_select(1)); nvolumes=length(data.subwindow(wsel).volume_id_select); if(isempty(dvss)), data.subwindow(wsel).render_type='black'; datarender.RenderType='black'; datarender.ImageSize=[data.config.ImageSizeRender data.config.ImageSizeRender]; datarender.imin=0; datarender.imax=1; renderimage = render(zeros(3,3,3),datarender); data.subwindow(wsel).render_image(1).image=renderimage; else if(render_new_image) for i=1:nvolumes dvss=structfind(data.volumes,'id',data.subwindow(wsel).volume_id_select(i)); data.subwindow(wsel).render_image(i).image=MakeRenderImage(data,dvss,wsel,preview); end end if(nvolumes==1), combine='trans'; else combine=data.subwindow(wsel).combine; end for i=1:nvolumes dvss=structfind(data.volumes,'id',data.subwindow(wsel).volume_id_select(i)); renderimage1=LevelRenderImage(data.subwindow(wsel).render_image(i).image,data,dvss,wsel); if(i==1) switch(combine) case 'trans' renderimage=renderimage1; case 'rgb' renderimage=zeros([size(renderimage1,1) size(renderimage1,2) 3]); renderimage(:,:,i)=mean(renderimage1,3); end else switch(combine) case 'trans' renderimage=renderimage+renderimage1; case 'rgb' renderimage(:,:,i)=mean(renderimage1,3); end end end switch(combine) case 'trans' if(nvolumes>1), renderimage=renderimage*(1/nvolumes); end end end data.subwindow(wsel).total_image=renderimage; % Add position information etc. to the rendered image data=InfoOnScreen(data); data=showMeasureList(data); % To range data.subwindow(wsel).total_image(data.subwindow(wsel).total_image<0)=0; data.subwindow(wsel).total_image(data.subwindow(wsel).total_image>1)=1; if(data.subwindow(wsel).first_render) data.subwindow(wsel).imshow_handle=imshow(data.subwindow(wsel).total_image,'Parent',data.subwindow(wsel).handles.axes); drawnow('expose') data.subwindow(wsel).first_render=false; else set(data.subwindow(wsel).imshow_handle,'Cdata',data.subwindow(wsel).total_image); end data.subwindow(wsel).axes_size=get(data.subwindow(wsel).handles.axes,'PlotBoxAspectRatio'); set(get(data.subwindow(wsel).handles.axes,'Children'),'ButtonDownFcn','viewer3d(''axes_ButtonDownFcn'',gcbo,[],guidata(gcbo))'); data=console_addline(data,['Render Time : ' num2str(toc)]); setMyData(data); function renderimage=MakeRenderImage(data,dvss,wsel,preview) datarender=struct(); datarender.ImageSize=[data.config.ImageSizeRender data.config.ImageSizeRender]; datarender.imin=data.volumes(dvss).volumemin; datarender.imax=data.volumes(dvss).volumemax; switch data.subwindow(wsel).render_type case 'mip' datarender.RenderType='mip'; datarender.ShearInterp=data.config.ShearInterpolation; datarender.WarpInterp=data.config.WarpInterpolation; case 'vr' datarender.RenderType='bw'; datarender.AlphaTable=data.volumes(dvss).alphatable; datarender.ShearInterp=data.config.ShearInterpolation; datarender.WarpInterp=data.config.WarpInterpolation; case 'vrc' datarender.RenderType='color'; datarender.AlphaTable=data.volumes(dvss).alphatable; datarender.ColorTable=data.volumes(dvss).colortable; datarender.ShearInterp=data.config.ShearInterpolation; datarender.WarpInterp=data.config.WarpInterpolation; case 'vrs' datarender.RenderType='shaded'; datarender.AlphaTable=data.volumes(dvss).alphatable; datarender.ColorTable=data.volumes(dvss).colortable; datarender.LightVector=data.subwindow(wsel).LightVector; datarender.ViewerVector=data.subwindow(wsel).ViewerVector; datarender.ShadingMaterial=data.subwindow(wsel).shading_material; datarender.ShearInterp=data.config.ShearInterpolation; datarender.WarpInterp=data.config.WarpInterpolation; case 'slicex' datarender.RenderType='slicex'; datarender.ColorTable=data.volumes(dvss).colortable; datarender.SliceSelected=data.subwindow(wsel).SliceSelected(1); datarender.WarpInterp='bicubic'; datarender.ColorSlice=data.subwindow(data.axes_select).ColorSlice; case 'slicey' datarender.RenderType='slicey'; datarender.ColorTable=data.volumes(dvss).colortable; datarender.SliceSelected=data.subwindow(wsel).SliceSelected(2); datarender.WarpInterp='bicubic'; datarender.ColorSlice=data.subwindow(data.axes_select).ColorSlice; case 'slicez' datarender.RenderType='slicez'; datarender.ColorTable=data.volumes(dvss).colortable; datarender.SliceSelected=data.subwindow(wsel).SliceSelected(3); datarender.WarpInterp='bicubic'; datarender.ColorSlice=data.subwindow(data.axes_select).ColorSlice; case 'black' datarender.RenderType='black'; end if(preview) switch data.subwindow(wsel).render_type case {'slicex','slicey','slicez'} datarender.WarpInterp='nearest'; datarender.Mview=data.subwindow(wsel).viewer_matrix; renderimage = render(data.volumes(dvss).volume_original, datarender); otherwise R=ResizeMatrix(data.volumes(dvss).Size_preview./data.volumes(dvss).Size_original); datarender.Mview=data.subwindow(wsel).viewer_matrix*R; renderimage = render(data.volumes(dvss).volume_preview,datarender); end else mouse_button_old=data.mouse.button; set_mouse_shape('watch',data); drawnow('expose'); switch data.subwindow(wsel).render_type case {'slicex','slicey','slicez'} datarender.Mview=data.subwindow(wsel).viewer_matrix; renderimage = render(data.volumes(dvss).volume_original, datarender); case 'black' renderimage = render(data.volumes(dvss).volume, datarender); otherwise datarender.Mview=data.subwindow(wsel).viewer_matrix*ResizeMatrix(data.volumes(dvss).Size./data.volumes(dvss).Size_original); datarender.VolumeX=data.volumes(dvss).volumex; datarender.VolumeY=data.volumes(dvss).volumey; datarender.Normals=data.volumes(dvss).normals; renderimage = render(data.volumes(dvss).volume, datarender); end set_mouse_shape(mouse_button_old,data); drawnow('expose'); end function renderimage=LevelRenderImage(renderimage,data,dvss,wsel) if(~isempty(dvss)) switch data.subwindow(wsel).render_type case {'mip','slicex', 'slicey', 'slicez'} % The render image is scaled to fit to [0..1], perform both back scaling % and Window level and Window width if ((ndims(renderimage)==2)&&(data.volumes(dvss).WindowWidth~=0||data.volumes(dvss).WindowLevel~=0)) m=(data.volumes(dvss).volumemax-data.volumes(dvss).volumemin)*(1/data.volumes(dvss).WindowWidth); o=(data.volumes(dvss).volumemin-data.volumes(dvss).WindowLevel)*(1/data.volumes(dvss).WindowWidth)+0.5; renderimage=renderimage*m+o; end end end function data=set_initial_view_matrix(data) dvss=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); switch data.subwindow(data.axes_select).render_type case 'slicex' data.subwindow(data.axes_select).viewer_matrix=[data.volumes(dvss).Scales(1)*data.subwindow(data.axes_select).Zoom 0 0 0; 0 data.volumes(dvss).Scales(2)*data.subwindow(data.axes_select).Zoom 0 0; 0 0 data.volumes(dvss).Scales(3)*data.subwindow(data.axes_select).Zoom 0; 0 0 0 1]; data.subwindow(data.axes_select).viewer_matrix=[0 0 1 0;0 1 0 0; -1 0 0 0;0 0 0 1]*data.subwindow(data.axes_select).viewer_matrix; case 'slicey' data.subwindow(data.axes_select).viewer_matrix=[data.volumes(dvss).Scales(1)*data.subwindow(data.axes_select).Zoom 0 0 0; 0 data.volumes(dvss).Scales(2)*data.subwindow(data.axes_select).Zoom 0 0; 0 0 data.volumes(dvss).Scales(3)*data.subwindow(data.axes_select).Zoom 0; 0 0 0 1]; data.subwindow(data.axes_select).viewer_matrix=[1 0 0 0;0 0 -1 0; 0 1 0 0;0 0 0 1]*data.subwindow(data.axes_select).viewer_matrix; case 'slicez' data.subwindow(data.axes_select).viewer_matrix=[data.volumes(dvss).Scales(1)*data.subwindow(data.axes_select).Zoom 0 0 0; 0 data.volumes(dvss).Scales(2)*data.subwindow(data.axes_select).Zoom 0 0; 0 0 data.volumes(dvss).Scales(3)*data.subwindow(data.axes_select).Zoom 0; 0 0 0 1]; data.subwindow(data.axes_select).viewer_matrix=data.subwindow(data.axes_select).viewer_matrix*[1 0 0 0;0 1 0 0; 0 0 1 0;0 0 0 1]; otherwise data.subwindow(data.axes_select).viewer_matrix=[data.volumes(dvss).Scales(1)*data.subwindow(data.axes_select).Zoom 0 0 0; 0 data.volumes(dvss).Scales(2)*data.subwindow(data.axes_select).Zoom 0 0; 0 0 data.volumes(dvss).Scales(3)*data.subwindow(data.axes_select).Zoom 0; 0 0 0 1]; end % --- Outputs from this function are returned to the command line. function varargout = viewer3d_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; function set_menu_checks(data) for i=1:data.NumberWindows C=data.subwindow(i).menu.Children(2).Children; for j=1:length(C) set(C(j).Handle,'Checked','off'); end D=data.subwindow(i).menu.Children(3).Children; s=structfind(D,'Tag','menu_config_slicescolor'); set(D(s).Handle,'Checked','off'); if(data.subwindow(i).ColorSlice) set(D(s).Handle,'Checked','on'); end s1=structfind(D,'Tag','menu_metal'); s2=structfind(D,'Tag','menu_shiny'); s3=structfind(D,'Tag','menu_dull'); set(D(s1).Handle,'Checked','off'); set(D(s2).Handle,'Checked','off'); set(D(s3).Handle,'Checked','off'); switch(data.subwindow(i).shading_material) case 'metal' set(D(s1).Handle,'Checked','on'); case 'shiny' set(D(s2).Handle,'Checked','on'); case 'dull' set(D(s3).Handle,'Checked','on'); end s1=structfind(D,'Tag','menu_combine_trans'); s2=structfind(D,'Tag','menu_combine_rgb'); set(D(s1).Handle,'Checked','off'); set(D(s2).Handle,'Checked','off'); switch(data.subwindow(i).combine) case 'trans' set(D(s1).Handle,'Checked','on'); case 'rgb' set(D(s2).Handle,'Checked','on'); end if(data.subwindow(i).volume_id_select(1)>0) n=length(data.subwindow(i).volume_id_select); st=['wmenu-' num2str(i)]; for j=1:n dvss=structfind(data.volumes,'id',data.subwindow(i).volume_id_select(j)); st=[st '-' num2str(dvss)]; end Ci=structfind(C,'Tag',st); else Ci=1; end if(~isempty(Ci)) set(C(Ci).Handle,'Checked','on'); end d=get(data.subwindow(i).menu.Children(1).Handle,'Children'); e=zeros(size(d)); for j=1:length(d), set(d(j),'Checked','off'); e(j)=get(d(j),'Position'); end [t,in]=sort(e); d=d(in); dv=structfind(data.rendertypes,'type',data.subwindow(i).render_type); set(d(dv),'Checked','on'); sl=strcmp(data.subwindow(i).render_type(1:min(5,end)),'slice'); if(sl) set(data.subwindow(i).menu.Children(4).Handle,'Enable','on') id=data.subwindow(i).volume_id_select; editable=false(1,length(id)); for k=1:length(id) editable(k)=data.volumes(structfind(data.volumes,'id',data.subwindow(i).volume_id_select(k))).Editable; end if(any(editable)) set(data.subwindow(i).menu.Children(5).Handle,'Enable','on') else set(data.subwindow(i).menu.Children(5).Handle,'Enable','off') end else set(data.subwindow(i).menu.Children(4).Handle,'Enable','off') set(data.subwindow(i).menu.Children(5).Handle,'Enable','off') end end menubar; % --- Executes on mouse motion over figure - except title and menu. function figure1_WindowButtonMotionFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) menubar('MotionFcn',gcf); cursor_position_in_axes(hObject,handles); data=getMyData(); if(isempty(data)), return, end if(isempty(data.axes_select)), return, end if(strcmp(data.subwindow(data.axes_select).render_type,'black')), return; end if((length(data.subwindow(data.axes_select).render_type)>5)&&strcmp(data.subwindow(data.axes_select).render_type(1:5),'slice')) data=mouseposition_to_voxelposition(data); setMyData(data); end if(data.mouse.pressed) switch(data.mouse.button) case 'rotate1' r1=-360*(data.subwindow(data.axes_select).mouse_position_last(1)-data.subwindow(data.axes_select).mouse_position(1)); r2=360*(data.subwindow(data.axes_select).mouse_position_last(2)-data.subwindow(data.axes_select).mouse_position(2)); R=RotationMatrix([r1 r2 0]); data.subwindow(data.axes_select).viewer_matrix=R*data.subwindow(data.axes_select).viewer_matrix; setMyData(data); show3d(true,true) case 'rotate2' r1=100*(data.subwindow(data.axes_select).mouse_position_last(1)-data.subwindow(data.axes_select).mouse_position(1)); r2=100*(data.subwindow(data.axes_select).mouse_position_last(2)-data.subwindow(data.axes_select).mouse_position(2)); if(data.subwindow(data.axes_select).mouse_position(2)>0.5), r1=-r1; end if(data.subwindow(data.axes_select).mouse_position(1)<0.5), r2=-r2; end r3=r1+r2; R=RotationMatrix([0 0 r3]); data.subwindow(data.axes_select).viewer_matrix=R*data.subwindow(data.axes_select).viewer_matrix; setMyData(data); show3d(true,true) case 'pan' t2=200*(data.subwindow(data.axes_select).mouse_position_last(1)-data.subwindow(data.axes_select).mouse_position(1)); t1=200*(data.subwindow(data.axes_select).mouse_position_last(2)-data.subwindow(data.axes_select).mouse_position(2)); M=TranslateMatrix([t1 t2 0]); data.subwindow(data.axes_select).viewer_matrix=M*data.subwindow(data.axes_select).viewer_matrix; setMyData(data); show3d(true,true) case 'zoom' z1=1+2*(data.subwindow(data.axes_select).mouse_position_last(1)-data.subwindow(data.axes_select).mouse_position(1)); z2=1+2*(data.subwindow(data.axes_select).mouse_position_last(2)-data.subwindow(data.axes_select).mouse_position(2)); z=0.5*(z1+z2); R=ResizeMatrix([z z z]); data.subwindow(data.axes_select).Zoom=data.subwindow(data.axes_select).Zoom*(1/z); data.subwindow(data.axes_select).viewer_matrix=R*data.subwindow(data.axes_select).viewer_matrix; setMyData(data); show3d(true,true) case 'drag' id=data.subwindow(data.axes_select).object_id_select; dvs=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); n=structfind(data.volumes(dvs).MeasureList,'id',id(1)); object=data.volumes(dvs).MeasureList(n); s=round(id(3)*length(object.x)); if(s==0) object.x=object.x-mean(object.x(:))+ data.subwindow(data.axes_select).VoxelLocation(1); object.y=object.y-mean(object.y(:))+ data.subwindow(data.axes_select).VoxelLocation(2); object.z=object.z-mean(object.z(:))+ data.subwindow(data.axes_select).VoxelLocation(3); else object.x(s)=data.subwindow(data.axes_select).VoxelLocation(1); object.y(s)=data.subwindow(data.axes_select).VoxelLocation(2); object.z(s)=data.subwindow(data.axes_select).VoxelLocation(3); end switch object.type case 'd' dx=data.volumes(dvs).Scales(1)*(object.x(1)-object.x(2)); dy=data.volumes(dvs).Scales(2)*(object.y(1)-object.y(2)); dz=data.volumes(dvs).Scales(3)*(object.z(1)-object.z(2)); distance=sqrt(dx.^2+dy.^2+dz.^2); object.varmm=distance; otherwise end data.volumes(dvs).MeasureList(n)=object; setMyData(data); show3d(false,false) otherwise end end function R=RotationMatrix(r) % Determine the rotation matrix (View matrix) for rotation angles xyz ... Rx=[1 0 0 0; 0 cosd(r(1)) -sind(r(1)) 0; 0 sind(r(1)) cosd(r(1)) 0; 0 0 0 1]; Ry=[cosd(r(2)) 0 sind(r(2)) 0; 0 1 0 0; -sind(r(2)) 0 cosd(r(2)) 0; 0 0 0 1]; Rz=[cosd(r(3)) -sind(r(3)) 0 0; sind(r(3)) cosd(r(3)) 0 0; 0 0 1 0; 0 0 0 1]; R=Rx*Ry*Rz; function M=ResizeMatrix(s) M=[1/s(1) 0 0 0; 0 1/s(2) 0 0; 0 0 1/s(3) 0; 0 0 0 1]; function M=TranslateMatrix(t) M=[1 0 0 -t(1); 0 1 0 -t(2); 0 0 1 -t(3); 0 0 0 1]; function cursor_position_in_axes(hObject,handles) data=getMyData(); if(isempty(data)), return, end; if(isempty(data.axes_select)), return, end data.subwindow(data.axes_select).mouse_position_last=data.subwindow(data.axes_select).mouse_position; % Get position of the mouse in the large axes % p = get(0, 'PointerLocation'); % pf = get(hObject, 'pos'); % p(1:2) = p(1:2)-pf(1:2); % set(gcf, 'CurrentPoint', p(1:2)); h=data.subwindow(data.axes_select).handles.axes; if(~ishandle(h)), return; end p = get(h, 'CurrentPoint'); if (~isempty(p)) data.subwindow(data.axes_select).mouse_position=[p(1, 1) p(1, 2)]./data.subwindow(data.axes_select).axes_size(1:2); end setMyData(data); function setMyData(data,handle) % Store data struct in figure if(nargin<2), handle=gcf; end setappdata(handle,'data3d',data); function data=getMyData(handle) % Get data struct stored in figure if(nargin<1), handle=gcf; end data=getappdata(handle,'data3d'); % --- Executes on mouse press over axes background. function axes_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end dvs=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); ha=zeros(1,data.NumberWindows); for i=1:data.NumberWindows, ha(i)=data.subwindow(i).handles.axes; end data.axes_select=find(ha==gca); data.mouse.pressed=true; data.mouse.button=get(handles.figure1,'SelectionType'); data.subwindow(data.axes_select).mouse_position_pressed=data.subwindow(data.axes_select).mouse_position; if(strcmp(data.mouse.button,'normal')) sr=strcmp(data.subwindow(data.axes_select).render_type(1:min(end,5)),'slice'); if(sr) switch(data.mouse.action) case 'measure_distance' if(getnumberofpoints(data)==0) % Do measurement data=addMeasureList('p',data.subwindow(data.axes_select).VoxelLocation(1),data.subwindow(data.axes_select).VoxelLocation(2),data.subwindow(data.axes_select).VoxelLocation(3),0,data); data.mouse.button='select_distance'; data.mouse.pressed=false; setMyData(data); show3d(false,false); return elseif(getnumberofpoints(data)>0) VoxelLocation1=[data.volumes(dvs).MeasureList(end).x data.volumes(dvs).MeasureList(end).y data.volumes(dvs).MeasureList(end).z]; VoxelLocation2=data.subwindow(data.axes_select).VoxelLocation; % First remove the point (will be replaced by distance) data=rmvMeasureList(data.volumes(dvs).MeasureList(end).id,data); % Do measurement x=[VoxelLocation1(1) VoxelLocation2(1)]; y=[VoxelLocation1(2) VoxelLocation2(2)]; z=[VoxelLocation1(3) VoxelLocation2(3)]; dx=data.volumes(dvs).Scales(1)*(x(1)-x(2)); dy=data.volumes(dvs).Scales(2)*(y(1)-y(2)); dz=data.volumes(dvs).Scales(3)*(z(1)-z(2)); distance=sqrt(dx.^2+dy.^2+dz.^2); data=addMeasureList('d',x,y,z,distance,data); data.mouse.action=''; data.mouse.pressed=false; setMyData(data); show3d(false,false); return end case 'measure_landmark' data=addMeasureList('l',data.subwindow(data.axes_select).VoxelLocation(1),data.subwindow(data.axes_select).VoxelLocation(2),data.subwindow(data.axes_select).VoxelLocation(3),0,data); data.mouse.button='select_landmark'; data.mouse.action=''; data.mouse.pressed=false; setMyData(data); show3d(false,false); return case 'segment_click_roi' % Do measurement [vx,vy,vz]=getClickRoi(data); for i=1:length(vx), data=addMeasureList('p',vx(i),vy(i),vz(i),0,data); end data=points2roi(data,false); data.mouse.button='click_roi'; data.subwindow(data.axes_select).click_roi=false; data.mouse.pressed=false; setMyData(data); show3d(false,false); return case 'measure_roi' % Do measurement data=addMeasureList('p',data.subwindow(data.axes_select).VoxelLocation(1),data.subwindow(data.axes_select).VoxelLocation(2),data.subwindow(data.axes_select).VoxelLocation(3),0,data); data.mouse.button='select_roi'; data.mouse.pressed=false; setMyData(data); show3d(false,false); return case 'segment_roi' % Do measurement data=addMeasureList('p',data.subwindow(data.axes_select).VoxelLocation(1),data.subwindow(data.axes_select).VoxelLocation(2),data.subwindow(data.axes_select).VoxelLocation(3),0,data); data.mouse.button='select_roi'; data.mouse.pressed=false; setMyData(data); show3d(true,false); return otherwise id_detect=getHitMapClick(data); if(id_detect(1)>0) data.subwindow(data.axes_select).object_id_select=id_detect; data.mouse.button='drag'; setMyData(data); return; end end end distance_center=sum((data.subwindow(data.axes_select).mouse_position-[0.5 0.5]).^2); if((distance_center<0.15)&&data.subwindow(data.axes_select).render_type(1)~='s') data.mouse.button='rotate1'; set_mouse_shape('rotate1',data) else data.mouse.button='rotate2'; set_mouse_shape('rotate2',data) end end if(strcmp(data.mouse.button,'open')) switch(data.mouse.action) case 'measure_roi' data=addMeasureList('p',data.subwindow(data.axes_select).VoxelLocation(1),data.subwindow(data.axes_select).VoxelLocation(2),data.subwindow(data.axes_select).VoxelLocation(3),0,data); data=points2roi(data,false); data.mouse.action=''; data.mouse.pressed=false; setMyData(data); show3d(false,false); return case 'segment_roi' data=addMeasureList('p',data.subwindow(data.axes_select).VoxelLocation(1),data.subwindow(data.axes_select).VoxelLocation(2),data.subwindow(data.axes_select).VoxelLocation(3),0,data); data=points2roi(data,true); data.mouse.action=''; data.mouse.pressed=false; setMyData(data); show3d(false,true); return otherwise end end if(strcmp(data.mouse.button,'extend')) data.mouse.button='pan'; set_mouse_shape('pan',data) end if(strcmp(data.mouse.button,'alt')) if(data.subwindow(data.axes_select).render_type(1)=='s') id_detect=getHitMapClick(data); if(id_detect(1)>0) data=rmvMeasureList(id_detect(1),data); setMyData(data); show3d(false,false); return; end end data.mouse.button='zoom'; set_mouse_shape('zoom',data); end setMyData(data); function id_detect=getHitMapClick(data) % Get the mouse position x_2d=data.subwindow(data.axes_select).mouse_position(2); y_2d=data.subwindow(data.axes_select).mouse_position(1); % To rendered image position x_2d=round(x_2d*data.config.ImageSizeRender); y_2d=round(y_2d*data.config.ImageSizeRender); m=3; x_2d_start=x_2d-m; x_2d_start(x_2d_start<1)=1; x_2d_end=x_2d+m; x_2d_end(x_2d_end>size(data.subwindow(data.axes_select).hitmap,1))=size(data.subwindow(data.axes_select).hitmap,1); y_2d_start=y_2d-m; y_2d_start(y_2d_start<1)=1; y_2d_end=y_2d+m; y_2d_end(y_2d_end>size(data.subwindow(data.axes_select).hitmap,2))=size(data.subwindow(data.axes_select).hitmap,2); hitmap_part=data.subwindow(data.axes_select).hitmap(x_2d_start:x_2d_end,y_2d_start:y_2d_end,:); h1=hitmap_part(:,:,1); h2=hitmap_part(:,:,2); h3=hitmap_part(:,:,3); id_detect=[max(h1(:)) max(h2(:)) max(h3(:))]; if(isempty(id_detect)), id_detect=[0 0 0]; end function data=points2roi(data,segment) dvs=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); np=getnumberofpoints(data); x=zeros(1,np); y=zeros(1,np); z=zeros(1,np); for i=1:np; x(i)=data.volumes(dvs).MeasureList(end).x; y(i)=data.volumes(dvs).MeasureList(end).y; z(i)=data.volumes(dvs).MeasureList(end).z; data=rmvMeasureList(data.volumes(dvs).MeasureList(end).id,data); end [x,y,z]=interpcontour(x,y,z,2); switch (data.subwindow(data.axes_select).render_type) case {'slicex'} x_2d=y; y_2d=z; sizeI=[size(data.volumes(dvs).volume_original,2) size(data.volumes(dvs).volume_original,3)]; case {'slicey'} x_2d=x; y_2d=z; sizeI=[size(data.volumes(dvs).volume_original,1) size(data.volumes(dvs).volume_original,3)]; case {'slicez'} x_2d=x; y_2d=y; sizeI=[size(data.volumes(dvs).volume_original,1) size(data.volumes(dvs).volume_original,2)]; end I=bitmapplot(x_2d,y_2d,zeros(sizeI),struct('FillColor',[1 1 1 1],'Color',[1 1 1 1]))>0; if(segment) data=addMeasureList('s',x,y,z,0,data); data.volumes(dvs).MeasureList(length(data.volumes(dvs).MeasureList)).SliceSelected=0; else volume=sum(I(:))*prod(data.volumes(dvs).Scales); data=addMeasureList('r',x,y,z,volume,data); end function [vx,vy,vz]=getClickRoi(data) switch(data.subwindow(data.axes_select).render_type) case 'slicex' B=squeeze(data.volumes(dvs).volume_original(data.subwindow(data.axes_select).SliceSelected(1),:,:)); Bx=data.subwindow(data.axes_select).VoxelLocation(2); By=data.subwindow(data.axes_select).VoxelLocation(3); case 'slicey' B=squeeze(data.volumes(dvs).volume_original(:,data.subwindow(data.axes_select).SliceSelected(2),:)); Bx=data.subwindow(data.axes_select).VoxelLocation(1); By=data.subwindow(data.axes_select).VoxelLocation(3); case 'slicez' B=squeeze(data.volumes(dvs).volume_original(:,:,data.subwindow(data.axes_select).SliceSelected(3))); Bx=data.subwindow(data.axes_select).VoxelLocation(1); By=data.subwindow(data.axes_select).VoxelLocation(2); end B=(B-data.volumes(dvs).WindowLevel)./data.volumes(dvs).WindowWidth; Bx=round(max(min(Bx,size(B,1)-1),2)); By=round(max(min(By,size(B,2)-1),2)); val=mean(mean(B(Bx-1:Bx+1,By-1:By+1))); B=B-val; B=abs(B)<0.15; L=bwlabel(B); B=L==L(Bx,By); B=bwmorph(bwmorph(bwmorph(imfill(B,'holes'),'remove'),'skel'),'spur',inf); [x,y]=find(B); for i=2:length(x) dist=(x(i:end)-x(i-1)).^2+(y(i:end)-y(i-1)).^2; [t,j]=min(dist); j=j+i-1; t=x(i); x(i)=x(j); x(j)=t; t=y(i); y(i)=y(j); y(j)=t; dist=(x(1)-x(i)).^2+(y(1)-y(i)).^2; if((i>4)&&dist<2), break; end end x=x(1:3:i); y=y(1:3:i); switch(data.subwindow(data.axes_select).render_type) case 'slicex' vx=repmat(data.subwindow(data.axes_select).SliceSelected(1),size(x)); vy=x; vz=y; case 'slicey' vy=repmat(data.subwindow(data.axes_select).SliceSelected(2),size(x)); vx=x; vz=y; case 'slicez' vz=repmat(data.subwindow(data.axes_select).SliceSelected(3),size(x)); vx=x; vy=y; end function p=getnumberofpoints(data) p=0; dvs=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); for i=length(data.volumes(dvs).MeasureList):-1:1, if(data.volumes(dvs).MeasureList(i).type=='p'), p=p+1; else return; end end function data=showMeasureList(data) dvs=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); data.subwindow(data.axes_select).hitmap=zeros([size(data.subwindow(data.axes_select).total_image,1) size(data.subwindow(data.axes_select).total_image,2) 3]); if(~isfield(data.volumes(dvs),'MeasureList')), return; end if(length(data.subwindow(data.axes_select).render_type)<6), return; end SliceSelected=data.subwindow(data.axes_select).SliceSelected(uint8(data.subwindow(data.axes_select).render_type(6))-119); for i=1:length(data.volumes(dvs).MeasureList) S=data.volumes(dvs).MeasureList(i).SliceSelected; if(data.subwindow(data.axes_select).render_type(6)==data.volumes(dvs).MeasureList(i).RenderSelected&&(SliceSelected==S||S==0)) id=data.volumes(dvs).MeasureList(i).id; x=data.volumes(dvs).MeasureList(i).x; y=data.volumes(dvs).MeasureList(i).y; z=data.volumes(dvs).MeasureList(i).z; [x,y]=voxelposition_to_imageposition(x,y,z,data); switch data.volumes(dvs).MeasureList(i).type case 'd' distancemm=data.volumes(dvs).MeasureList(i).varmm; data=plotDistance(x,y,distancemm,id,data); case 'r' volumemm=data.volumes(dvs).MeasureList(i).varmm; data=plotRoi(x,y,volumemm,id,data); case 's' data=plotSegRoi(x,y,id,data); case 'p' data=plotPoint(x,y,id,data); case 'l' data=plotPointBlue(x,y,id,data); end end end function data=plotPoint(x,y,id,data) I=data.subwindow(data.axes_select).total_image; I=bitmapplot(x,y,I,struct('Marker','*','MarkerColor',[1 0 0 1],'Color',[0 0 1 1])); data.subwindow(data.axes_select).hitmap=bitmapplot(x,y,data.subwindow(data.axes_select).hitmap,struct('Marker','*','MarkerColor',[id id 0 1],'Color',[id id 0 1])); data.subwindow(data.axes_select).total_image=I; function data=plotPointBlue(x,y,id,data) I=data.subwindow(data.axes_select).total_image; I=bitmapplot(x,y,I,struct('Marker','*','MarkerColor',[0 0 1 1],'Color',[1 0 0 1])); data.subwindow(data.axes_select).hitmap=bitmapplot(x,y,data.subwindow(data.axes_select).hitmap,struct('Marker','*','MarkerColor',[id id 0 1],'Color',[id id 0 1])); data.subwindow(data.axes_select).total_image=I; function data=plotDistance(x,y,distancemm,id,data) I=data.subwindow(data.axes_select).total_image; I=bitmapplot(x,y,I,struct('Marker','*','MarkerColor',[1 0 0 1],'Color',[0 0 1 1])); MC=zeros(length(x),4); MC(:,1)=id; MC(:,2)=id; MC(:,3)=(1:length(x))/length(x); MC(:,4)=1; data.subwindow(data.axes_select).hitmap=bitmapplot(x,y,data.subwindow(data.axes_select).hitmap,struct('Marker','*','MarkerColor',MC,'Color',[id id 0 1])); info=[num3str(distancemm,0,2) ' mm']; I=bitmaptext(info,I,[mean(x)-5 mean(y)-5],struct('Color',[0 1 0 1])); data.subwindow(data.axes_select).total_image=I; function data=plotRoi(x,y,volumemm,id,data) I=data.subwindow(data.axes_select).total_image; I=bitmapplot(x,y,I,struct('FillColor',[0 0 1 0.1],'Color',[1 0 0 1])); data.subwindow(data.axes_select).hitmap=bitmapplot(x,y,data.subwindow(data.axes_select).hitmap,struct('Color',[id id 0 1])); info=[num3str(volumemm,0,2) ' mm^3']; I=bitmaptext(info,I,[mean(x)-5 mean(y)-5],struct('Color',[0 1 0 1])); data.subwindow(data.axes_select).total_image=I; function data=plotSegRoi(x,y,id,data) I=data.subwindow(data.axes_select).total_image; I=bitmapplot(x,y,I,struct('FillColor',[0 1 1 0.3],'Color',[0 1 1 1],'Marker','+')); MC=zeros(length(x),4); MC(:,1)=id; MC(:,2)=id; MC(:,3)=(1:length(x))/length(x); MC(:,4)=1; data.subwindow(data.axes_select).hitmap=bitmapplot(x,y,data.subwindow(data.axes_select).hitmap,struct('Marker','+','MarkerColor',MC,'Color',[id id 0 1])); data.subwindow(data.axes_select).total_image=I; function numstr=num3str(num,bef,aft) numstr=num2str(num,['%.' num2str(aft) 'f']); if(aft>0), maxlen = bef + aft +1; else maxlen = bef; end while (length(numstr)<maxlen), numstr=['0' numstr]; end function data=addMeasureList(type,x,y,z,varmm,data) dvs=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); if(isempty(data.volumes(dvs).MeasureList)), p=1; else p=length(data.volumes(dvs).MeasureList)+1; end data.volumes(dvs).MeasureList(p).id=(rand+sum(clock)-floor(sum(clock)))/2; data.volumes(dvs).MeasureList(p).type=type; data.volumes(dvs).MeasureList(p).RenderSelected=data.subwindow(data.axes_select).render_type(6); SliceSelected=data.subwindow(data.axes_select).SliceSelected(uint8(data.subwindow(data.axes_select).render_type(6))-119); data.volumes(dvs).MeasureList(p).SliceSelected=SliceSelected; data.volumes(dvs).MeasureList(p).x=x; data.volumes(dvs).MeasureList(p).y=y; data.volumes(dvs).MeasureList(p).z=z; data.volumes(dvs).MeasureList(p).varmm=varmm; data=calcTotalVolume(data); function data=rmvMeasureList(id,data) dvs=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); index=-1; for i=1:length(data.volumes(dvs).MeasureList) if(data.volumes(dvs).MeasureList(i).id==id), index=i;end end if(index>-1) data.volumes(dvs).MeasureList(index)=[]; end data=calcTotalVolume(data); function data=calcTotalVolume(data) dvs=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); data.subwindow(data.axes_select).tVolumemm=0; for i=1:length(data.volumes(dvs).MeasureList) if(data.volumes(dvs).MeasureList(i).type=='r') data.subwindow(data.axes_select).tVolumemm=data.subwindow(data.axes_select).tVolumemm+data.volumes(dvs).MeasureList(i).varmm; end end function set_mouse_shape(type,data) if(isempty(type)), type='normal'; end switch(type) case 'rotate1' set(gcf,'Pointer','custom','PointerShapeCData',data.icons.icon_mouse_rotate1,'PointerShapeHotSpot',round(size(data.icons.icon_mouse_rotate1)/2)) set(data.handles.figure1,'Pointer','custom'); case 'rotate2' set(gcf,'Pointer','custom','PointerShapeCData',data.icons.icon_mouse_rotate2,'PointerShapeHotSpot',round(size(data.icons.icon_mouse_rotate2)/2)) set(data.handles.figure1,'Pointer','custom'); case 'select_distance' set(data.handles.figure1,'Pointer','crosshair') case 'select_landmark' set(data.handles.figure1,'Pointer','crosshair') case 'select_roi' set(data.handles.figure1,'Pointer','crosshair') case 'click_roi' set(data.handles.figure1,'Pointer','crosshair') case 'normal' set(data.handles.figure1,'Pointer','arrow') case 'alt' set(data.handles.figure1,'Pointer','arrow') case 'open' set(data.handles.figure1,'Pointer','arrow') case 'zoom' set(gcf,'Pointer','custom','PointerShapeCData',data.icons.icon_mouse_zoom,'PointerShapeHotSpot',round(size(data.icons.icon_mouse_zoom)/2)) set(data.handles.figure1,'Pointer','custom'); case 'pan' set(gcf,'Pointer','custom','PointerShapeCData',data.icons.icon_mouse_pan,'PointerShapeHotSpot',round(size(data.icons.icon_mouse_pan)/2)) set(data.handles.figure1,'Pointer','custom'); otherwise set(data.handles.figure1,'Pointer','arrow') end % --- Executes on mouse press over figure background, over a disabled or % --- inactive control, or over an axes background. function figure1_WindowButtonUpFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end if(isempty(data.axes_select)), return, end if(data.mouse.pressed) data.mouse.pressed=false; setMyData(data); show3d(false,true) end switch(data.mouse.action) case 'measure_distance', set_mouse_shape('select_distance',data) case 'measure_roi', set_mouse_shape('select_roi',data) otherwise set_mouse_shape('arrow',data) end function A=imresize3d(V,scale,tsize,ntype,npad) % This function resizes a 3D image volume to new dimensions % Vnew = imresize3d(V,scale,nsize,ntype,npad); % % inputs, % V: The input image volume % scale: scaling factor, when used set tsize to []; % nsize: new dimensions, when used set scale to []; % ntype: Type of interpolation ('nearest', 'linear', or 'cubic') % npad: Boundary condition ('replicate', 'symmetric', 'circular', 'fill', or 'bound') % % outputs, % Vnew: The resized image volume % % example, % load('mri','D'); D=squeeze(D); % Dnew = imresize3d(D,[],[80 80 40],'nearest','bound'); % % This function is written by D.Kroon University of Twente (July 2008) % Check the inputs if(exist('ntype', 'var') == 0), ntype='nearest'; end if(exist('npad', 'var') == 0), npad='bound'; end if(exist('scale', 'var')&&~isempty(scale)), tsize=round(size(V)*scale); end if(ndims(V)>2) if(exist('tsize', 'var')&&~isempty(tsize)), scale=(tsize./size(V)); end vmin=min(V(:)); vmax=max(V(:)); % Make transformation structure T = makehgtform('scale',scale); tform = maketform('affine', T); % Specify resampler R = makeresampler(ntype, npad); % Resize the image volueme A = tformarray(V, tform, R, [1 2 3], [1 2 3], tsize, [], 0); % Limit to range A(A<vmin)=vmin; A(A>vmax)=vmax; else if(exist('tsize', 'var')&&~isempty(tsize)), tsize=tsize(1:2); scale=(tsize./size(V)); end vmin=min(V(:)); vmax=max(V(:)); switch(ntype(1)) case 'n' ntype2='nearest'; case 'l' ntype2='bilinear'; otherwise ntype2='bicubic'; end % Transform the image A=imresize(V,scale.*size(V),ntype2); % Limit to range A(A<vmin)=vmin; A(A>vmax)=vmax; end % -------------------------------------------------------------------- function menu_file_Callback(hObject, eventdata, handles) % hObject handle to menu_file (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_config_Callback(hObject, eventdata, handles) % hObject handle to menu_config (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_change_alpha_colors_Callback(hObject, eventdata, handles) % hObject handle to menu_change_alpha_colors (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.volume_select=eventdata; data.figurehandles.histogram=viewer3d_histogram(data.figurehandles.viewer3d); handles_histogram=guidata(data.figurehandles.histogram); data.figurehandles.histogram_axes=handles_histogram.axes_histogram; setMyData(data); createHistogram(); drawHistogramPoints(); % -------------------------------------------------------------------- function menu_load_view_Callback(hObject, eventdata, handles) % hObject handle to menu_load_view (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(ishandle(data.figurehandles.histogram)), close(data.figurehandles.histogram); end [filename, dirname] = uigetfile('*.mat', 'Select a Viewer3D Matlab file',fileparts(data.history.filenames{1})); if(ischar(filename)) filename=[dirname filename]; load_view(filename); else viewer3d_error({'No File selected'}); return end function load_view(filename) dataold=getMyData(); if(exist(filename,'file')) load(filename); else viewer3d_error({'File Not Found'}); return end if(exist('data','var')) % Remove current Windows and VolumeMenu's dataold.NumberWindows=0; dataold=deleteWindows(dataold); for i=1:length(dataold.volumes) delete(dataold.MenuVolume(i).Handle); end % Temporary store the loaded data in a new variable datanew=data; % Make an empty data-structure data=struct; % Add the current figure handles and other information about the % current render figure. data.Menu=dataold.Menu; data.handles=dataold.handles; data.mouse=dataold.mouse; data.config=dataold.config; data.history=dataold.history; data.rendertypes=dataold.rendertypes; data.figurehandles=dataold.figurehandles; data.volumes=[]; data.axes_select=[]; data.volume_select=[]; data.subwindow=[]; data.NumberWindows=0; data.MenuVolume=[]; data.icons=dataold.icons; % Add the loaded volumes data.volumes=datanew.volumes; for nv=1:length(data.volumes) data=makeVolumeXY(data,nv); data=computeNormals(data,nv); data=makePreviewVolume(data,nv); data=makeRenderVolume(data,nv); data=createAlphaColorTable(nv,data); end data.NumberWindows=datanew.NumberWindows; data=addWindows(data); cfield={'tVolumemm', ... 'VoxelLocation','mouse_position_pressed','mouse_position','mouse_position_last','shading_material', ... 'ColorSlice','render_type','ViewerVector','LightVector','volume_id_select','object_id_select' ... 'render_image','total_image','hitmap','axes_size','Zoom','viewer_matrix','SliceSelected','Mview','combine'}; for i=1:data.NumberWindows for j=1:length(cfield); if(isfield(datanew.subwindow(i),cfield{j})) data.subwindow(i).(cfield{j})=datanew.subwindow(i).(cfield{j}); else data.subwindow(i).(cfield{j})=dataold.subwindow(1).(cfield{j}); end end end data.substorage=datanew.substorage; data.axes_select=datanew.axes_select; data.volume_select=datanew.volume_select; setMyData(data); addMenuVolume(); set_menu_checks(data); allshow3d(false,true); % Menu: [1x5 struct] % handles: [1x1 struct] % mouse: [1x1 struct] % config: [1x1 struct] % history: [1x1 struct] % rendertypes: [1x8 struct] % figurehandles: [1x1 struct] % volumes: [1x2 struct] % axes_select: 1 % volume_select: 2 % subwindow: [1x2 struct] % NumberWindows: 2 % MenuVolume: [1x2 struct] % icons: [1x1 struct] % substorage: else viewer3d_error({'Matlab File does not contain','data from "Save View"'}) end function data=add_filename_to_history(data,filename) % Add curent filename to history for i=1:5 if(strcmpi(data.history.filenames{i},filename)); data.history.filenames{i}=''; end end for i=5:-1:1 if(i==1) data.history.filenames{i}=filename; else data.history.filenames{i}=data.history.filenames{i-1}; end end % Save filename history history=data.history; save(data.history.historyfile,'history'); showhistory(data); function load_variable_Callback(hObject, eventdata, handles) % hObject handle to menu_load_view (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end V=eventdata; volumemax=double(max(V(:))); volumemin=double(min(V(:))); info=struct; info.WindowWidth=volumemax-volumemin; info.WindowLevel=0.5*(volumemax+volumemin); addVolume(V,[1 1 1],info); % -------------------------------------------------------------------- function menu_load_data_Callback(hObject, eventdata, handles) % hObject handle to menu_load_data (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end if(ishandle(data.figurehandles.histogram)), close(data.figurehandles.histogram); end [volume,info]=ReadData3D; % Make the volume nD -> 4D V=reshape(volume,size(volume,1),size(volume,2),size(volume,3),[]); if(isempty(info)),return; end scales=info.PixelDimensions; if(nnz(scales)<3) viewer3d_error({'Pixel Scaling Unknown using [1, 1, 1]'}) scales=[1 1 1]; end if(exist('volume','var')) addVolume(V,scales,info) else viewer3d_error({'Matlab Data Load Error'}) end % -------------------------------------------------------------------- function menu_save_view_Callback(hObject, eventdata, handles) % hObject handle to menu_save_view (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end for dvs=1:length(data.volumes) data.volumes(dvs).volume_preview=[]; data.volumes(dvs).volume=[]; data.volumes(dvs).volumex=[]; data.volumes(dvs).volumey=[]; data.volumes(dvs).normals=[]; end [filename, dirname] = uiputfile('*.mat', 'Store a Viewer3D file',fileparts(data.history.filenames{1})); if(ischar(filename)) filename=[dirname filename]; h = waitbar(0,'Please wait...'); drawnow('expose') save(filename,'data'); close(h); else viewer3d_error({'No File selected'}); return end % Add curent filename to history data=getMyData(); if(isempty(data)), return, end data=add_filename_to_history(data,filename); setMyData(data); function menu_load_histogram_Callback(hObject, eventdata, handles) % hObject handle to menu_load_view (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end alpha=0; uiload; if(exist('positions','var')) data.volumes(dvs).histogram_positions=positions; data.volumes(dvs).histogram_colors=colors; data.volumes(dvs).histogram_alpha=alpha; setMyData(data); drawHistogramPoints(); createAlphaColorTable(); show3d(false,true); else viewer3d_error({'Matlab File does not contain','data from "Save AlphaColors"'}) end % -------------------------------------------------------------------- function menu_save_histogram_Callback(hObject, eventdata, handles) % hObject handle to menu_save_view (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end positions=data.volumes(dvs).histogram_positions; colors=data.volumes(dvs).histogram_colors; alpha=data.volumes(dvs).histogram_alpha; uisave({'positions','colors','alpha'}); % -------------------------------------------------------------------- function menu_render_Callback(hObject, eventdata, handles) % hObject handle to menu_render (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_info_Callback(hObject, eventdata, handles) % hObject handle to menu_info (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_save_picture_Callback(hObject, eventdata, handles) % hObject handle to menu_save_picture (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [filename, pathname] = uiputfile({'*.png';'*.jpg'}, 'Save Rendered Image as'); data=getMyData(); if(isempty(data)), return, end imwrite(data.subwindow(data.axes_select).total_image,[pathname filename]); % -------------------------------------------------------------------- function menu_about_Callback(hObject, eventdata, handles) % hObject handle to menu_about (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) viewer3d_about function createHistogram() % This function creates and show the (log) histogram of the data data=getMyData(); if(isempty(data)), return, end dvs=data.volume_select; % Get histogram volumepart=single(data.volumes(dvs).volume(1:8:end)); data.volumes(dvs).histogram_countsx=linspace(data.volumes(dvs).volumemin,data.volumes(dvs).volumemax,1000); data.volumes(dvs).histogram_countsy=hist(volumepart,data.volumes(dvs).histogram_countsx); % Log the histogram data data.volumes(dvs).histogram_countsy=log(data.volumes(dvs).histogram_countsy+100); data.volumes(dvs).histogram_countsy=data.volumes(dvs).histogram_countsy-min(data.volumes(dvs).histogram_countsy); data.volumes(dvs).histogram_countsy=data.volumes(dvs).histogram_countsy./max(data.volumes(dvs).histogram_countsy(:)); % Focus on histogram axes figure(data.figurehandles.histogram) % Display the histogram stem(data.figurehandles.histogram_axes,data.volumes(dvs).histogram_countsx,data.volumes(dvs).histogram_countsy,'Marker', 'none'); hold(data.figurehandles.histogram_axes,'on'); % Set the axis of the histogram axes data.volumes(dvs).histogram_maxy=max(data.volumes(dvs).histogram_countsy(:)); data.volumes(dvs).histogram_maxx=max(data.volumes(dvs).histogram_countsx(:)); set(data.figurehandles.histogram_axes,'yLim', [0 1]); set(data.figurehandles.histogram_axes,'xLim', [data.volumes(dvs).volumemin data.volumes(dvs).volumemax]); setMyData(data); % --- Executes on selection change in popupmenu_colors. function popupmenu_colors_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_colors (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns popupmenu_colors contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_colors data=getMyData(); if(isempty(data)), return, end dvs=data.volume_select; % Generate the new color markers c_choice=get(handles.popupmenu_colors,'Value'); ncolors=length(data.volumes(dvs).histogram_positions); switch c_choice, case 1,new_colormap=jet(1000); case 2, new_colormap=hsv(1000); case 3, new_colormap=hot(1000); case 4, new_colormap=cool(1000); case 5, new_colormap=spring(1000); case 6, new_colormap=summer(1000); case 7, new_colormap=autumn(1000); case 8, new_colormap=winter(1000); case 9, new_colormap=gray(1000); case 10, new_colormap=bone(1000); case 11, new_colormap=copper(1000); case 12, new_colormap=pink(1000); otherwise, new_colormap=hot(1000); end new_colormap=new_colormap(round(1:(end-1)/(ncolors-1):end),:); data.volumes(dvs).histogram_colors=new_colormap; % Draw the new color markers and make the color and alpha map setMyData(data); drawHistogramPoints(); createAlphaColorTable(); show3d(false,true); function drawHistogramPoints() data=getMyData(); if(isempty(data)), return, end dvs=data.volume_select; % Delete old points and line try delete(data.volumes(dvs).histogram_linehandle), for i=1:length(data.volumes(dvs).histogram_pointhandle), delete(data.volumes(dvs).histogram_pointhandle(i)), end, catch end stem(data.figurehandles.histogram_axes,data.volumes(dvs).histogram_countsx,data.volumes(dvs).histogram_countsy,'Marker', 'none'); hold(data.figurehandles.histogram_axes,'on'); % Display the markers and line through the markers. data.volumes(dvs).histogram_linehandle=plot(data.figurehandles.histogram_axes,data.volumes(dvs).histogram_positions,data.volumes(dvs).histogram_alpha*data.volumes(dvs).histogram_maxy,'m'); set(data.volumes(dvs).histogram_linehandle,'ButtonDownFcn','viewer3d(''lineHistogramButtonDownFcn'',gcbo,[],guidata(gcbo))'); for i=1:length(data.volumes(dvs).histogram_positions) data.volumes(dvs).histogram_pointhandle(i)=plot(data.figurehandles.histogram_axes,data.volumes(dvs).histogram_positions(i),data.volumes(dvs).histogram_alpha(i)*data.volumes(dvs).histogram_maxy,'bo','MarkerFaceColor',data.volumes(dvs).histogram_colors(i,:)); set(data.volumes(dvs).histogram_pointhandle(i),'ButtonDownFcn','viewer3d(''pointHistogramButtonDownFcn'',gcbo,[],guidata(gcbo))'); end % For detection of mouse up, down and in histogram figure. set(data.figurehandles.histogram, 'WindowButtonDownFcn','viewer3d(''HistogramButtonDownFcn'',gcbo,[],guidata(gcbo))'); set(data.figurehandles.histogram, 'WindowButtonMotionFcn','viewer3d(''HistogramButtonMotionFcn'',gcbo,[],guidata(gcbo))'); set(data.figurehandles.histogram, 'WindowButtonUpFcn','viewer3d(''HistogramButtonUpFcn'',gcbo,[],guidata(gcbo))'); setMyData(data); function pointHistogramButtonDownFcn(hObject, eventdata, handles) data=getMyData(); if(isempty(data)), return, end dvs=data.volume_select; data.mouse.button=get(data.figurehandles.histogram,'SelectionType'); if(strcmp(data.mouse.button,'normal')) data.volumes(dvs).histogram_pointselected=find(data.volumes(dvs).histogram_pointhandle==gcbo); data.volumes(dvs).histogram_pointselectedhandle=gcbo; set(data.volumes(dvs).histogram_pointselectedhandle, 'MarkerSize',8); setMyData(data); elseif(strcmp(data.mouse.button,'extend')) data.volumes(dvs).histogram_pointselected=find(data.volumes(dvs).histogram_pointhandle==gcbo); data.volumes(dvs).histogram_colors(data.volumes(dvs).histogram_pointselected,:)=rand(1,3); data.volumes(dvs).histogram_pointselected=[]; setMyData(data); drawHistogramPoints(); createAlphaColorTable(); % Show the data histogram_handles=guidata(data.figurehandles.histogram); if(get(histogram_handles.checkbox_auto_update,'value')) show3d(false,true); else show3d(true,true); end elseif(strcmp(data.mouse.button,'alt')) data.volumes(dvs).histogram_pointselected=find(data.volumes(dvs).histogram_pointhandle==gcbo); data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected)=[]; data.volumes(dvs).histogram_colors(data.volumes(dvs).histogram_pointselected,:)=[]; data.volumes(dvs).histogram_alpha(data.volumes(dvs).histogram_pointselected)=[]; data.volumes(dvs).histogram_pointselected=[]; setMyData(data); drawHistogramPoints(); createAlphaColorTable(); % Show the data histogram_handles=guidata(data.figurehandles.histogram); if(get(histogram_handles.checkbox_auto_update,'value')) show3d(false,true); else show3d(true,true); end end function HistogramButtonDownFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) function HistogramButtonUpFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end dvs=data.volume_select; if(~isempty(data.volumes(dvs).histogram_pointselected)) set(data.volumes(dvs).histogram_pointselectedhandle, 'MarkerSize',6); data.volumes(dvs).histogram_pointselected=[]; setMyData(data); createAlphaColorTable(); % Show the data histogram_handles=guidata(data.figurehandles.histogram); if(get(histogram_handles.checkbox_auto_update,'value')) allshow3d(false,true); else allshow3d(true,true); end end function Histogram_pushbutton_update_view_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_update_view (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) allshow3d(false,true) function HistogramButtonMotionFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) cursor_position_in_histogram_axes(hObject,handles); data=getMyData(); if(isempty(data)), return, end dvs=data.volume_select; if(~isempty(data.volumes(dvs).histogram_pointselected)) % Set point to location mouse data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected)=data.volumes(dvs).histogram_mouse_position(1,1); data.volumes(dvs).histogram_alpha(data.volumes(dvs).histogram_pointselected)=data.volumes(dvs).histogram_mouse_position(1,2); % Correct new location if(data.volumes(dvs).histogram_alpha(data.volumes(dvs).histogram_pointselected)<0), data.volumes(dvs).histogram_alpha(data.volumes(dvs).histogram_pointselected)=0; end if(data.volumes(dvs).histogram_alpha(data.volumes(dvs).histogram_pointselected)>1), data.volumes(dvs).histogram_alpha(data.volumes(dvs).histogram_pointselected)=1; end if(data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected)<data.volumes(dvs).volumemin), data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected)=data.volumes(dvs).volumemin; end if(data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected)>data.volumes(dvs).volumemax), data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected)=data.volumes(dvs).volumemax; end if((data.volumes(dvs).histogram_pointselected>1)&&(data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected-1)>data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected))) data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected)=data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected-1); end if((data.volumes(dvs).histogram_pointselected<length(data.volumes(dvs).histogram_positions))&&(data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected+1)<data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected))) data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected)=data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected+1); end % Move point set(data.volumes(dvs).histogram_pointselectedhandle, 'xdata', data.volumes(dvs).histogram_positions(data.volumes(dvs).histogram_pointselected)); set(data.volumes(dvs).histogram_pointselectedhandle, 'ydata', data.volumes(dvs).histogram_alpha(data.volumes(dvs).histogram_pointselected)); % Move line set(data.volumes(dvs).histogram_linehandle, 'xdata',data.volumes(dvs).histogram_positions); set(data.volumes(dvs).histogram_linehandle, 'ydata',data.volumes(dvs).histogram_alpha); end setMyData(data); function lineHistogramButtonDownFcn(hObject, eventdata, handles) data=getMyData(); if(isempty(data)), return, end dvs=data.volume_select; % New point on mouse location newposition=data.volumes(dvs).histogram_mouse_position(1,1); % List for the new markers newpositions=zeros(1,length(data.volumes(dvs).histogram_positions)+1); newalphas=zeros(1,length(data.volumes(dvs).histogram_alpha)+1); newcolors=zeros(size(data.volumes(dvs).histogram_colors,1)+1,3); % Check if the new point is between old points index_down=find(data.volumes(dvs).histogram_positions<=newposition); if(isempty(index_down)) else index_down=index_down(end); index_up=find(data.volumes(dvs).histogram_positions>newposition); if(isempty(index_up)) else index_up=index_up(1); % Copy the (first) old markers to the new lists newpositions(1:index_down)=data.volumes(dvs).histogram_positions(1:index_down); newalphas(1:index_down)=data.volumes(dvs).histogram_alpha(1:index_down); newcolors(1:index_down,:)=data.volumes(dvs).histogram_colors(1:index_down,:); % Add the new interpolated marker perc=(newposition-data.volumes(dvs).histogram_positions(index_down)) / (data.volumes(dvs).histogram_positions(index_up) - data.volumes(dvs).histogram_positions(index_down)); color=(1-perc)*data.volumes(dvs).histogram_colors(index_down,:)+perc*data.volumes(dvs).histogram_colors(index_up,:); alpha=(1-perc)*data.volumes(dvs).histogram_alpha(index_down)+perc*data.volumes(dvs).histogram_alpha(index_up); newpositions(index_up)=newposition; newalphas(index_up)=alpha; newcolors(index_up,:)=color; % Copy the (last) old markers to the new lists newpositions(index_up+1:end)=data.volumes(dvs).histogram_positions(index_up:end); newalphas(index_up+1:end)=data.volumes(dvs).histogram_alpha(index_up:end); newcolors(index_up+1:end,:)=data.volumes(dvs).histogram_colors(index_up:end,:); % Make the new lists the used marker lists data.volumes(dvs).histogram_positions=newpositions; data.volumes(dvs).histogram_alpha=newalphas; data.volumes(dvs).histogram_colors=newcolors; end end % Update the histogram window cla(data.figurehandles.histogram_axes); setMyData(data); drawHistogramPoints(); createAlphaColorTable(); % Show the data histogram_handles=guidata(data.figurehandles.histogram); if(get(histogram_handles.checkbox_auto_update,'value')) show3d(false,true); else show3d(true,true); end function cursor_position_in_histogram_axes(hObject,handles) data=getMyData(); if(isempty(data)), return, end dvs=data.volume_select; % % Get position of the mouse in the large axes % p = get(0, 'PointerLocation'); % pf = get(hObject, 'pos'); % p(1:2) = p(1:2)-pf(1:2); % set(data.figurehandles.histogram, 'CurrentPoint', p(1:2)); p = get(data.figurehandles.histogram_axes, 'CurrentPoint'); data.volumes(dvs).histogram_mouse_position=[p(1, 1) p(1, 2)]; setMyData(data); % -------------------------------------------------------------------- function menu_help_Callback(hObject, eventdata, handles) % hObject handle to menu_help (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) web('info.html'); % --- Executes when user attempts to close figure1. function figure1_CloseRequestFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: delete(hObject) closes the figure data=getMyData(); if(isempty(data)), delete(hObject); return, end try if(ishandle(data.figurehandles.histogram)), delete(data.figurehandles.histogram); end if(ishandle(data.figurehandles.qualityspeed)), delete(data.figurehandles.qualityspeed); end if(ishandle(data.figurehandles.console)), delete(data.figurehandles.console); end if(ishandle(data.figurehandles.contrast)), delete(data.figurehandles.contrast); end if(ishandle(data.figurehandles.voxelsize)), delete(data.figurehandles.voxelsize); end if(ishandle(data.figurehandles.lightvector)), delete(data.figurehandles.lightvector); end catch me disp(me.message); end % Remove the data of this figure try rmappdata(gcf,'data3d'); catch end delete(hObject); % -------------------------------------------------------------------- function menu_shiny_Callback(hObject, eventdata, handles) % hObject handle to menu_shiny (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.axes_select=eventdata; data.subwindow(data.axes_select).shading_material='shiny'; set_menu_checks(data); setMyData(data); show3d(false,true); % -------------------------------------------------------------------- function menu_dull_Callback(hObject, eventdata, handles) % hObject handle to menu_dull (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.axes_select=eventdata; data.subwindow(data.axes_select).shading_material='dull'; set_menu_checks(data); setMyData(data); show3d(false,true); % -------------------------------------------------------------------- function menu_metal_Callback(hObject, eventdata, handles) % hObject handle to menu_metal (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.axes_select=eventdata; data.subwindow(data.axes_select).shading_material='metal'; set_menu_checks(data); setMyData(data); show3d(false,true); function menu_combine_Callback(hObject, eventdata, handles) % hObject handle to menu_metal (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.axes_select=eventdata(1); switch(eventdata(2)) case 1 data.subwindow(data.axes_select).combine='trans'; case 2 data.subwindow(data.axes_select).combine='rgb'; end setMyData(data); set_menu_checks(data); show3d(false,true); function button_voxelsize_apply_Callback(hObject, eventdata, handles) data=getMyData(); if(isempty(data)), return, end dvs=data.volume_select; handles_voxelsize=guidata(data.figurehandles.voxelsize); Scales_old=data.volumes(dvs).Scales; data.volumes(dvs).Scales(1)=str2double(get(handles_voxelsize.edit_scax,'String')); data.volumes(dvs).Scales(2)=str2double(get(handles_voxelsize.edit_scay,'String')); data.volumes(dvs).Scales(3)=str2double(get(handles_voxelsize.edit_scaz,'String')); for i=1:data.NumberWindows if(data.volumes(dvs).id==data.subwindow(i).volume_id_select(1)) Zoom_old=data.subwindow(i).Zoom; data.subwindow(i).first_render=true; data.subwindow(i).Zoom=(sqrt(3)./sqrt(sum(data.volumes(dvs).Scales.^2))); data.subwindow(i).viewer_matrix=data.subwindow(i).viewer_matrix*ResizeMatrix((Scales_old.*Zoom_old)./(data.volumes(dvs).Scales.*data.subwindow(i).Zoom)); end end %data=set_initial_view_matrix(data); setMyData(data); show3d(false,true); % -------------------------------------------------------------------- function show3d_Callback(hObject, eventdata, handles) % hObject handle to menu_file (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) if(~isempty(eventdata)) show3d(eventdata(1),eventdata(2)); else show3d(false,false); end % -------------------------------------------------------------------- function UpdatedVolume_Callback(hObject, eventdata, handles) % hObject handle to menu_file (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) dvs=eventdata(1); data=getMyData(); if(isempty(data)), return, end data=makePreviewVolume(data,dvs); data=makeRenderVolume(data,dvs); setMyData(data); allshow3d(true,true); % -------------------------------------------------------------------- function menu_voxelsize_Callback(hObject, eventdata, handles) % hObject handle to menu_voxelsize (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end dvs=eventdata; data.volume_select=dvs; data.figurehandles.voxelsize=viewer3d_voxelsize; setMyData(data); handles_voxelsize=guidata(data.figurehandles.voxelsize); set(handles_voxelsize.edit_volx,'String',num2str(size(data.volumes(dvs).volume,1))); set(handles_voxelsize.edit_voly,'String',num2str(size(data.volumes(dvs).volume,2))); set(handles_voxelsize.edit_volz,'String',num2str(size(data.volumes(dvs).volume,3))); set(handles_voxelsize.edit_scax,'String',num2str(data.volumes(dvs).Scales(1))); set(handles_voxelsize.edit_scay,'String',num2str(data.volumes(dvs).Scales(2))); set(handles_voxelsize.edit_scaz,'String',num2str(data.volumes(dvs).Scales(3))); function button_lightvector_apply_Callback(hObject, eventdata, handles) data=getMyData(); if(isempty(data)), return, end handles_lightvector=guidata(data.figurehandles.lightvector); data.subwindow(data.axes_select).LightVector(1)=str2double(get(handles_lightvector.edit_lightx,'String')); data.subwindow(data.axes_select).LightVector(2)=str2double(get(handles_lightvector.edit_lighty,'String')); data.subwindow(data.axes_select).LightVector(3)=str2double(get(handles_lightvector.edit_lightz,'String')); setMyData(data); show3d(false,true); % -------------------------------------------------------------------- function menu_lightvector_Callback(hObject, eventdata, handles) % hObject handle to menu_voxelsize (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.axes_select=eventdata; data.figurehandles.lightvector=viewer3d_lightvector; setMyData(data); handles_lightvector=guidata(data.figurehandles.lightvector); set(handles_lightvector.edit_lightx,'String',num2str(data.subwindow(data.axes_select).LightVector(1))); set(handles_lightvector.edit_lighty,'String',num2str(data.subwindow(data.axes_select).LightVector(2))); set(handles_lightvector.edit_lightz,'String',num2str(data.subwindow(data.axes_select).LightVector(3))); % -------------------------------------------------------------------- function menu_load_worksp_Callback(hObject, eventdata, handles) % hObject handle to menu_load_worksp (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.figurehandles.workspacevars=viewer3d_workspacevars; setMyData(data) % Get variables in the workspace vars = evalin('base','who'); % Select only variables with 3 dimensions vars3d=[]; for i=1:length(vars), if(evalin('base',['ndims(' vars{i} ')'])>1), vars3d{length(vars3d)+1}=vars{i}; end end % Show the 3D variables in the workspace handles_workspacevars=guidata(data.figurehandles.workspacevars); set(handles_workspacevars.listbox_vars,'String',vars3d); % --- Executes on button press in pushbutton1. function workspacevars_button_load_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end handles_workspacevars=guidata(data.figurehandles.workspacevars); list_entries = get(handles_workspacevars.listbox_vars,'String'); index_selected = get(handles_workspacevars.listbox_vars,'Value'); if length(index_selected) ~= 1 errordlg('You must select one variable') return; else var1 = list_entries{index_selected(1)}; evalin('base',['viewer3d(''load_variable_Callback'',gcf,' var1 ',guidata(gcf))']); end if(ishandle(data.figurehandles.workspacevars)), close(data.figurehandles.workspacevars); end function console_button_clear_Callback(hObject, eventdata, handles) data=getMyData(); if(isempty(data)), return, end data.subwindow(data.axes_select).consoletext=[]; data.subwindow(data.axes_select).consolelines=0; set(data.figurehandles.console_edit,'String',''); setMyData(data); function data=console_addline(data,newline) if(ishandle(data.figurehandles.console)), data.subwindow(data.axes_select).consolelines=data.subwindow(data.axes_select).consolelines+1; data.subwindow(data.axes_select).consoletext{data.subwindow(data.axes_select).consolelines}=newline; if(data.subwindow(data.axes_select).consolelines>14), data.subwindow(data.axes_select).consolelines=14; data.subwindow(data.axes_select).consoletext={data.subwindow(data.axes_select).consoletext{2:end}}; end set(data.figurehandles.console_edit,'String',data.subwindow(data.axes_select).consoletext); end % -------------------------------------------------------------------- function menu_console_Callback(hObject, eventdata, handles) % hObject handle to menu_console (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end keyboard data.figurehandles.console=viewer3d_console; handles_console=guidata(data.figurehandles.console); data.figurehandles.console_edit=handles_console.edit_console; data.subwindow(data.axes_select).consoletext=[]; data.subwindow(data.axes_select).consolelines=0; setMyData(data) set(data.figurehandles.console_edit,'String',''); function menu_compile_files_Callback(hObject, eventdata, handles) % This script will compile all the C files cd('SubFunctions'); clear affine_transform_2d_double; mex affine_transform_2d_double.c image_interpolation.c -v cd('..'); % -------------------------------------------------------------------- function menu_quality_speed_Callback(hObject, eventdata, handles) % hObject handle to menu_quality_speed (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.figurehandles.qualityspeed=viewer3d_qualityspeed; setMyData(data); handles_qualityspeed=guidata(data.figurehandles.qualityspeed); switch(data.config.VolumeScaling) case{25} set(handles_qualityspeed.uipanel_VolumeScaling,'SelectedObject',handles_qualityspeed.radiobutton_scaling25); case{50} set(handles_qualityspeed.uipanel_VolumeScaling,'SelectedObject',handles_qualityspeed.radiobutton_scaling50); case{100} set(handles_qualityspeed.uipanel_VolumeScaling,'SelectedObject',handles_qualityspeed.radiobutton_scaling100); case{200} set(handles_qualityspeed.uipanel_VolumeScaling,'SelectedObject',handles_qualityspeed.radiobutton_scaling200); end switch(data.config.PreviewVolumeSize) case{32} set(handles_qualityspeed.uipanel_PreviewVolumeSize,'SelectedObject',handles_qualityspeed.radiobutton_preview_32); case{64} set(handles_qualityspeed.uipanel_PreviewVolumeSize,'SelectedObject',handles_qualityspeed.radiobutton_preview_64); case{100} set(handles_qualityspeed.uipanel_PreviewVolumeSize,'SelectedObject',handles_qualityspeed.radiobutton_preview_100); end switch(data.config.ImageSizeRender) case{150} set(handles_qualityspeed.uipanel_ImageSizeRender,'SelectedObject',handles_qualityspeed.radiobutton_rendersize150); case{250} set(handles_qualityspeed.uipanel_ImageSizeRender,'SelectedObject',handles_qualityspeed.radiobutton_rendersize250); case{400} set(handles_qualityspeed.uipanel_ImageSizeRender,'SelectedObject',handles_qualityspeed.radiobutton_rendersize400); case{600} set(handles_qualityspeed.uipanel_ImageSizeRender,'SelectedObject',handles_qualityspeed.radiobutton_rendersize600); case{800} set(handles_qualityspeed.uipanel_ImageSizeRender,'SelectedObject',handles_qualityspeed.radiobutton_rendersize800); case{1400} set(handles_qualityspeed.uipanel_ImageSizeRender,'SelectedObject',handles_qualityspeed.radiobutton_rendersize1400); case{2500} set(handles_qualityspeed.uipanel_ImageSizeRender,'SelectedObject',handles_qualityspeed.radiobutton_rendersize2500); end switch(data.config.ShearInterpolation) case{'bilinear'} set(handles_qualityspeed.uipanel_ShearInterpolation,'SelectedObject',handles_qualityspeed.radiobutton_shear_int_bilinear); case{'nearest'} set(handles_qualityspeed.uipanel_ShearInterpolation,'SelectedObject',handles_qualityspeed.radiobutton_shear_int_nearest); end switch(data.config.WarpInterpolation) case{'bicubic'} set(handles_qualityspeed.uipanel_WarpInterpolation,'SelectedObject',handles_qualityspeed.radiobutton_warp_int_bicubic); case{'bilinear'} set(handles_qualityspeed.uipanel_WarpInterpolation,'SelectedObject',handles_qualityspeed.radiobutton_warp_int_bilinear); case{'nearest'} set(handles_qualityspeed.uipanel_WarpInterpolation,'SelectedObject',handles_qualityspeed.radiobutton_warp_int_nearest); end set(handles_qualityspeed.checkbox_prerender,'Value',data.config.PreRender); set(handles_qualityspeed.checkbox_storexyz,'Value',data.config.StoreXYZ); % --- Executes on button press in pushbutton_applyconfig. function qualityspeed_pushbutton_applyconfig_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_applyconfig (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end handles_qualityspeed=guidata(data.figurehandles.qualityspeed); VolumeScaling=get(get(handles_qualityspeed.uipanel_VolumeScaling,'SelectedObject'),'Tag'); PreviewVolumeSize=get(get(handles_qualityspeed.uipanel_PreviewVolumeSize,'SelectedObject'),'Tag'); ShearInterpolation=get(get(handles_qualityspeed.uipanel_ShearInterpolation,'SelectedObject'),'Tag'); WarpInterpolation=get(get(handles_qualityspeed.uipanel_WarpInterpolation,'SelectedObject'),'Tag'); ImageSizeRender=get(get(handles_qualityspeed.uipanel_ImageSizeRender,'SelectedObject'),'Tag'); VolumeScaling=str2double(VolumeScaling(20:end)); ImageSizeRender=str2double(ImageSizeRender(23:end)); PreviewVolumeSize=str2double(PreviewVolumeSize(21:end)); data.config.ShearInterpolation=ShearInterpolation(23:end); data.config.WarpInterpolation=WarpInterpolation(22:end); data.config.PreRender=get(handles_qualityspeed.checkbox_prerender,'Value'); data.config.StoreXYZ=get(handles_qualityspeed.checkbox_storexyz,'Value'); if(ImageSizeRender~=data.config.ImageSizeRender) s=data.config.ImageSizeRender/ImageSizeRender; data.subwindow(data.axes_select).viewer_matrix=data.subwindow(data.axes_select).viewer_matrix*ResizeMatrix([s s s]); data.config.ImageSizeRender=ImageSizeRender; end scale_change=data.config.VolumeScaling~=VolumeScaling; if(scale_change) data.config.VolumeScaling=VolumeScaling; for dvs=1:length(data.volumes) data=makeRenderVolume(data,dvs); end end if(data.config.PreviewVolumeSize~=PreviewVolumeSize) data.config.PreviewVolumeSize=PreviewVolumeSize; for dvs=1:length(data.volumes) data=makePreviewVolume(data,dvs); end end for dvs=1:length(data.volumes) data.volume_id_select(1)=data.volumes(dvs).id; if((isempty(data.volumes(dvs).volumey)||scale_change)&&data.config.StoreXYZ) data=makeVolumeXY(data); end if(~data.config.StoreXYZ) data.volumes(dvs).volumex=[]; data.volumes(dvs).volumey=[]; end end if((isempty(data.volumes(dvs).normals)||scale_change)&&data.config.PreRender) % Make normals for dvs=1:length(data.volumes) data=computeNormals(data,dvs); end end if(~data.config.PreRender) data.volumes(dvs).normals=[]; end data.subwindow(data.axes_select).first_render=true; setMyData(data); show3d(false,true); function data=makeVolumeXY(data,dvs) if(data.config.StoreXYZ) data.volumes(dvs).volumex=shiftdim(data.volumes(dvs).volume,1); data.volumes(dvs).volumey=shiftdim(data.volumes(dvs).volume,2); else data.volumes(dvs).volumex=[]; data.volumes(dvs).volumey=[]; end function data=computeNormals(data,dvs) if(data.config.PreRender) % Pre computer Normals for faster shading rendering. [fy,fx,fz]=gradient(imgaussian(double(data.volumes(dvs).volume),1/2)); flength=sqrt(fx.^2+fy.^2+fz.^2)+1e-6; data.volumes(dvs).normals=zeros([size(fx) 3]); data.volumes(dvs).normals(:,:,:,1)=fx./flength; data.volumes(dvs).normals(:,:,:,2)=fy./flength; data.volumes(dvs).normals(:,:,:,3)=fz./flength; else data.volumes(dvs).normals=[]; end function I=imgaussian(I,sigma,siz) % IMGAUSSIAN filters an 1D, 2D or 3D image with an gaussian filter. % This function uses IMFILTER, for the filtering but instead of using % a multidimensional gaussian kernel, it uses the fact that a gaussian % filter can be separated in 1D gaussian kernels. % % J=IMGAUSSIAN(I,SIGMA,SIZE) % % inputs, % I: The 1D, 2D, or 3D input image % SIGMA: The sigma used for the gaussian % SIZE: Kernel size (single value) (default: sigma*6) % % outputs, % J: The gaussian filterd image % % example, % I = im2double(rgb2gray(imread('peppers.png'))); % figure, imshow(imgaussian(I,3)); % % Function is written by D.Kroon University of Twente (October 2008) if(~exist('siz','var')), siz=sigma*6; end % Make 1D gaussian kernel x=-(siz/2)+0.5:siz/2; H = exp(-(x.^2/(2*sigma^2))); H = H/sum(H(:)); % Filter each dimension with the 1D gaussian kernels if(ndims(I)==1) I=imfilter(I,H); elseif(ndims(I)==2) Hx=reshape(H,[length(H) 1]); Hy=reshape(H,[1 length(H)]); I=imfilter(imfilter(I,Hx),Hy); elseif(ndims(I)==3) Hx=reshape(H,[length(H) 1 1]); Hy=reshape(H,[1 length(H) 1]); Hz=reshape(H,[1 1 length(H)]); I=imfilter(imfilter(imfilter(I,Hx),Hy),Hz); else error('imgaussian:input','unsupported input dimension'); end % --- Executes on button press in pushbutton_saveconfig. function qualityspeed_pushbutton_saveconfig_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_saveconfig (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end handles_qualityspeed=guidata(data.figurehandles.qualityspeed); VolumeScaling=get(get(handles_qualityspeed.uipanel_VolumeScaling,'SelectedObject'),'Tag'); PreviewVolumeSize=get(get(handles_qualityspeed.uipanel_PreviewVolumeSize,'SelectedObject'),'Tag'); ShearInterpolation=get(get(handles_qualityspeed.uipanel_ShearInterpolation,'SelectedObject'),'Tag'); WarpInterpolation=get(get(handles_qualityspeed.uipanel_WarpInterpolation,'SelectedObject'),'Tag'); ImageSizeRender=get(get(handles_qualityspeed.uipanel_ImageSizeRender,'SelectedObject'),'Tag'); VolumeScaling=str2double(VolumeScaling(20:end)); PreviewVolumeSize=str2double(PreviewVolumeSize(21:end)); data.config.ImageSizeRender=str2double(ImageSizeRender(23:end)); data.config.ShearInterpolation=ShearInterpolation(23:end); data.config.WarpInterpolation=WarpInterpolation(22:end); data.config.PreRender=get(handles_qualityspeed.checkbox_prerender,'Value'); data.config.StoreXYZ=get(handles_qualityspeed.checkbox_storexyz,'Value'); data.config.VolumeScaling=VolumeScaling; data.config.PreviewVolumeSize=PreviewVolumeSize; % Save the default config config=data.config; functiondir=which('viewer3d.m'); functiondir=functiondir(1:end-length('viewer3d.m')); save([functiondir '/default_config.mat'],'config') % -------------------------------------------------------------------- function menu_measure_Callback(hObject, eventdata, handles) % hObject handle to menu_measure (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_config_contrast_Callback(hObject, eventdata, handles) % hObject handle to menu_config_contrast (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.figurehandles.contrast=viewer3d_contrast(data.figurehandles.viewer3d); handles_contrast=guidata(data.figurehandles.contrast); dvs=eventdata; data.volume_select=dvs; c=(data.volumes(dvs).volumemin+data.volumes(dvs).volumemax)/2; dmin=c-data.volumes(dvs).volumemin; dmax=data.volumes(dvs).volumemax-c; amin=c-dmin*4; amax=c+dmax*4; set(handles_contrast.slider_window_width,'Min',0); set(handles_contrast.slider_window_width,'Max',amax); set(handles_contrast.slider_window_level,'Min',amin); set(handles_contrast.slider_window_level,'Max',amax); data.volumes(dvs).WindowWidth=min(max(data.volumes(dvs).WindowWidth,0),amax); data.volumes(dvs).WindowLevel=min(max(data.volumes(dvs).WindowLevel,amin),amax); set(handles_contrast.slider_window_width,'value',data.volumes(dvs).WindowWidth); set(handles_contrast.slider_window_level,'value',data.volumes(dvs).WindowLevel); set(handles_contrast.edit_window_width,'String',num2str(data.volumes(dvs).WindowWidth)); set(handles_contrast.edit_window_level,'String',num2str(data.volumes(dvs).WindowLevel)); setMyData(data); % -------------------------------------------------------------------- function menu_measure_distance_Callback(hObject, eventdata, handles) % hObject handle to menu_measure_distance (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.mouse.button='select_distance'; data.mouse.action='measure_distance'; setMyData(data); set_mouse_shape('select_distance',data) % -------------------------------------------------------------------- function menu_measure_roi_Callback(hObject, eventdata, handles) % hObject handle to menu_measure_roi (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.mouse.button='select_roi'; data.mouse.action='measure_roi'; setMyData(data); set_mouse_shape('select_roi',data) % -------------------------------------------------------------------- function menu_segment_roi_Callback(hObject, eventdata, handles) % hObject handle to menu_measure_roi (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.mouse.button='select_roi'; data.mouse.action='segment_roi'; setMyData(data); viewer3d_segment; set_mouse_shape('select_roi',data) function data=checkvolumetype(data,nv) if(nargin<2), s=1; e=length(data.volumes); else s=nv; e=nv; end for i=s:e data.volumes(i).volumemin=double(min(data.volumes(i).volume_original(:))); data.volumes(i).volumemax=double(max(data.volumes(i).volume_original(:))); if( data.volumes(i).volumemax==0), data.volumes(i).volumemax=1; end switch(class(data.volumes(i).volume_original)) case {'uint8','uint16','uint32','int8','int16','int32','single','double'} otherwise viewer3d_error({'Unsupported input datatype converted to double'}); data.volumes(i).volume_original=double(data.volumes(i).volume_original); end data.volumes(i).WindowWidth=data.volumes(i).volumemax-data.volumes(i).volumemin; data.volumes(i).WindowLevel=0.5*(data.volumes(i).volumemax+data.volumes(i).volumemin); end % --- Executes on scroll wheel click while the figure is in focus. function figure1_WindowScrollWheelFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata structure with the following fields (see FIGURE) % VerticalScrollCount: signed integer indicating direction and number of clicks % VerticalScrollAmount: number of lines scrolled for each click % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end if(isempty(data.axes_select)), return, end switch data.subwindow(data.axes_select).render_type case {'slicex','slicey','slicez'} handles=guidata(hObject); data=changeslice(eventdata.VerticalScrollCount,handles,data); setMyData(data); show3d(false,true); end % --- Executes on key press with focus on figure1 and none of its controls. function figure1_KeyPressFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata structure with the following fields (see FIGURE) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end if(strcmp(eventdata.Key,'uparrow')), eventdata.Character='+'; end if(strcmp(eventdata.Key,'downarrow')), eventdata.Character='-'; end switch data.subwindow(data.axes_select).render_type case {'slicex','slicey','slicez'} handles=guidata(hObject); switch(eventdata.Character) case '+' data=changeslice(1,handles,data); setMyData(data); show3d(true,true); case '-' data=changeslice(-1,handles,data); setMyData(data); show3d(true,true); case 'r' menu_measure_roi_Callback(hObject, eventdata, handles); case 'd' menu_measure_distance_Callback(hObject, eventdata, handles); case 'l' menu_measure_landmark_Callback(hObject, eventdata, handles); case 'c' menu_segment_roi_Callback(hObject, eventdata, handles); otherwise end otherwise end function data=changeslice(updown,handles,data) dvss=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); switch data.subwindow(data.axes_select).render_type case 'slicex' data.subwindow(data.axes_select).SliceSelected(1)=data.subwindow(data.axes_select).SliceSelected(1)+updown; if(data.subwindow(data.axes_select).SliceSelected(1)>size(data.volumes(dvss).volume_original,1)), data.subwindow(data.axes_select).SliceSelected(1)=size(data.volumes(dvss).volume_original,1); end case 'slicey' data.subwindow(data.axes_select).SliceSelected(2)=data.subwindow(data.axes_select).SliceSelected(2)+updown; if(data.subwindow(data.axes_select).SliceSelected(2)>size(data.volumes(dvss).volume_original,2)), data.subwindow(data.axes_select).SliceSelected(2)=size(data.volumes(dvss).volume_original,2); end case 'slicez' data.subwindow(data.axes_select).SliceSelected(3)=data.subwindow(data.axes_select).SliceSelected(3)+updown; if(data.subwindow(data.axes_select).SliceSelected(3)>size(data.volumes(dvss).volume_original,3)), data.subwindow(data.axes_select).SliceSelected(3)=size(data.volumes(dvss).volume_original,3); end end % Boundary limit data.subwindow(data.axes_select).SliceSelected(data.subwindow(data.axes_select).SliceSelected<1)=1; % Stop measurement data.mouse.action=''; % --- Executes on key release with focus on figure1 and none of its controls. function figure1_KeyReleaseFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata structure with the following fields (see FIGURE) % Key: name of the key that was released, in lower case % Character: character interpretation of the key(s) that was released % Modifier: name(s) of the modifier key(s) (i.e., control, shift) released % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end switch data.subwindow(data.axes_select).render_type case {'slicex','slicey','slicez'} show3d(false,true); end function data=InfoOnScreen(data) if (size(data.subwindow(data.axes_select).total_image,3)==3) I=data.subwindow(data.axes_select).total_image; else % Greyscale to color I(:,:,1)=data.subwindow(data.axes_select).total_image; I(:,:,2)=data.subwindow(data.axes_select).total_image; I(:,:,3)=data.subwindow(data.axes_select).total_image; end if(data.subwindow(data.axes_select).render_type(1)=='s') dvs=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); info=cell(1,5); switch data.subwindow(data.axes_select).render_type case 'slicex' info{1}=['Slice X : ' num2str(data.subwindow(data.axes_select).SliceSelected(1))]; case 'slicey' info{1}=['Slice y : ' num2str(data.subwindow(data.axes_select).SliceSelected(2))]; case 'slicez' info{1}=['Slice Z : ' num2str(data.subwindow(data.axes_select).SliceSelected(3))]; end VL=data.subwindow(data.axes_select).VoxelLocation; VL(1)=min(max(VL(1),1),data.volumes(dvs).Size_original(1)); VL(2)=min(max(VL(2),1),data.volumes(dvs).Size_original(2)); VL(3)=min(max(VL(3),1),data.volumes(dvs).Size_original(3)); info{2}=['ROIs mm^3: ' num2str(data.subwindow(data.axes_select).tVolumemm)]; info{3}=['x,y,z px: ' num2str(VL(1)) ' - ' num2str(VL(2)) ' - ' num2str(VL(3))]; info{4}=['x,y,z mm: ' num2str(VL(1)*data.volumes(dvs).Scales(1)) ' - ' num2str(VL(2)*data.volumes(dvs).Scales(2)) ' - ' num2str(VL(3)*data.volumes(dvs).Scales(3))]; info{5}=['Val: ' num2str(data.volumes(dvs).volume_original(VL(1),VL(2),VL(3)))]; I=bitmaptext(info,I,[1 1],struct('Color',[0 1 0 1])); end data.subwindow(data.axes_select).total_image=I; function I=bitmaptext(lines,I,pos,options) % The function BITMAPTEXT will insert textline(s) on the specified position % in the image. % % I=bitmaptext(Text,Ibackground,Position,options) % % inputs, % Text : Cell array with text lines % Ibackground: the bitmap used as background when a m x n x 3 matrix % color plots are made, when m x n a greyscale plot. If empty [] % autosize to fit text. % Position: x,y position of the text % options: struct with options such as color % % outputs, % Iplot: The bitmap containing the plotted text % % note, % Colors are always [r(ed) g(reen) b(lue) a(pha)], with range 0..1. % when Ibackground is grayscale, the mean of r,g,b is used as grey value. % % options, % options.Color: The color of the text. % options.FontSize: The size of the font, 1,2 or 3 (small,medium,large). % % example, % % % The text consisting of 2 lines % lines={'a_A_j_J?,','ImageText version 1.1'}; % % Background image % I=ones([256 256 3]); % % Plot text into background image % I=bitmaptext(lines,I,[1 1],struct('FontSize',3)); % % Show the result % figure, imshow(I), % % Function is written by D.Kroon University of Twente (March 2009) global character_images; % Process inputs defaultoptions=struct('Color',[0 0 1 1],'FontSize',1); if(~exist('options','var')), options=defaultoptions; else tags = fieldnames(defaultoptions); for i=1:length(tags) if(~isfield(options,tags{i})), options.(tags{i})=defaultoptions.(tags{i}); end end if(length(tags)~=length(fieldnames(options))), warning('register_images:unknownoption','unknown options found'); end end % If single line make it a cell array if(~iscell(lines)), lines={lines}; end if(~exist('I','var')), I=[]; end if(exist('pos','var')), if(length(pos)~=2) error('imagtext:inputs','position must have x,y coordinates'); end else pos=[1 1]; end % Round the position pos=round(pos); % Set the size of the font fsize=options.FontSize; % The character bitmap and character set; character_set='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_+-=[]\;'''',./{}|:"<>?'; if(isempty(character_images)), character_images=load_font(); end % Font parameters Font_sizes_x=[8 10 11]; Font_sizes_y=[13 15 18]; Font_startx=[1 1 1]; Font_starty=[1 14 29]; % Get maximum sentence length lengths=zeros(1,length(lines)); for i=1:length(lines), lengths(i)=length(lines{i}); end max_line_length=max(lengths); % Make text image from the lines lines_image=zeros([(Font_sizes_y(fsize)+4)*length(lines),max_line_length*Font_sizes_x(fsize)],'double'); for j=1:length(lines) line=lines{j}; for i=1:length(line), [t,p]=find(character_set==line(i)); if(~isempty(p)) p=p(1)-1; character_bitmap=character_images(Font_starty(fsize):(Font_starty(fsize)+Font_sizes_y(fsize)-1),Font_startx(fsize)+(1+p*Font_sizes_x(fsize)):Font_startx(fsize)+((p+1)*Font_sizes_x(fsize))); posx=Font_sizes_x(fsize)*(i-1); posy=(Font_sizes_y(fsize)+4)*(j-1); lines_image((1:Font_sizes_y(fsize))+posy,(1:Font_sizes_x(fsize))+posx)=character_bitmap; end end end if(isempty(I)), I=zeros([size(lines_image) 3]); end % Remove part of textimage which will be outside of the output image if(pos(1)<1), lines_image=lines_image(2-pos(1):end,:); pos(1)=1; end if(pos(2)<2), lines_image=lines_image(:,2-pos(2):end); pos(2)=1; end if((pos(1)+size(lines_image,1))>size(I,1)), dif=size(I,1)-(pos(1)+size(lines_image,1)); lines_image=lines_image(1:end+dif,:); end if((pos(2)+size(lines_image,2))>size(I,2)), dif=size(I,2)-(pos(2)+size(lines_image,2)); lines_image=lines_image(:,1:end+dif); end % Make text image the same size as background image I_line=zeros([size(I,1) size(I,2)]); I_line(pos(1):(pos(1)+size(lines_image,1)-1),pos(2):(pos(2)+size(lines_image,2)-1))=lines_image; I_line=I_line*options.Color(4); % Insert the text image into the output image if(~isempty(lines_image)) if(size(I,3)==3) for i=1:3 I(:,:,i)=I(:,:,i).*(1-I_line)+options.Color(i)*(I_line); end else I=I.*(1-I_line)+mean(options.Color(1:3))*(I_line); end end function character_images=load_font() character_images=uint8([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 8 9 9 9 9 9 9 9 9 9 9 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]); character_images=double(character_images)/9; function [x_2d,y_2d]=voxelposition_to_imageposition(x,y,z,data) dvs=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); data.subwindow(data.axes_select).Mview=data.subwindow(data.axes_select).viewer_matrix; switch (data.subwindow(data.axes_select).render_type) case {'slicex'} sizeIin=[size(data.volumes(dvs).volume_original,2) size(data.volumes(dvs).volume_original,3)]; M=[data.subwindow(data.axes_select).Mview(1,2) data.subwindow(data.axes_select).Mview(1,3) data.subwindow(data.axes_select).Mview(1,4); data.subwindow(data.axes_select).Mview(2,2) data.subwindow(data.axes_select).Mview(2,3) data.subwindow(data.axes_select).Mview(2,4); 0 0 1]; case {'slicey'} sizeIin=[size(data.volumes(dvs).volume_original,1) size(data.volumes(dvs).volume_original,3)]; M=[data.subwindow(data.axes_select).Mview(1,1) data.subwindow(data.axes_select).Mview(1,3) data.subwindow(data.axes_select).Mview(1,4); data.subwindow(data.axes_select).Mview(2,1) data.subwindow(data.axes_select).Mview(2,3) data.subwindow(data.axes_select).Mview(2,4); 0 0 1]; % Rotate 90 case {'slicez'} sizeIin=[size(data.volumes(dvs).volume_original,1) size(data.volumes(dvs).volume_original,2)]; M=[data.subwindow(data.axes_select).Mview(1,1) data.subwindow(data.axes_select).Mview(1,2) data.subwindow(data.axes_select).Mview(1,4); data.subwindow(data.axes_select).Mview(2,1) data.subwindow(data.axes_select).Mview(2,2) data.subwindow(data.axes_select).Mview(2,4); 0 0 1]; end switch (data.subwindow(data.axes_select).render_type) case {'slicex'} Tlocalx=y; Tlocaly=z; case {'slicey'} Tlocalx=x; Tlocaly=z; case {'slicez'} Tlocalx=x; Tlocaly=y; end % Calculate center of the input image mean_in=sizeIin/2; x_2d=zeros(1,length(Tlocalx)); y_2d=zeros(1,length(Tlocalx)); Tlocalx=Tlocalx-mean_in(1); Tlocaly=Tlocaly-mean_in(2); for i=1:length(x) vector=M*[Tlocalx(i);Tlocaly(i);1]; x_2d(i)=vector(1); y_2d(i)=vector(2); end % Calculate center of the output image mean_out=[data.config.ImageSizeRender data.config.ImageSizeRender]/2; % Make center of the image coordinates 0,0 x_2d=x_2d+mean_out(1); y_2d=y_2d+mean_out(2); function data=mouseposition_to_voxelposition(data) dvs=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); if(isempty(dvs)), return; end data.subwindow(data.axes_select).Mview=data.subwindow(data.axes_select).viewer_matrix; switch (data.subwindow(data.axes_select).render_type) case {'slicex'} sizeIin=[size(data.volumes(dvs).volume_original,2) size(data.volumes(dvs).volume_original,3)]; M=[data.subwindow(data.axes_select).Mview(1,2) data.subwindow(data.axes_select).Mview(1,3) data.subwindow(data.axes_select).Mview(1,4); data.subwindow(data.axes_select).Mview(2,2) data.subwindow(data.axes_select).Mview(2,3) data.subwindow(data.axes_select).Mview(2,4); 0 0 1]; case {'slicey'} sizeIin=[size(data.volumes(dvs).volume_original,1) size(data.volumes(dvs).volume_original,3)]; M=[data.subwindow(data.axes_select).Mview(1,1) data.subwindow(data.axes_select).Mview(1,3) data.subwindow(data.axes_select).Mview(1,4); data.subwindow(data.axes_select).Mview(2,1) data.subwindow(data.axes_select).Mview(2,3) data.subwindow(data.axes_select).Mview(2,4); 0 0 1]; % Rotate 90 case {'slicez'} sizeIin=[size(data.volumes(dvs).volume_original,1) size(data.volumes(dvs).volume_original,2)]; M=[data.subwindow(data.axes_select).Mview(1,1) data.subwindow(data.axes_select).Mview(1,2) data.subwindow(data.axes_select).Mview(1,4); data.subwindow(data.axes_select).Mview(2,1) data.subwindow(data.axes_select).Mview(2,2) data.subwindow(data.axes_select).Mview(2,4); 0 0 1]; end M=inv(M); % Get the mouse position x_2d=data.subwindow(data.axes_select).mouse_position(2); y_2d=data.subwindow(data.axes_select).mouse_position(1); % To rendered image position x_2d=x_2d*data.config.ImageSizeRender; y_2d=y_2d*data.config.ImageSizeRender; % Calculate center of the input image mean_in=sizeIin/2; % Calculate center of the output image mean_out=[data.config.ImageSizeRender data.config.ImageSizeRender]/2; % Calculate the Transformed coordinates x_2d=x_2d - mean_out(1); y_2d=y_2d - mean_out(2); location(1)= mean_in(1) + M(1,1) * x_2d + M(1,2) *y_2d + M(1,3) * 1; location(2)= mean_in(2) + M(2,1) * x_2d + M(2,2) *y_2d + M(2,3) * 1; switch (data.subwindow(data.axes_select).render_type) case {'slicex'} data.subwindow(data.axes_select).VoxelLocation=[data.subwindow(data.axes_select).SliceSelected(1) location(1) location(2)]; case {'slicey'} data.subwindow(data.axes_select).VoxelLocation=[location(1) data.subwindow(data.axes_select).SliceSelected(2) location(2)]; case {'slicez'} data.subwindow(data.axes_select).VoxelLocation=[location(1) location(2) data.subwindow(data.axes_select).SliceSelected(3)]; end data.subwindow(data.axes_select).VoxelLocation=round(data.subwindow(data.axes_select).VoxelLocation); data.subwindow(data.axes_select).VoxelLocation(data.subwindow(data.axes_select).VoxelLocation<1)=1; if(data.subwindow(data.axes_select).VoxelLocation(1)>size(data.volumes(dvs).volume_original,1)), data.subwindow(data.axes_select).VoxelLocation(1)=size(data.volumes(dvs).volume_original,1); end if(data.subwindow(data.axes_select).VoxelLocation(2)>size(data.volumes(dvs).volume_original,2)), data.subwindow(data.axes_select).VoxelLocation(2)=size(data.volumes(dvs).volume_original,2); end if(data.subwindow(data.axes_select).VoxelLocation(3)>size(data.volumes(dvs).volume_original,3)), data.subwindow(data.axes_select).VoxelLocation(3)=size(data.volumes(dvs).volume_original,3); end % --- Executes on mouse motion over figure - except title and menu. function brightness_contrast_WindowButtonMotionFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end dvs=data.volume_select; if(~isempty(data.figurehandles.contrast)&&ishandle(data.figurehandles.contrast)) handles_contrast=guidata(data.figurehandles.contrast); level=get(handles_contrast.slider_window_level,'value'); width=get(handles_contrast.slider_window_width,'value'); if((width~=data.volumes(dvs).WindowWidth)||(level~=data.volumes(dvs).WindowLevel)) data.volumes(dvs).WindowWidth=width; data.volumes(dvs).WindowLevel=level; set(handles_contrast.edit_window_width,'String',num2str(data.volumes(dvs).WindowWidth)); set(handles_contrast.edit_window_level,'String',num2str(data.volumes(dvs).WindowLevel)); setMyData(data); allshow3d(false,false); end end function brightness_contrast_pushbutton_auto_Callback(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end dvs=data.volume_select; handles_contrast=guidata(data.figurehandles.contrast); data.volumes(dvs).WindowWidth=data.volumes(dvs).volumemax-data.volumes(dvs).volumemin; data.volumes(dvs).WindowLevel=0.5*(data.volumes(dvs).volumemax+data.volumes(dvs).volumemin); set(handles_contrast.slider_window_level,'value',data.volumes(dvs).WindowLevel); set(handles_contrast.slider_window_width,'value',data.volumes(dvs).WindowWidth); setMyData(data); allshow3d(false,false); % -------------------------------------------------------------------- function menu_config_slicescolor_Callback(hObject, eventdata, handles) % hObject handle to menu_config_slicescolor (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); data.axes_select=eventdata; if(data.subwindow(data.axes_select).ColorSlice) data.subwindow(data.axes_select).ColorSlice=false; else data.subwindow(data.axes_select).ColorSlice=true; end setMyData(data); set_menu_checks(data); show3d(false,true); % -------------------------------------------------------------------- function menu_measure_landmark_Callback(hObject, eventdata, handles) % hObject handle to menu_measure_landmark (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.mouse.button='select_landmark'; data.mouse.action='measure_landmark'; setMyData(data); set_mouse_shape('select_landmark',data) % -------------------------------------------------------------------- function menu_data_info_Callback(hObject, eventdata, handles) % hObject handle to menu_data_info (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end dvs=eventdata; viewer3d_dicominfo(data.volumes(dvs).info); % -------------------------------------------------------------------- function menu_addseg_Callback(hObject, eventdata, handles) % hObject handle to menu_data_info (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end dvs=eventdata; volumedata=data.volumes(dvs); Info=[]; Scales=volumedata.Scales; V=zeros(size(volumedata.volume_original),'uint8'); Editable=true; addVolume(V,Scales,Info,Editable); %viewer3d_dicominfo(data.volumes(dvs).info); % -------------------------------------------------------------------- function menu_click_roi_Callback(hObject, eventdata, handles) % hObject handle to menu_click_roi (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.mouse.button='click_roi'; data.mouse.action='click_roi'; setMyData(data); set_mouse_shape('click_roi',data) % -------------------------------------------------------------------- function load_filename1_Callback(hObject, eventdata, handles) % hObject handle to load_filename1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end load_view(data.history.filenames{1}) % -------------------------------------------------------------------- function load_filename2_Callback(hObject, eventdata, handles) % hObject handle to load_filename2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end load_view(data.history.filenames{2}) % -------------------------------------------------------------------- function load_filename3_Callback(hObject, eventdata, handles) % hObject handle to load_filename3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end load_view(data.history.filenames{3}) % -------------------------------------------------------------------- function load_filename4_Callback(hObject, eventdata, handles) % hObject handle to load_filename4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end load_view(data.history.filenames{4}) % -------------------------------------------------------------------- function load_filename5_Callback(hObject, eventdata, handles) % hObject handle to load_filename5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end load_view(data.history.filenames{5}) function showhistory(data) for i=1:5 filename=data.history.filenames{i}; switch(i) case 1, h=data.handles.load_filename1; case 2, h=data.handles.load_filename2; case 3, h=data.handles.load_filename3; case 4, h=data.handles.load_filename4; case 5, h=data.handles.load_filename5; end if(~isempty(filename)) set(h,'Visible','on'); set(h,'Label',['...' filename(max(end-40,1):end)]); else set(h,'Visible','off'); end end % -------------------------------------------------------------------- function menu_windows1_Callback(hObject, eventdata, handles) % hObject handle to menu_windows1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.NumberWindows=1; data=deleteWindows(data); data=addWindows(data); setMyData(data); allshow3d(false,true); % -------------------------------------------------------------------- function menu_windows2_Callback(hObject, eventdata, handles) % hObject handle to menu_windows2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.NumberWindows=2; data=deleteWindows(data); data=addWindows(data); setMyData(data); allshow3d(false,true); % -------------------------------------------------------------------- function menu_windows3_Callback(hObject, eventdata, handles) % hObject handle to menu_windows3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.NumberWindows=3; data=deleteWindows(data); data=addWindows(data); setMyData(data); allshow3d(false,true); % -------------------------------------------------------------------- function menu_windows4_Callback(hObject, eventdata, handles) % hObject handle to menu_windows4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.NumberWindows=4; data=deleteWindows(data); data=addWindows(data); setMyData(data); allshow3d(false,true); function menu_ChangeVolume_Callback(hObject, eventdata, handles) data=getMyData(); if(isempty(data)), return, end s=eventdata(2); if(s>0); switch length(eventdata) case 2 data.subwindow(eventdata(1)).volume_id_select=data.volumes(eventdata(2)).id; case 3 data.subwindow(eventdata(1)).volume_id_select=[data.volumes(eventdata(2)).id; data.volumes(eventdata(3)).id]; case 4 data.subwindow(eventdata(1)).volume_id_select=[data.volumes(eventdata(2)).id; data.volumes(eventdata(3)).id; data.volumes(eventdata(4)).id]; end else data.subwindow(eventdata(1)).volume_id_select=0; data.subwindow(eventdata(1)).render_type='black'; end data.axes_select=eventdata(1); if(s>0) data.subwindow(eventdata(1)).Zoom=(sqrt(3)./sqrt(sum(data.volumes(s).Scales.^2))); data=set_initial_view_matrix(data); data.subwindow(data.axes_select).SliceSelected=round(data.volumes(s).Size/2); end setMyData(data); show3d(false,true); set_menu_checks(data); function menu_ChangeRender_Callback(hObject, eventdata, handles) %#ok<*INUSD,*INUSL> data=getMyData(); if(isempty(data)), return, end if(data.subwindow(eventdata(1)).volume_id_select(1)>0) data.axes_select=eventdata(1); data.subwindow(data.axes_select).render_type=data.rendertypes(eventdata(2)).type; switch data.rendertypes(eventdata(2)).type case {'slicex','slicey','slicez'} data=set_initial_view_matrix(data); end set_menu_checks(data); data.subwindow(data.axes_select).first_render=true; setMyData(data); show3d(false,true); end function data=deleteWindows(data) for i=(data.NumberWindows+1):length(data.subwindow) h=data.subwindow(i).handles.axes; if(~isempty(h)), delete(data.subwindow(i).handles.axes), set(data.subwindow(i).handles.uipanelmenu,'UIContextMenu',uicontextmenu); menubar delete(data.subwindow(i).handles.uipanelmenu), end data.subwindow(i).handles.axes=[]; end function data=addWindows(data) for i=1:data.NumberWindows if(length(data.subwindow)>=i), h=data.subwindow(i).handles.axes; else h=[]; end if(isempty(h)), data.subwindow(i).click_roi=false; data.subwindow(i).tVolumemm=0; data.subwindow(i).VoxelLocation=[1 1 1]; data.subwindow(i).first_render=true; data.subwindow(i).mouse_position_pressed=[0 0]; data.subwindow(i).mouse_position=[0 0]; data.subwindow(i).mouse_position_last=[0 0]; data.subwindow(i).shading_material='shiny'; data.subwindow(i).combine='rgb'; data.subwindow(i).volume_id_select=0; data.subwindow(i).object_id_select=0; data.subwindow(i).first_render=true; data.subwindow(i).ColorSlice=false; data.subwindow(i).render_type='black'; data.subwindow(i).ViewerVector = [0 0 1]; data.subwindow(i).LightVector = [0.5 -0.5 -0.67]; data.subwindow(i).handles.uipanelmenu=uipanel('units','normalized'); data.subwindow(i).handles.axes=axes; set(data.subwindow(i).handles.axes,'units','normalized'); data.subwindow(i).menu.Handle=[]; end end data=addWindowsMenus(data); % Units Normalized Margin switch(data.NumberWindows) case 1 w=1; h=1; makeWindow(data,1,0,0,w,h); case 2 w=0.5; h=1; makeWindow(data,1,0,0,w,h); makeWindow(data,2,0.5,0,w,h); case 3 w=1/3; h=1; makeWindow(data,1,0,0,w,h); makeWindow(data,2,1/3,0,w,h); makeWindow(data,3,2/3,0,w,h); case 4 w=0.5; h=0.5; makeWindow(data,1,0.5,0 ,w,h); makeWindow(data,2,0.5,0.5,w,h); makeWindow(data,3,0 ,0.5,w,h); makeWindow(data,4,0 ,0 ,w,h); end menubar function data=makeWindow(data,id,x,y,w,h) a=0.01; set(data.subwindow(id).handles.axes, 'position', [(x+a/2) (y+a/2) (w-a) (h-0.07-a) ]); set(data.subwindow(id).handles.uipanelmenu, 'position', [x y w h]); function data=addWindowsMenus(data) for i=1:data.NumberWindows % Attach a contextmenu (right-mouse button menu) if(ishandle(data.subwindow(i).menu.Handle)) delete(data.subwindow(i).menu.Handle); data.subwindow(i).menu=[]; end Menu(1).Label='Render'; Menu(1).Tag='menu_render'; Menu(1).Callback=''; for f=1:length(data.rendertypes) Menu(1).Children(f).Label=data.rendertypes(f).label; Menu(1).Children(f).Callback=['viewer3d(''menu_ChangeRender_Callback'',gcbo,[' num2str(i) ' ' num2str(f) '],guidata(gcbo))']; end Menu(2).Label='Volume'; hn=0; for f=0:length(data.volumes) if(f==0), name='None'; g=[]; else name=data.volumes(f).name; g=structfind(data.volumes(f+1:end),'Size_original',data.volumes(f).Size_original); if(~isempty(g)); g=g+f; g=g(1:min(end,2)); end end hn=hn+1; Menu(2).Children(hn).Callback=['viewer3d(''menu_ChangeVolume_Callback'',gcbo,[' num2str(i) ' ' num2str(f) '],guidata(gcbo))']; Menu(2).Children(hn).Label=name; Menu(2).Children(hn).Tag=['wmenu-' num2str(i) '-' num2str(f)]; if(~isempty(g)) hn=hn+1; Menu(2).Children(hn).Callback=['viewer3d(''menu_ChangeVolume_Callback'',gcbo,[' num2str(i) ' ' num2str(f) ' ' num2str(g(1)) '],guidata(gcbo))']; Menu(2).Children(hn).Label=[name ' & ' data.volumes(g(1)).name]; Menu(2).Children(hn).Tag=['wmenu-' num2str(i) '-' num2str(f) '-' num2str(g(1))]; if(length(g)>1) hn=hn+1; Menu(2).Children(hn).Callback=['viewer3d(''menu_ChangeVolume_Callback'',gcbo,[' num2str(i) ' ' num2str(f) ' ' num2str(g(1)) ' ' num2str(g(2)) '],guidata(gcbo))']; Menu(2).Children(hn).Label=[name ' & ' data.volumes(g(1)).name ' & ' data.volumes(g(2)).name]; Menu(2).Children(hn).Tag=['wmenu-' num2str(i) '-' num2str(f) '-' num2str(g(1)) '-' num2str(g(2)) ]; end end end Menu(3).Label='Config'; Menu(3).Tag='menu_config'; Menu(3).Callback='viewer3d(''menu_measure_Callback'',gcbo,[],guidata(gcbo))'; Menu(3).Children(1).Label='Light Vector'; Menu(3).Children(1).Tag='menu_lightvector'; Menu(3).Children(1).Callback=['viewer3d(''menu_lightvector_Callback'',gcbo,' num2str(i) ',guidata(gcbo))']; Menu(3).Children(2).Label='Shading Shiny'; Menu(3).Children(2).Tag='menu_shiny'; Menu(3).Children(2).Callback=['viewer3d(''menu_shiny_Callback'',gcbo,' num2str(i) ',guidata(gcbo))']; Menu(3).Children(3).Label='Shading Dull'; Menu(3).Children(3).Tag='menu_dull'; Menu(3).Children(3).Callback=['viewer3d(''menu_dull_Callback'',gcbo,' num2str(i) ',guidata(gcbo))']; Menu(3).Children(4).Label='Shading Metal'; Menu(3).Children(4).Tag='menu_metal'; Menu(3).Children(4).Callback=['viewer3d(''menu_metal_Callback'',gcbo,' num2str(i) ',guidata(gcbo))']; Menu(3).Children(5).Label='Slices Color'; Menu(3).Children(5).Tag='menu_config_slicescolor'; Menu(3).Children(5).Callback=['viewer3d(''menu_config_slicescolor_Callback'',gcbo,' num2str(i) ',guidata(gcbo))']; Menu(3).Children(6).Label='Combine Transparent'; Menu(3).Children(6).Tag='menu_combine_trans'; Menu(3).Children(6).Callback=['viewer3d(''menu_combine_Callback'',gcbo,[' num2str(i) ' 1],guidata(gcbo))']; Menu(3).Children(7).Label='Combine RGB'; Menu(3).Children(7).Tag='menu_combine_rgb'; Menu(3).Children(7).Callback=['viewer3d(''menu_combine_Callback'',gcbo,[' num2str(i) ' 2],guidata(gcbo))']; Menu(4).Label='Measure'; Menu(4).Tag='menu_measure'; Menu(4).Callback='viewer3d(''menu_measure_Callback'',gcbo,[],guidata(gcbo))'; Menu(4).Children(1).Label='Distance (key D)'; Menu(4).Children(1).Tag='menu_measure_distance'; Menu(4).Children(1).Callback='viewer3d(''menu_measure_distance_Callback'',gcbo,[],guidata(gcbo))'; Menu(4).Children(2).Label='Roi Selection (key R)'; Menu(4).Children(2).Tag='menu_measure_roi'; Menu(4).Children(2).Callback='viewer3d(''menu_measure_roi_Callback'',gcbo,[],guidata(gcbo))'; Menu(4).Children(3).Label='LandMark (key L)'; Menu(4).Children(3).Tag='menu_measure_landmark'; Menu(4).Children(3).Callback='viewer3d(''menu_measure_landmark_Callback'',gcbo,[],guidata(gcbo))'; Menu(5).Label='Segment'; Menu(5).Tag='menu_segment'; Menu(5).Callback='viewer3d(''menu_measure_Callback'',gcbo,[],guidata(gcbo))'; Menu(5).Children(1).Label='Roi Selection (key C)'; Menu(5).Children(1).Tag='menu_segment_roi'; Menu(5).Children(1).Callback='viewer3d(''menu_segment_roi_Callback'',gcbo,[],guidata(gcbo))'; handle_menu=uicontextmenu; Menu=addMenu(handle_menu,Menu); data.subwindow(i).menu.Handle=handle_menu; data.subwindow(i).menu.Children=Menu; set(data.subwindow(i).handles.uipanelmenu,'UIContextMenu',data.subwindow(i).menu.Handle); end menubar set_menu_checks(data); % -------------------------------------------------------------------- function menu_window_Callback(hObject, eventdata, handles) % hObject handle to menu_window (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_volume_ws_Callback(hObject, eventdata, handles) % hObject handle to menu_window (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end volume_select=eventdata; % Get variables in the workspace assignin('base','VolumeData',data.volumes(volume_select).volume_original); assignin('base','VolumeInfo',data.volumes(volume_select).info); assignin('base','VolumeScales',data.volumes(volume_select).Scales); % -------------------------------------------------------------------- function menu_volume_close_Callback(hObject, eventdata, handles) % hObject handle to menu_window (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end volume_select=eventdata; data.volume_id_select(1)=data.volumes(volume_select).id; for i=1:data.NumberWindows if(any(data.subwindow(i).volume_id_select==data.volume_id_select)) data.subwindow(i).volume_id_select=0; data.subwindow(i).render_type='black'; end end delete(data.MenuVolume(volume_select).Handle); data.MenuVolume(volume_select)=[]; data.volumes(volume_select)=[]; data=addWindowsMenus(data); setMyData(data); addMenuVolume(); set_menu_checks(data); allshow3d(false,true); function Menu=showmenu(handle_figure) Menu(1).Label='File'; Menu(1).Tag='menu_file'; Menu(1).Callback='viewer3d(''menu_file_Callback'',gcbo,[],guidata(gcbo))'; Menu(1).Children(1).Label='Load View'; Menu(1).Children(1).Tag='menu_load_view'; Menu(1).Children(1).Callback='viewer3d(''menu_load_view_Callback'',gcbo,[],guidata(gcbo))'; Menu(1).Children(2).Label='Load Workspace Variable'; Menu(1).Children(2).Tag='menu_load_worksp'; Menu(1).Children(2).Callback='viewer3d(''menu_load_worksp_Callback'',gcbo,[],guidata(gcbo))'; Menu(1).Children(3).Label='Open Medical 3D File'; Menu(1).Children(3).Tag='menu_load_data'; Menu(1).Children(3).Callback='viewer3d(''menu_load_data_Callback'',gcbo,[],guidata(gcbo))'; Menu(1).Children(4).Label='Save View'; Menu(1).Children(4).Tag='menu_save_view'; Menu(1).Children(4).Callback='viewer3d(''menu_save_view_Callback'',gcbo,[],guidata(gcbo))'; Menu(1).Children(5).Label='Save Picture'; Menu(1).Children(5).Tag='menu_save_picture'; Menu(1).Children(5).Callback='viewer3d(''menu_save_picture_Callback'',gcbo,[],guidata(gcbo))'; Menu(1).Children(6).Label='filename1'; Menu(1).Children(6).Tag='load_filename1'; Menu(1).Children(6).Callback='viewer3d(''load_filename1_Callback'',gcbo,[],guidata(gcbo))'; Menu(1).Children(7).Label='filename2'; Menu(1).Children(7).Tag='load_filename2'; Menu(1).Children(7).Callback='viewer3d(''load_filename2_Callback'',gcbo,[],guidata(gcbo))'; Menu(1).Children(8).Label='filename3'; Menu(1).Children(8).Tag='load_filename3'; Menu(1).Children(8).Callback='viewer3d(''load_filename3_Callback'',gcbo,[],guidata(gcbo))'; Menu(1).Children(9).Label='filename4'; Menu(1).Children(9).Tag='load_filename4'; Menu(1).Children(9).Callback='viewer3d(''load_filename4_Callback'',gcbo,[],guidata(gcbo))'; Menu(1).Children(10).Label='filename5'; Menu(1).Children(10).Tag='load_filename5'; Menu(1).Children(10).Callback='viewer3d(''load_filename5_Callback'',gcbo,[],guidata(gcbo))'; Menu(2).Label='Window'; Menu(2).Tag='menu_window'; Menu(2).Callback='viewer3d(''menu_window_Callback'',gcbo,[],guidata(gcbo))'; Menu(2).Children(1).Label='One Window'; Menu(2).Children(1).Tag='menu_windows1'; Menu(2).Children(1).Callback='viewer3d(''menu_windows1_Callback'',gcbo,[],guidata(gcbo))'; Menu(2).Children(2).Label='Two Windows'; Menu(2).Children(2).Tag='menu_windows2'; Menu(2).Children(2).Callback='viewer3d(''menu_windows2_Callback'',gcbo,[],guidata(gcbo))'; Menu(2).Children(3).Label='Three Windows'; Menu(2).Children(3).Tag='menu_windows3'; Menu(2).Children(3).Callback='viewer3d(''menu_windows3_Callback'',gcbo,[],guidata(gcbo))'; Menu(2).Children(4).Label='Four Windows'; Menu(2).Children(4).Tag='menu_windows4'; Menu(2).Children(4).Callback='viewer3d(''menu_windows4_Callback'',gcbo,[],guidata(gcbo))'; Menu(3).Label='Config'; Menu(3).Tag='menu_config'; Menu(3).Callback='viewer3d(''menu_config_Callback'',gcbo,[],guidata(gcbo))'; Menu(3).Children(1).Label='Quality v. Speed'; Menu(3).Children(1).Tag='menu_quality_speed'; Menu(3).Children(1).Callback='viewer3d(''menu_quality_speed_Callback'',gcbo,[],guidata(gcbo))'; Menu(3).Children(2).Label='Compile C Files'; Menu(3).Children(2).Tag='menu_compile_files'; Menu(3).Children(2).Callback='viewer3d(''menu_compile_files_Callback'',gcbo,[],guidata(gcbo))'; Menu(4).Label='Help'; Menu(4).Tag='menu_info'; Menu(4).Callback='viewer3d(''menu_info_Callback'',gcbo,[],guidata(gcbo))'; Menu(4).Children(1).Label='Help'; Menu(4).Children(1).Tag='menu_help'; Menu(4).Children(1).Callback='viewer3d(''menu_help_Callback'',gcbo,[],guidata(gcbo))'; Menu(4).Children(2).Label='About'; Menu(4).Children(2).Tag='menu_about'; Menu(4).Children(2).Callback='viewer3d(''menu_about_Callback'',gcbo,[],guidata(gcbo))'; Menu(4).Children(3).Label='Console'; Menu(4).Children(3).Tag='menu_console'; Menu(4).Children(3).Callback='viewer3d(''menu_console_Callback'',gcbo,[],guidata(gcbo))'; %set(figurehandles.figure,'Toolbar','none') %set(figurehandles.figure,'MenuBar','none') Menu=addMenu(handle_figure,Menu); function addMenuVolume() %data.MenuVolume=addMenuVolume(data.figurehandles.viewer3d,data.volumes); data=getMyData(); if(isempty(data)), return, end if(isempty(data.volumes)), return, end % Delete existing volume menus for i=1:length(data.MenuVolume) delete(data.MenuVolume(i).Handle); end MenuVolume=struct; for i=1:length(data.volumes) MenuVolume(i).Label=data.volumes(i).name; MenuVolume(i).Tag='menu_volume'; if(data.volumes(i).Editable) MenuVolume(i).ForegroundColor=[0 0.5 0]; else MenuVolume(i).ForegroundColor=[0 0 1]; end MenuVolume(i).Callback=''; MenuVolume(i).Children(1).Label='WindowLevel&Width'; MenuVolume(i).Children(1).Tag='menu_config_contrast'; MenuVolume(i).Children(1).Callback=['viewer3d(''menu_config_contrast_Callback'',gcbo,' num2str(i) ',guidata(gcbo))']; MenuVolume(i).Children(2).Label='Change Alpha&Colors'; MenuVolume(i).Children(2).Tag='menu_change_alpha_colors'; MenuVolume(i).Children(2).Callback=['viewer3d(''menu_change_alpha_colors_Callback'',gcbo,' num2str(i) ',guidata(gcbo))']; MenuVolume(i).Children(3).Label='Voxel Size'; MenuVolume(i).Children(3).Tag='menu_voxelsize'; MenuVolume(i).Children(3).Callback=['viewer3d(''menu_voxelsize_Callback'',gcbo,' num2str(i) ',guidata(gcbo))']; MenuVolume(i).Children(4).Label='Data Info'; MenuVolume(i).Children(4).Tag='menu_data_info'; MenuVolume(i).Children(4).Callback=['viewer3d(''menu_data_info_Callback'',gcbo,' num2str(i) ',guidata(gcbo))']; MenuVolume(i).Children(5).Label='Add Empty(Segment)Volume'; MenuVolume(i).Children(5).Tag='menu_add_segvol'; MenuVolume(i).Children(5).Callback=['viewer3d(''menu_addseg_Callback'',gcbo,' num2str(i) ',guidata(gcbo))']; MenuVolume(i).Children(6).Label='Volume to Workspace'; MenuVolume(i).Children(6).Tag='menu_volume_ws'; MenuVolume(i).Children(6).Callback=['viewer3d(''menu_volume_ws_Callback'',gcbo,' num2str(i) ',guidata(gcbo))']; MenuVolume(i).Children(7).Label='Close'; MenuVolume(i).Children(7).Tag='menu_volume_close'; MenuVolume(i).Children(7).Callback=['viewer3d(''menu_volume_close_Callback'',gcbo,' num2str(i) ',guidata(gcbo))']; end data.MenuVolume=addMenu(data.figurehandles.viewer3d,MenuVolume); setMyData(data); function Menu=addMenu(handle_figure,Menu) Properties={'Label','Callback','Separator','Checked','Enable','ForegroundColor','Position','ButtonDownFcn','Selected','SelectionHighlight','Visible','UserData'}; for i=1:length(Menu) z2=Menu(i); z2.Handle=uimenu(handle_figure, 'Label',z2.Label); for j=1:length(Properties) Pr=Properties{j}; if(isfield(z2,Pr)) val=z2.(Pr); if(~isempty(val)), set(z2.Handle ,Pr,val); end end end if(isfield(z2,'Children')&&~isempty(z2.Children)) Menu(i).Children=addMenu(z2.Handle,z2.Children); end Menu(i).Handle=z2.Handle; end % --- Executes when figure1 is resized. function figure1_ResizeFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) menubar('ResizeFcn',gcf);
github
jacksky64/imageProcessing-master
render.m
.m
imageProcessing-master/Matlab Viewer3D/render.m
40,381
utf_8
c1baff4ae87d57f8f014f914f1b14c19
function render_image = render(volume,options) % Function RENDER will volume render a image of a 3D volume, % with transperancy, shading and ColorTable. % % I = RENDER(VOLUME,OPTIONS); % % outputs, % I: The rendered image % % inputs, % VOLUME : Input image volume (Data of type double has short render % times uint16 the longest) % OPTIONS: A struct with all the render options and parameters: % OPTIONS.RenderType : Maximum intensitity projections (default) 'mip', % greyscale volume rendering 'bw', color volume rendering % 'color' and volume rendering with shading 'shaded' % OPTIONS.ShearInterp : Interpolation method used in the Shear steps % of the shearwarp algoritm, nearest or (default) bilinear % OPTIONS.WarpInterp : Interpolation method used in the warp step % of the shearwarp algoritm, nearest or (default) % bilinear % OPTIONS.ImageSize : Size of the rendered image, defaults to [400 400] % OPTIONS.Mview : This 4x4 matrix is the viewing matrix % defaults to [1 0 0 0;0 1 0 0;0 0 1 0;0 0 0 1] % OPTIONS.AlphaTable : This Nx1 table is linear interpolated such that % every % voxel intensity gets a specific alpha (transparency) % [0 0.01 0.05 0.1 0.2 1 1 1 1 1] % OPTIONS.ColorTable : This Nx3 table is linear interpolated such that % every voxel intensity gets a specific color. % defaults to [1 0 0;1 0 0;1 0 0;1 0 0;1 0 0;1 0 0;1 0 0] % OPTIONS.LightVector : Light Direction defaults to [0.67 0.33 -0.67] % OPTIONS.ViewerVector : View vector X,Y,Z defaults to [0 0 1] % OPTIONS.ShadingMaterial : The type of material shading : dull, % shiny(default) or metal. % % Optional parameters to speed up rendering: % OPTIONS.VolumeX, OPTIONS.VolumeY : Dimensions shifted Voxel volumes, % Must be used like: % OPTIONS.VolumeX=shiftdim(OPTIONS.Volume,1); % OPTIONS.VolumeY=shiftdim(OPTIONS.Volume,2); % OPTIONS.Normals : The normalized gradient of the voxel volume % Must be used like: % [fy,fx,fz]=gradient(OPTIONS.Volume); % flength=sqrt(fx.^2+fy.^2+fz.^2)+1e-6; % OPTIONS.Normals=zeros([size(fx) 3]); % OPTIONS.Normals(:,:,:,1)=fx./flength; % OPTIONS.Normals(:,:,:,2)=fy./flength; % OPTIONS.Normals(:,:,:,3)=fz./flength; % % example, % %Add paths % functionname='render.m'; % functiondir=which(functionname); % functiondir=functiondir(1:end-length(functionname)); % addpath(functiondir); % addpath([functiondir '/SubFunctions']); % % Load data % load('ExampleData/TestVolume.mat'); V=data.volumes(1).volume_original; % % Type of rendering % options.RenderType = 'shaded'; % % color and alpha table % options.AlphaTable=[0 0 0 0 0 1 1 1 1 1]; % options.ColorTable=[1 0 0;1 0 0;1 0 0;1 0 0;1 0 0;1 0 0;1 0 0]; % % Viewer Matrix % options.Mview=makeViewMatrix([0 0 0],[0.25 0.25 0.25],[0 0 0]); % % Render and show image % figure, % I = render(V,options); % imshow(I); % % Function is written by D.Kroon University of Twente (April 2009) %% Set the default options defaultoptions=struct( ... 'RenderType','mip', ... 'Volume', zeros(3,3,3), ... 'VolumeX', [], ... 'VolumeY', [], ... 'Normals', [], ... 'imax',[], ... 'imin',[], ... 'ShearInterp', 'bilinear', ... 'WarpInterp', 'bilinear', ... 'ImageSize', [400 400], ... 'Mview', [1 0 0 0;0 1 0 0;0 0 1 0;0 0 0 1], ... 'AlphaTable', [0 0.01 0.05 0.1 0.2 1 1 1 1 1], ... 'ColorTable', [1 0 0;1 0 0;1 0 0;1 0 0;1 0 0;1 0 0;1 0 0], ... 'LightVector',[0.67 0.33 -0.67], ... 'ViewerVector',[0 0 1], ... 'SliceSelected', 1, ... 'ColorSlice', false, ... 'ShadingMaterial','shiny'); %% Check the input options if(~exist('options','var')), options=defaultoptions; else tags = fieldnames(defaultoptions); for i=1:length(tags) if(~isfield(options,tags{i})), options.(tags{i})=defaultoptions.(tags{i}); end end if(length(tags)~=length(fieldnames(options))), warning('Render:unknownoption','unknown options found'); end end % Make the data structure from the options structure data=options; if(exist('volume','var')); data.Volume=volume; end %% If black if(strcmp(data.RenderType,'black')) render_image = zeros(data.ImageSize); return end %% Needed to convert intensities to range [0 1] if(isempty(data.imax)) switch class(data.Volume) case 'uint8', data.imax=2^8-1; data.imin=0; case 'uint16', data.imax=2^16-1; data.imin=0; case 'uint32', data.imax=2^32-1; data.imin=0; case 'int8', data.imax=2^7-1; data.imin=-2^7; case 'int16', data.imax=2^15-1; data.imin=-2^15; case 'int32', data.imax=2^31-1; data.imin=-2^31; otherwise, data.imax=max(data.Volume(:)); data.imin=min(data.Volume(:)); end end data.imaxmin=data.imax-data.imin; %% Split ColorTable in R,G,B if(~isempty(data.ColorTable)) if(size(data.ColorTable,2)>size(data.ColorTable,1)), data.ColorTable=data.ColorTable'; end data.ColorTable_r=data.ColorTable(:,1); data.ColorTable_g=data.ColorTable(:,2); data.ColorTable_b=data.ColorTable(:,3); end %% If no 3D but slice render do slicerender if((length(data.RenderType)>5)&&strcmp(data.RenderType(1:5),'slice')) render_image = render_slice(data); return end %% Calculate the Shear and Warp Matrices if(ndims(data.Volume)==2) sizes=[size(data.Volume) 1]; else sizes=size(data.Volume); end [data.Mshear,data.Mwarp2D,data.c]=makeShearWarpMatrix(data.Mview,sizes); data.Mwarp2Dinv=inv(double(data.Mwarp2D)); data.Mshearinv=inv(data.Mshear); %% Store Volume sizes data.Iin_sizex=size(data.Volume,1); data.Iin_sizey=size(data.Volume,2); data.Iin_sizez=size(data.Volume,3); %% Create Shear (intimidate) buffer data.Ibuffer_sizex=ceil(1.7321*max(size(data.Volume))+1); data.Ibuffer_sizey=data.Ibuffer_sizex; switch data.RenderType case {'mip'} data.Ibuffer=zeros([data.Ibuffer_sizex data.Ibuffer_sizey])+data.imin; case {'bw'} data.Ibuffer=zeros([data.Ibuffer_sizex data.Ibuffer_sizey]); otherwise data.Ibuffer=zeros([data.Ibuffer_sizex data.Ibuffer_sizey 3]); end %% Adjust alpha table by voxel length because of rotation and volume size lengthcor=sqrt(1+data.Mshearinv(1,3)^2+data.Mshearinv(2,3)^2)*mean(size(data.Volume))/100; data.AlphaTable=1 - (1-data.AlphaTable).^(1/lengthcor); data.AlphaTable(data.AlphaTable<0)=0; data.AlphaTable(data.AlphaTable>1)=1; %% Shading type -> Phong values switch lower(data.ShadingMaterial) case {'shiny'} data.material=[0.7, 0.6, 0.9, 15]; case {'dull'} data.material=[0.7, 0.8, 0.0, 10]; case {'metal'} data.material=[0.7, 0.3, 1.0, 20]; otherwise data.material=[0.7, 0.6, 0.9, 20]; end %% Normalize Light and Viewer vectors data.LightVector=[data.LightVector(:);0]; data.LightVector=data.LightVector./sqrt(sum(data.LightVector(1:3).^2)); data.ViewerVector=[data.ViewerVector(:);0]; data.ViewerVector=data.ViewerVector./sqrt(sum(data.ViewerVector(1:3).^2)); %% Shear Rendering data = shear(data); data = warp(data); render_image = data.Iout; %% Slice rendering function Iout=render_slice(data) switch (data.RenderType) case {'slicex'} Iin=(double(squeeze(data.Volume(data.SliceSelected,:,:,:)))-data.imin)/data.imaxmin; M=[data.Mview(1,2) data.Mview(1,3) data.Mview(1,4); data.Mview(2,2) data.Mview(2,3) data.Mview(2,4); 0 0 1]; % Rotate 90 case {'slicey'} Iin=(double(squeeze(data.Volume(:,data.SliceSelected,:,:)))-data.imin)/data.imaxmin; M=[data.Mview(1,1) data.Mview(1,3) data.Mview(1,4); data.Mview(2,1) data.Mview(2,3) data.Mview(2,4); 0 0 1]; % Rotate 90 case {'slicez'} Iin=(double(squeeze(data.Volume(:,:,data.SliceSelected,:)))-data.imin)/data.imaxmin; M=[data.Mview(1,1) data.Mview(1,2) data.Mview(1,4); data.Mview(2,1) data.Mview(2,2) data.Mview(2,4); 0 0 1]; end M=inv(M); % Perform the affine transformation switch(data.WarpInterp) case 'nearest', wi=5; case 'bicubic', wi=3; case 'bilinear', wi=1; otherwise, wi=1; end Ibuffer=affine_transform_2d_double(Iin,M,wi,data.ImageSize); if(data.ColorSlice) Ibuffer(Ibuffer<0)=0; Ibuffer(Ibuffer>1)=1; betaC=(length(data.ColorTable_r)-1); indexColor=round(Ibuffer*betaC)+1; % Greyscale to Color Ibuffer=zeros([size(Ibuffer) 3]); Ibuffer(:,:,1)=data.ColorTable_r(indexColor); Ibuffer(:,:,2)=data.ColorTable_g(indexColor); Ibuffer(:,:,3)=data.ColorTable_b(indexColor); Iout=Ibuffer; else Iout=Ibuffer; end %% Shearwarp functions function data=shear(data) switch (data.c) case 1 for z=0:(data.Iin_sizex-1); % Offset calculation xd=(-data.Ibuffer_sizex/2)+data.Mshearinv(1,3)*(z-data.Iin_sizex/2)+data.Iin_sizey/2; yd=(-data.Ibuffer_sizey/2)+data.Mshearinv(2,3)*(z-data.Iin_sizex/2)+data.Iin_sizez/2; xdfloor=floor(xd); ydfloor=floor(yd); %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=data.Iin_sizez-ydfloor; if(pyend>data.Ibuffer_sizey), pyend=data.Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=data.Iin_sizey-xdfloor; if(pxend>data.Ibuffer_sizex), pxend=data.Ibuffer_sizex; end data.py=(pystart+1:pyend-1); data.px=(pxstart+1:pxend-1); if(isempty(data.px)), data.px=pxstart+1; end if(isempty(data.py)), data.py=pystart+1; end % Determine x and y coordinates of pixel(s) which will be come current pixel yBas=data.py+ydfloor; xBas=data.px+xdfloor; switch (data.ShearInterp) case {'bilinear'} xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc=[(1-xCom)*(1-yCom) (1-xCom)*yCom xCom*(1-yCom) xCom*yCom]; if(isempty(data.VolumeX)) % Get the intensities if(data.Iin_sizez>1) slice=double(squeeze(data.Volume(z+1,:,:))); else slice=double(data.Volume(z+1,:))'; end intensity_xyz1=slice(xBas, yBas); intensity_xyz2=slice(xBas, yBas1); intensity_xyz3=slice(xBas1, yBas); intensity_xyz4=slice(xBas1, yBas1); else slice=double(data.VolumeX(:, :,z+1)); intensity_xyz1=slice(xBas, yBas); intensity_xyz2=slice(xBas, yBas1); intensity_xyz3=slice(xBas1, yBas); intensity_xyz4=slice(xBas1, yBas1); end % Calculate the interpolated intensity data.intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4)); otherwise if(isempty(data.VolumeX)) data.intensity_loc=double(squeeze(data.Volume(z+1,xBas, yBas))); else data.intensity_loc=double(data.VolumeX(xBas, yBas,z+1)); end end % Update the shear image buffer switch (data.RenderType) case {'mip'} data=updatebuffer_MIP(data); case {'color'} data=updatebuffer_COLOR(data); case {'bw'} data=updatebuffer_BW(data); case {'shaded'} data=returnnormal(z+1,xBas, yBas,data); data=updatebuffer_SHADED(data); end end case 2 for z=0:(data.Iin_sizey-1), % Offset calculation xd=(-data.Ibuffer_sizex/2)+data.Mshearinv(1,3)*(z-data.Iin_sizey/2)+data.Iin_sizez/2; yd=(-data.Ibuffer_sizey/2)+data.Mshearinv(2,3)*(z-data.Iin_sizey/2)+data.Iin_sizex/2; xdfloor=floor(xd); ydfloor=floor(yd); %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=data.Iin_sizex-ydfloor; if(pyend>data.Ibuffer_sizey), pyend=data.Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=data.Iin_sizez-xdfloor; if(pxend>data.Ibuffer_sizex), pxend=data.Ibuffer_sizex; end data.py=(pystart+1:pyend-1); data.px=(pxstart+1:pxend-1); if(isempty(data.px)), data.px=pxstart+1; end if(isempty(data.py)), data.py=pystart+1; end %Determine x,y coordinates of pixel(s) which will be come current pixel yBas=data.py+ydfloor; xBas=data.px+xdfloor; switch (data.ShearInterp) case {'bilinear'} xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; if(isempty(data.VolumeY)) % Get the intensities slice=double(squeeze(data.Volume(:,z+1,:))); intensity_xyz1=slice(yBas, xBas); intensity_xyz2=slice(yBas1,xBas); intensity_xyz3=slice(yBas, xBas1); intensity_xyz4=slice(yBas1, xBas1); else % Get the intensities slice=double(data.VolumeY(:,:,z+1)); intensity_xyz1=slice(xBas,yBas); intensity_xyz2=slice(xBas,yBas1); intensity_xyz3=slice(xBas1,yBas); intensity_xyz4=slice(xBas1,yBas1); end % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc=[(1-xCom)*(1-yCom) (1-xCom)*yCom xCom*(1-yCom) xCom*yCom]; % Calculate the interpolated intensity data.intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4)); otherwise if(isempty(data.VolumeY)) data.intensity_loc=double(squeeze(data.Volume(yBas, z+1,xBas))); else data.intensity_loc=double(data.VolumeY(xBas,yBas,z+1)); end end % Rotate image if (isempty(data.VolumeY)), data.intensity_loc=data.intensity_loc'; end % Update the shear image buffer switch (data.RenderType) case {'mip'} data=updatebuffer_MIP(data); case {'color'} data=updatebuffer_COLOR(data); case {'bw'} data=updatebuffer_BW(data); case {'shaded'} data=returnnormal(yBas, z+1,xBas,data); data=updatebuffer_SHADED(data); end end case 3 for z=0:(data.Iin_sizez-1), % Offset calculation xd=(-data.Ibuffer_sizex/2)+data.Mshearinv(1,3)*(z-data.Iin_sizez/2)+data.Iin_sizex/2; yd=(-data.Ibuffer_sizey/2)+data.Mshearinv(2,3)*(z-data.Iin_sizez/2)+data.Iin_sizey/2; xdfloor=floor(xd); ydfloor=floor(yd); %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=data.Iin_sizey-ydfloor; if(pyend>data.Ibuffer_sizey), pyend=data.Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=data.Iin_sizex-xdfloor; if(pxend>data.Ibuffer_sizex), pxend=data.Ibuffer_sizex; end data.py=(pystart+1:pyend-1); data.px=(pxstart+1:pxend-1); if(isempty(data.px)), data.px=pxstart+1; end if(isempty(data.py)), data.py=pystart+1; end %Determine x,y coordinates of pixel(s) which will be come current pixel yBas=data.py+ydfloor; xBas=data.px+xdfloor; switch (data.ShearInterp) case {'bilinear'} xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities slice=double(data.Volume(:,:,z+1)); intensity_xyz1=slice(xBas, yBas); intensity_xyz2=slice(xBas, yBas1); intensity_xyz3=slice(xBas1, yBas); intensity_xyz4=slice(xBas1, yBas1); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc=[(1-xCom)*(1-yCom) (1-xCom)*yCom xCom*(1-yCom) xCom*yCom]; % Calculate the interpolated intensity data.intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4)); otherwise data.intensity_loc=double(data.Volume(xBas, yBas, z+1)); end % Update the shear image buffer switch (data.RenderType) case {'mip'} data=updatebuffer_MIP(data); case {'color'} data=updatebuffer_COLOR(data); case {'bw'} data=updatebuffer_BW(data); case {'shaded'} data=returnnormal(xBas,yBas,z+1,data); data=updatebuffer_SHADED(data); end end case 4 for z=(data.Iin_sizex-1):-1:0, % Offset calculation xd=(-data.Ibuffer_sizex/2)+data.Mshearinv(1,3)*(z-data.Iin_sizex/2)+data.Iin_sizey/2; yd=(-data.Ibuffer_sizey/2)+data.Mshearinv(2,3)*(z-data.Iin_sizex/2)+data.Iin_sizez/2; xdfloor=floor(xd); ydfloor=floor(yd); %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=data.Iin_sizez-ydfloor; if(pyend>data.Ibuffer_sizey), pyend=data.Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=data.Iin_sizey-xdfloor; if(pxend>data.Ibuffer_sizex), pxend=data.Ibuffer_sizex; end data.py=(pystart+1:pyend-1); data.px=(pxstart+1:pxend-1); if(isempty(data.px)), data.px=pxstart+1; end if(isempty(data.py)), data.py=pystart+1; end % Determine x,y coordinates of pixel(s) which will be come current pixel yBas=data.py+ydfloor; xBas=data.px+xdfloor; switch (data.ShearInterp) case {'bilinear'} xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; if(isempty(data.VolumeX)) % Get the intensities if(data.Iin_sizez>1) slice=double(squeeze(data.Volume(z+1,:,:))); else slice=double(data.Volume(z+1,:))'; end intensity_xyz1=slice(xBas, yBas); intensity_xyz2=slice(xBas, yBas1); intensity_xyz3=slice(xBas1, yBas); intensity_xyz4=slice(xBas1, yBas1); else slice=double(data.VolumeX(:, :,z+1)); intensity_xyz1=slice(xBas,yBas); intensity_xyz2=slice(xBas,yBas1); intensity_xyz3=slice(xBas1,yBas); intensity_xyz4=slice(xBas1,yBas1); end % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc=[(1-xCom)*(1-yCom) (1-xCom)*yCom xCom*(1-yCom) xCom*yCom]; % Calculate the interpolated intensity data.intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4)); otherwise if(isempty(data.VolumeX)) data.intensity_loc=double(squeeze(data.Volume(z+1,xBas, yBas))); else data.intensity_loc=double(data.VolumeX(xBas, yBas,z+1)); end end % Update the shear image buffer switch (data.RenderType) case {'mip'} data=updatebuffer_MIP(data); case {'color'} data=updatebuffer_COLOR(data); case {'bw'} data=updatebuffer_BW(data); case {'shaded'} data=returnnormal(z+1,xBas,yBas,data); data=updatebuffer_SHADED(data); end end case 5 for z=(data.Iin_sizey-1):-1:0, % Offset calculation xd=(-data.Ibuffer_sizex/2)+data.Mshearinv(1,3)*(z-data.Iin_sizey/2)+data.Iin_sizez/2; yd=(-data.Ibuffer_sizey/2)+data.Mshearinv(2,3)*(z-data.Iin_sizey/2)+data.Iin_sizex/2; xdfloor=floor(xd); ydfloor=floor(yd); %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=data.Iin_sizex-ydfloor; if(pyend>data.Ibuffer_sizey), pyend=data.Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=data.Iin_sizez-xdfloor; if(pxend>data.Ibuffer_sizex), pxend=data.Ibuffer_sizex; end data.py=(pystart+1:pyend-1); data.px=(pxstart+1:pxend-1); if(isempty(data.px)), data.px=pxstart+1; end if(isempty(data.py)), data.py=pystart+1; end %Determine x,y coordinates of pixel(s) which will be come current pixel xBas=data.px+xdfloor; yBas=data.py+ydfloor; switch (data.ShearInterp) case {'bilinear'} xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; if(isempty(data.VolumeY)) % Get the intensities slice=double(squeeze(data.Volume(:, z+1,:))); intensity_xyz1=slice(yBas, xBas); intensity_xyz2=slice(yBas1,xBas); intensity_xyz3=slice(yBas, xBas1); intensity_xyz4=slice(yBas1, xBas1); else % Get the intensities slice=double(data.VolumeY(:,:,z+1)); intensity_xyz1=slice(xBas,yBas); intensity_xyz2=slice(xBas,yBas1); intensity_xyz3=slice(xBas1,yBas); intensity_xyz4=slice(xBas1,yBas1); end % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc=[(1-xCom)*(1-yCom) (1-xCom)*yCom xCom*(1-yCom) xCom*yCom]; % Calculate the interpolated intensity data.intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4)); otherwise if(isempty(data.VolumeY)) data.intensity_loc=double(squeeze(data.Volume(yBas, z+1,xBas))); else data.intensity_loc=double(data.VolumeY(xBas,yBas,z+1)); end end % Rotate image if (isempty(data.VolumeY)), data.intensity_loc=data.intensity_loc'; end % Update the shear image buffer switch (data.RenderType) case {'mip'} data=updatebuffer_MIP(data); case {'color'} data=updatebuffer_COLOR(data); case {'bw'} data=updatebuffer_BW(data); case {'shaded'} data=returnnormal(yBas,z+1,xBas,data); data=updatebuffer_SHADED(data); end end case 6 for z=(data.Iin_sizez-1):-1:0, % Offset calculation xd=(-data.Ibuffer_sizex/2)+data.Mshearinv(1,3)*(z-data.Iin_sizez/2)+data.Iin_sizex/2; yd=(-data.Ibuffer_sizey/2)+data.Mshearinv(2,3)*(z-data.Iin_sizez/2)+data.Iin_sizey/2; xdfloor=floor(xd); ydfloor=floor(yd); %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=data.Iin_sizey-ydfloor; if(pyend>data.Ibuffer_sizey), pyend=data.Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=data.Iin_sizex-xdfloor; if(pxend>data.Ibuffer_sizex), pxend=data.Ibuffer_sizex; end data.py=(pystart+1:pyend-1); data.px=(pxstart+1:pxend-1); if(isempty(data.px)), data.px=pxstart+1; end if(isempty(data.py)), data.py=pystart+1; end % Determine x,y coordinates of pixel(s) which will be come current pixel xBas=data.px+xdfloor; yBas=data.py+ydfloor; switch (data.ShearInterp) case {'bilinear'} xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities slice=double(data.Volume(:, :, z+1)); intensity_xyz1=slice(xBas, yBas); intensity_xyz2=slice(xBas, yBas1); intensity_xyz3=slice(xBas1, yBas ); intensity_xyz4=slice(xBas1, yBas1 ); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc=[(1-xCom)*(1-yCom) (1-xCom)*yCom xCom*(1-yCom) xCom*yCom]; % Calculate the interpolated intensity data.intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4)); otherwise data.intensity_loc=double(data.Volume(xBas, yBas, z+1)); end % Update the shear image buffer switch (data.RenderType) case {'mip'} data=updatebuffer_MIP(data); case {'color'} data=updatebuffer_COLOR(data); case {'bw'} data=updatebuffer_BW(data); case {'shaded'} data=returnnormal(xBas,yBas,z+1,data); data=updatebuffer_SHADED(data); end end end switch (data.RenderType) case {'mip'} if(data.imin~=0), data.Ibuffer=data.Ibuffer-data.imin; end data.Ibuffer=data.Ibuffer/data.imaxmin; end function data=returnnormal(x,y,z,data) % Calculate the normals for a certain pixel / slice or volume. % The Normals are calculated by normalizing the voxel volume gradient. % The central pixel positions x1=x; y1=y; z1=z; % Check if the gradients is delivered by the user if(isempty(data.Normals)) % The forward pixel positions x2=x1+1; y2=y1+1; z2=z1+1; % Everything inside the boundaries checkx=x2>size(data.Volume,1); checky=y2>size(data.Volume,2); checkz=z2>size(data.Volume,3); if(nnz(checkx)>0), x1(checkx)=x1-1; x2(checkx)=size(data.Volume,1); end if(nnz(checky)>0), y1(checky)=y1-1; y2(checky)=size(data.Volume,2); end if(nnz(checkz)>0), z1(checkz)=z1-1; z2(checkz)=size(data.Volume,3); end % Calculate the forward gradient S(:,:,1)=double(squeeze(data.Volume(x2,y1,z1)-data.Volume(x1,y1,z1))); S(:,:,2)=double(squeeze(data.Volume(x1,y2,z1)-data.Volume(x1,y1,z1))); S(:,:,3)=double(squeeze(data.Volume(x1,y1,z2)-data.Volume(x1,y1,z1))); % Normalize the gradient data nlength=sqrt(S(:,:,1).^2+S(:,:,2).^2+S(:,:,3).^2)+0.000001; N=zeros(size(S)); N(:,:,1)=S(:,:,1)./nlength; N(:,:,2)=S(:,:,2)./nlength; N(:,:,3)=S(:,:,3)./nlength; else % Get the user inputed normal information N(:,:,1)=squeeze(data.Normals(x1,y1,z1,1)); N(:,:,2)=squeeze(data.Normals(x1,y1,z1,2)); N(:,:,3)=squeeze(data.Normals(x1,y1,z1,3)); end % Rotate the data in case of certain views if(data.c==2||data.c==5), N2=zeros([size(N,2) size(N,1) 3]); N2(:,:,1)=N(:,:,1)'; N2(:,:,2)=N(:,:,2)'; N2(:,:,3)=N(:,:,3)'; N=N2; end % "Return" the Normals data.N=N; function data=updatebuffer_MIP(data) % Update the current pixel in the shear image buffer check=double(data.intensity_loc>data.Ibuffer(data.px,data.py)); data.Ibuffer(data.px,data.py)=(check).*data.intensity_loc+(1-check).*data.Ibuffer(data.px,data.py); function data=updatebuffer_BW(data) % Calculate index in alpha transparency look up table if(data.imin~=0), data.intensity_loc=data.intensity_loc-data.imin; end if(data.imaxmin~=1), data.intensity_loc=data.intensity_loc./data.imaxmin; end betaA=(length(data.AlphaTable)-1); indexAlpha=round(data.intensity_loc*betaA)+1; % calculate current alphaimage alphaimage=data.AlphaTable(indexAlpha); % 2D volume fix because alphaimage becomes a row instead of column if(data.Iin_sizez==1), alphaimage=reshape(alphaimage,size(data.Ibuffer(data.px,data.py))); end alphaimage_inv=(1-alphaimage); % Update the current pixel in the shear image buffer data.Ibuffer(data.px,data.py)=alphaimage_inv.*data.Ibuffer(data.px,data.py)+alphaimage.*data.intensity_loc; function data=updatebuffer_COLOR(data) % Calculate index in alpha transparency look up table if(data.imin~=0), data.intensity_loc=data.intensity_loc-data.imin; end betaA=(length(data.AlphaTable)-1)/data.imaxmin; betaC=(length(data.ColorTable_r)-1)/data.imaxmin; indexAlpha=round(data.intensity_loc*betaA)+1; % Calculate index in color look up table if(betaA~=betaC) indexColor=round(data.intensity_loc*betaC)+1; else indexColor=indexAlpha; end r=data.ColorTable_r(indexColor); g=data.ColorTable_g(indexColor); b=data.ColorTable_b(indexColor); % calculate current alphaimage alphaimage=data.AlphaTable(indexAlpha); % Update the current pixel in the shear image buffer if(data.Iin_sizez==1), alphaimage=reshape(alphaimage,size(data.Ibuffer(data.px,data.py,1))); r=reshape(r,size(data.Ibuffer(data.px,data.py,1))); g=reshape(g,size(data.Ibuffer(data.px,data.py,1))); b=reshape(b,size(data.Ibuffer(data.px,data.py,1))); end % 2D volume fix because alphaimage becomes a row instead of column alphaimage_inv=(1-alphaimage); data.Ibuffer(data.px,data.py,1)=alphaimage_inv.*data.Ibuffer(data.px,data.py,1)+alphaimage.*r; data.Ibuffer(data.px,data.py,2)=alphaimage_inv.*data.Ibuffer(data.px,data.py,2)+alphaimage.*g; data.Ibuffer(data.px,data.py,3)=alphaimage_inv.*data.Ibuffer(data.px,data.py,3)+alphaimage.*b; function data=updatebuffer_SHADED(data) if(data.imin~=0), data.intensity_loc=data.intensity_loc-data.imin; end betaA=(length(data.AlphaTable)-1)/data.imaxmin; betaC=(length(data.ColorTable_r)-1)/data.imaxmin; % Calculate index in alpha transparency look up table indexAlpha=round(data.intensity_loc*betaA)+1; % Calculate index in color look up table if(betaA~=betaC) indexColor=round(data.intensity_loc*betaC)+1; else indexColor=indexAlpha; end % Rotate the light and view vector data.LightVector2=data.Mview\data.LightVector; data.LightVector2=data.LightVector2./sqrt(sum(data.LightVector2(1:3).^2)); data.ViewerVector2=data.Mview\data.ViewerVector; data.ViewerVector2=data.ViewerVector2./sqrt(sum(data.ViewerVector2(1:3).^2)); Ia=1; Id=data.N(:,:,1)*data.LightVector2(1)+data.N(:,:,2)*data.LightVector2(2)+data.N(:,:,3)*data.LightVector2(3); % R = 2.0*dot(N,L)*N - L; R(:,:,1)=2*Id.*data.N(:,:,1)-data.LightVector2(1); R(:,:,2)=2*Id.*data.N(:,:,2)-data.LightVector2(2); R(:,:,3)=2*Id.*data.N(:,:,3)-data.LightVector2(3); %Is = max(pow(dot(R,V),3),0); Is=-(R(:,:,1)*data.ViewerVector2(1)+R(:,:,2)*data.ViewerVector2(2)+R(:,:,3)*data.ViewerVector2(3)); % No spectacular highlights on "shadow" part Is(Id<0)=0; % Specular exponent Is=Is.^data.material(4); % Phong shading values Ipar=zeros([size(Id) 2]); Ipar(:,:,1)=data.material(1)*Ia+data.material(2)*Id; Ipar(:,:,2)=data.material(3)*Is; % calculate current alphaimage alphaimage=data.AlphaTable(indexAlpha); alphaimage_inv=(1-alphaimage); % Update the current pixel in the shear image buffer data.Ibuffer(data.px,data.py,1)=alphaimage_inv.*data.Ibuffer(data.px,data.py,1)+alphaimage.*(data.ColorTable_r(indexColor).*Ipar(:,:,1)+Ipar(:,:,2)); data.Ibuffer(data.px,data.py,2)=alphaimage_inv.*data.Ibuffer(data.px,data.py,2)+alphaimage.*(data.ColorTable_g(indexColor).*Ipar(:,:,1)+Ipar(:,:,2)); data.Ibuffer(data.px,data.py,3)=alphaimage_inv.*data.Ibuffer(data.px,data.py,3)+alphaimage.*(data.ColorTable_b(indexColor).*Ipar(:,:,1)+Ipar(:,:,2)); function data=warp(data) % This function warp, will warp the shear rendered buffer image % Make Affine matrix M=zeros(3,3); M(1,1)=data.Mwarp2Dinv(1,1); M(2,1)=data.Mwarp2Dinv(2,1); M(1,2)=data.Mwarp2Dinv(1,2); M(2,2)=data.Mwarp2Dinv(2,2); M(1,3)=data.Mwarp2Dinv(1,3)+data.Mshearinv(1,4); M(2,3)=data.Mwarp2Dinv(2,3)+data.Mshearinv(2,4); % Perform the affine transformation switch(data.WarpInterp) case 'nearest', wi=5; case 'bicubic', wi=3; case 'bilinear', wi=1; otherwise, wi=1; end data.Iout=affine_transform_2d_double(data.Ibuffer,M,wi,data.ImageSize); function [Mshear,Mwarp2D,c]=makeShearWarpMatrix(Mview,sizes) % Function MAKESHEARWARPMATRIX splits a View Matrix in to % a shear matrix and warp matrix, for efficient 3D volume rendering. % % [Mshear,Mwarp2D,c]=makeShearWarpMatrix(Mview,sizes) % % inputs, % Mview: The 4x4 viewing matrix % sizes: The sizes of the volume which will be rendered % % outputs, % Mshear: The shear matrix % Mwarp2D: The warp matrix % c: The principal viewing axis 1..6 % % example, % % Mview=makeViewMatrix([45 45 0],[0.5 0.5 0.5],[0 0 0]); % sizes=[512 512]; % [Mshear,Mwarp2D,c]=makeShearWarpMatrix(Mview,sizes) % % Function is written by D.Kroon University of Twente (October 2008) % Find the principal viewing axis Vo=[Mview(1,2)*Mview(2,3) - Mview(2,2)*Mview(1,3); Mview(2,1)*Mview(1,3) - Mview(1,1)*Mview(2,3); Mview(1,1)*Mview(2,2) - Mview(2,1)*Mview(1,2)]; [maxv,c]=max(abs(Vo)); % Choose the corresponding Permutation matrix P switch(c) case 1, %yzx P=[0 1 0 0; 0 0 1 0; 1 0 0 0; 0 0 0 1;]; case 2, % zxy P=[0 0 1 0; 1 0 0 0; 0 1 0 0; 0 0 0 1;]; case 3, % xyz P=[1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1;]; end % Compute the permuted view matrix from Mview and P Mview_p=Mview/P; % 180 degrees rotate detection if(Mview_p(3,3)<0), c=c+3; end % Compute the shear coeficients from the permuted view matrix Si = (Mview_p(2,2)* Mview_p(1,3) - Mview_p(1,2)* Mview_p(2,3)) / (Mview_p(1,1)* Mview_p(2,2) - Mview_p(2,1)* Mview_p(1,2)); Sj = (Mview_p(1,1)* Mview_p(2,3) - Mview_p(2,1)* Mview_p(1,3)) / (Mview_p(1,1)* Mview_p(2,2) - Mview_p(2,1)* Mview_p(1,2)); % Compute the translation between the orgins of standard object coordinates % and intermdiate image coordinates if((c==1)||(c==4)), kmax=sizes(1)-1; end if((c==2)||(c==5)), kmax=sizes(2)-1; end if((c==3)||(c==6)), kmax=sizes(3)-1; end if ((Si>=0)&&(Sj>=0)), Ti = 0; Tj = 0; end if ((Si>=0)&&(Sj<0)), Ti = 0; Tj = -Sj*kmax; end if ((Si<0)&&(Sj>=0)), Ti = -Si*kmax; Tj = 0; end if ((Si<0)&&(Sj<0)), Ti = -Si*kmax; Tj = -Sj*kmax; end % Compute the shear matrix Mshear=[1 0 Si Ti; 0 1 Sj Tj; 0 0 1 0; 0 0 0 1]; % Compute the 2Dwarp matrix Mwarp2D=[Mview_p(1,1) Mview_p(1,2) (Mview_p(1,4)-Ti*Mview_p(1,1)-Tj*Mview_p(1,2)); Mview_p(2,1) Mview_p(2,2) (Mview_p(2,4)-Ti*Mview_p(2,1)-Tj*Mview_p(2,2)); 0 0 1 ]; % Compute the 3Dwarp matrix % Mwarp3Da=[Mview_p(1,1) Mview_p(1,2) (Mview_p(1,3)-Si*Mview_p(1,1)-Sj*Mview_p(1,2)) Mview_p(1,4); % Mview_p(2,1) Mview_p(2,2) (Mview_p(2,3)-Si*Mview_p(2,1)-Sj*Mview_p(2,2)) Mview_p(2,4); % Mview_p(3,1) Mview_p(3,2) (Mview_p(3,3)-Si*Mview_p(3,1)-Sj*Mview_p(3,2)) Mview_p(3,4); % 0 0 0 1 ]; % Mwarp3Db=[1 0 0 -Ti; % 0 1 0 -Tj; % 0 0 1 0; % 0 0 0 1]; % Mwarp3D=Mwarp3Da*Mwarp3Db; % % Control matrix Mview % Mview_control = Mwarp3D*Mshear*P; % disp(Mview) % disp(Mview_control)
github
jacksky64/imageProcessing-master
ReadData3D.m
.m
imageProcessing-master/Matlab Viewer3D/ReadData3D/ReadData3D.m
14,704
utf_8
0cf98e0452dcfacfd88336aba55fe9aa
function varargout = ReadData3D(varargin) % This function ReadData3D allows the user to open medical 3D files. It % supports the following formats : % % Dicom Files ( .dcm , .dicom ) % V3D Philips Scanner ( .v3d ) % GIPL Guys Image Processing Lab ( .gipl ) % HDR/IMG Analyze ( .hdr ) % ISI Files ( .isi ) % NifTi ( .nii ) % RAW files ( .raw , .* ) % VMP BrainVoyager ( .vmp ) % XIF HDllab/ATL ultrasound ( .xif ) % VTK Visualization Toolkit ( .vtk ) % Insight Meta-Image ( .mha, .mhd ) % Micro CT ( .vff ) % PAR/REC Philips ( .par, .rec) % % usage: % % [V,info]=ReadData3D; % % or, % % [V,info]=ReadData3D(filename) % % or, % % [V,info]=ReadData3D(filename,real); % % % outputs, % V : The 3D Volume % info : Struct with info about the data % Always the following fields are present % info.Filename : Name of file % info.Dimensions : Dimensions of Volume % info.PixelDimensions : Size of one pixel / voxel % real : If set to true (default), convert the raw data to % type Single-precision and rescale data to real units % (in CT Hounsfield). When false, it returns the raw-data. % % Warning! % The read functions are not fully implemented as defined in % the file-format standards. thus do not use this function for % critical applications. % % % Function is written by D.Kroon University of Twente (July 2010) % Edit the above text to modify the response to help ReadData3D % Last Modified by GUIDE v2.5 09-Nov-2010 14:12:50 % Begin initialization code - DO NOT EDIT gui_Singleton = 0; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @ReadData3D_OpeningFcn, ... 'gui_OutputFcn', @ReadData3D_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if (nargin>2) && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before ReadData3D is made visible. function ReadData3D_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to ReadData3D (see VARARGIN) % Choose default command line output for ReadData3D handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes ReadData3D wait for user response (see UIRESUME) % uiwait(handles.figure1); %---- Start supported file formats ----% data.fileformat(1).ext='*.dcm'; data.fileformat(1).type='Dicom Files'; data.fileformat(1).folder='dicom'; data.fileformat(1).functioninfo='dicom_read_header'; data.fileformat(1).functionread='dicom_read_volume'; data.fileformat(2).ext='*.gipl'; data.fileformat(2).type='GIPL Guys Image Processing Lab'; data.fileformat(2).folder='gipl'; data.fileformat(2).functioninfo='gipl_read_header'; data.fileformat(2).functionread='gipl_read_volume'; data.fileformat(3).ext='*.hdr'; data.fileformat(3).type='HDR/IMG Analyze'; data.fileformat(3).folder='hdr'; data.fileformat(3).functioninfo='hdr_read_header'; data.fileformat(3).functionread='hdr_read_volume'; data.fileformat(4).ext='*.isi'; data.fileformat(4).type='ISI Files'; data.fileformat(4).folder='isi'; data.fileformat(4).functioninfo='isi_read_header'; data.fileformat(4).functionread='isi_read_volume'; data.fileformat(5).ext='*.nii'; data.fileformat(5).type='NifTi'; data.fileformat(5).folder='nii'; data.fileformat(5).functioninfo='nii_read_header'; data.fileformat(5).functionread='nii_read_volume'; data.fileformat(6).ext='*.raw'; data.fileformat(6).type='RAW files'; data.fileformat(6).folder='raw'; data.fileformat(6).functioninfo='raw_read_header'; data.fileformat(6).functionread='raw_read_volume'; data.fileformat(7).ext='*.v3d'; data.fileformat(7).type='V3D Philips Scanner'; data.fileformat(7).folder='v3d'; data.fileformat(7).functioninfo='v3d_read_header'; data.fileformat(7).functionread='v3d_read_volume'; data.fileformat(8).ext='*.vmp'; data.fileformat(8).type='VMP BrainVoyager'; data.fileformat(8).folder='vmp'; data.fileformat(8).functioninfo='vmp_read_header'; data.fileformat(8).functionread='vmp_read_volume'; data.fileformat(9).ext='*.xif'; data.fileformat(9).type='XIF HDllab/ATL ultrasound'; data.fileformat(9).folder='xif'; data.fileformat(9).functioninfo='xif_read_header'; data.fileformat(9).functionread='xif_read_volume'; data.fileformat(10).ext='*.vtk'; data.fileformat(10).type='VTK Visualization Toolkit'; data.fileformat(10).folder='vtk'; data.fileformat(10).functioninfo='vtk_read_header'; data.fileformat(10).functionread='vtk_read_volume'; data.fileformat(11).ext='*.mha'; data.fileformat(11).type='Insight Meta-Image'; data.fileformat(11).folder='mha'; data.fileformat(11).functioninfo='mha_read_header'; data.fileformat(11).functionread='mha_read_volume'; data.fileformat(12).ext='*.vff'; data.fileformat(12).type='Micro CT'; data.fileformat(12).folder='vff'; data.fileformat(12).functioninfo='vff_read_header'; data.fileformat(12).functionread='vff_read_volume'; data.fileformat(13).ext='*.par'; data.fileformat(13).type='Philips PAR/REC'; data.fileformat(13).folder='par'; data.fileformat(13).functioninfo='par_read_header'; data.fileformat(13).functionread='par_read_volume'; %---- End supported file formats ----% % Get path of ReadData3D functionname='ReadData3D.m'; functiondir=which(functionname); functiondir=functiondir(1:end-length(functionname)); % Add the file-reader functions also to the matlab path addpath([functiondir '/subfunctions']); for i=1:length(data.fileformat), addpath([functiondir '/' data.fileformat(i).folder]); end % Make popuplist file formats fileformatcell=cell(1,length(data.fileformat)); for i=1:length(data.fileformat), fileformatcell{i}=[data.fileformat(i).type ' (' data.fileformat(i).ext ')']; end set(handles.popupmenu_format,'String',fileformatcell); % Check if last filename is present from a previous time data.configfile=[functiondir '/lastfile.mat']; filename=''; fileformatid=1; if(exist(data.configfile,'file')), load(data.configfile); end data.handles=handles; data.lastfilename=[]; data.volume=[]; data.info=[]; % If filename is selected, look if the extention is known found=0; if(~isempty(varargin)) filename=varargin{1}; [pathstr,name,ext]=fileparts(filename); for i=1:length(data.fileformat) if(strcmp(data.fileformat(i).ext(2:end),ext)), found=1; fileformatid=i; end end end % Rescale the databack to original units. if(length(varargin)>1), real=varargin{2}; else real=true; end data.real=real; data.filename=filename; data.fileformatid=fileformatid; set(handles.checkbox_real,'Value',data.real); set(handles.edit_filename,'String',data.filename) set(handles.popupmenu_format,'Value',data.fileformatid); % Store all data setMyData(data); if(found==0) % Show Dialog File selection uiwait(handles.figure1); else % Load the File directly loaddata(); end % --- Outputs from this function are returned to the command line. function varargout = ReadData3D_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure if(ishandle(hObject)) data=getMyData(); else data=[]; end if(~isempty(data)) varargout{1} = data.volume; varargout{2} = data.info; else varargout{1}=[]; varargout{2}=[]; end if(ishandle(hObject)) close(hObject) end function edit_filename_Callback(hObject, eventdata, handles) % hObject handle to edit_filename (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_filename as text % str2double(get(hObject,'String')) returns contents of edit_filename as a double % --- Executes during object creation, after setting all properties. function edit_filename_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_filename (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in pushbutton_browse. function pushbutton_browse_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_browse (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); [extlist extlistid]=FileDialogExtentionList(data); [filename, dirname,filterindex] = uigetfile(extlist, 'Select a dicom file',fileparts(data.filename)); if(filterindex>0) if(extlistid(filterindex)~=0) data.fileformatid=extlistid(filterindex); set( handles.popupmenu_format,'Value',data.fileformatid); end if(filename==0), return; end filename=[dirname filename]; data.filename=filename; setMyData(data); set(handles.edit_filename,'String',data.filename) end function [extlist extlistid]=FileDialogExtentionList(data) extlist=cell(length(data.fileformat)+1,2); extlistid=zeros(length(data.fileformat)+1,1); ext=data.fileformat(data.fileformatid).ext; type=data.fileformat(data.fileformatid).type; extlistid(1)=data.fileformatid; extlist{1,1}=ext; extlist{1,2}=[type ' (' ext ')']; j=1; for i=1:length(data.fileformat); if(i~=data.fileformatid) j=j+1; ext=data.fileformat(i).ext; type=data.fileformat(i).type; extlistid(j)=i; extlist{j,1}=ext; extlist{j,2}=[type ' (' ext ')']; end end extlist{end,1}='*.*'; extlist{end,2}='All Files (*.*)'; function setMyData(data) % Store data struct in figure setappdata(gcf,'dataload3d',data); function data=getMyData() % Get data struct stored in figure data=getappdata(gcf,'dataload3d'); % --- Executes on button press in pushbutton_cancel. function pushbutton_cancel_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_cancel (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) setMyData([]); uiresume; % --- Executes on selection change in popupmenu_format. function popupmenu_format_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_format (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_format contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_format data=getMyData(); data.fileformatid=get( handles.popupmenu_format,'Value'); setMyData(data); % --- Executes during object creation, after setting all properties. function popupmenu_format_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_format (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in pushbutton_load. function pushbutton_load_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_load (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); data.filename=get(handles.edit_filename,'string'); loaddata(); pause(0.1); uiresume function loaddata() data=getMyData(); set(data.handles.figure1,'Pointer','watch'); drawnow('expose'); if(~strcmp(data.lastfilename,data.filename)) % Get info fhandle = str2func( data.fileformat(data.fileformatid).functioninfo); data.info=feval(fhandle,data.filename); data.lastfilename=data.filename; end fhandle = str2func( data.fileformat(data.fileformatid).functionread); data.volume=feval(fhandle,data.info); if(data.real) data.volume=single(data.volume); if(isfield(data.info,'RescaleSlope')), data.volume=data.volume*data.info.RescaleSlope; else disp('RescaleSlope not available, assuming 1') end if(isfield(data.info,'RescaleIntercept')), data.volume=data.volume+data.info.RescaleIntercept; else disp('RescaleIntercept not available, assuming 0') end end setMyData(data); set(data.handles.figure1,'Pointer','arrow') % Save the filename, for the next time this function is used filename=data.filename; fileformatid=data.fileformatid; try save(data.configfile,'filename','fileformatid'); catch ME; disp(ME.message); end % --- Executes on button press in pushbutton_info. function pushbutton_info_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_info (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); data.filename=get(handles.edit_filename,'string'); if(~strcmp(data.lastfilename,data.filename)) % Get info set(data.handles.figure1,'Pointer','watch'); drawnow('expose'); fhandle = str2func( data.fileformat(data.fileformatid).functioninfo); data.info=feval(fhandle,data.filename); data.lastfilename=data.filename; set(data.handles.figure1,'Pointer','arrow') end setMyData(data); % Show info InfoData3D(data.info); % --- Executes on button press in checkbox_real. function checkbox_real_Callback(hObject, eventdata, handles) % hObject handle to checkbox_real (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of checkbox_real data=getMyData(); data.real=get(handles.checkbox_real,'Value'); setMyData(data);
github
jacksky64/imageProcessing-master
dicom_folder_info.m
.m
imageProcessing-master/Matlab Viewer3D/ReadData3D/dicom/dicom_folder_info.m
8,444
utf_8
0c58b3656654e208a0c51854cd32d2e6
function datasets=dicom_folder_info(link,subfolders) % Function DICOM_FOLDER_INFO gives information about all Dicom files % in a certain folder (and subfolders), or of a certain dataset % % datasets=dicom_folder_info(link,subfolders) % % inputs, % link : A link to a folder like "C:\temp" or a link to the first % file of a dicom volume "C:\temp\01.dcm" % subfolders : Boolean if true (default) also look in sub-folders for % dicom files % % ouputs, % datasets : A struct with information about all dicom datasets in a % folder or of the selected dicom-dataset. % (Filenames are already sorted by InstanceNumber) % % % Example output: % datasets=dicom_folder_info('D:\MedicalVolumeData',true); % % datasets = 1x7 struct array with fields % % datasets(1) = % Filenames: {24x1 cell} % Sizes: [512 512 24] % Scales: [0.3320 0.3320 4.4992] % DicomInfo: [1x1 struct] % SeriesInstanceUID: '1.2.840.113619.2.176.2025' % SeriesDescription: 'AX. FSE PD' % SeriesDate: '20070101' % SeriesTime: '120000.000000' % Modality: 'MR' % % datasets(1).Filenames = % 'D:\MedicalVolumeData\IM-0001-0001.dcm' % 'D:\MedicalVolumeData\IM-0001-0002.dcm' % 'D:\MedicalVolumeData\IM-0001-0003.dcm' % % Function is written by D.Kroon University of Twente (June 2010) % If no Folder given, give folder selection dialog if(nargin<1), link = uigetdir(); end % If no subfolders option defined set it to true if(nargin<2), subfolders=true; end % Check if the input is a file or a folder if(isdir(link)) dirname=link; filehash=[]; else dirname = fileparts(link); info=dicominfo(link); SeriesInstanceUID=0; if(isfield(info,'SeriesInstanceUID')), SeriesInstanceUID=info.SeriesInstanceUID; end filehash=string2hash([dirname SeriesInstanceUID]); subfolders=false; end % Make a structure to store all files and folders dicomfilelist.Filename=cell(1,100000); dicomfilelist.InstanceNumber=zeros(1,100000); dicomfilelist.ImagePositionPatient=zeros(100000,3); dicomfilelist.hash=zeros(1,100000); nfiles=0; % Get all dicomfiles in the current folder (and sub-folders) [dicomfilelist,nfiles]=getdicomfilelist(dirname,dicomfilelist,nfiles,filehash,subfolders); if(nfiles==0), datasets=[]; return; end % Sort all dicom files based on a hash from dicom-series number and folder name datasets=sortdicomfilelist(dicomfilelist,nfiles); % Add Dicom information like scaling and size datasets=AddDicomInformation(datasets); function datasets=AddDicomInformation(datasets) for i=1:length(datasets) Scales=[0 0 0]; Sizes=[0 0 0]; SeriesInstanceUID=0; SeriesDescription=''; SeriesDate=''; SeriesTime=''; Modality=''; info=dicominfo(datasets(i).Filenames{1}); nf=length(datasets(i).Filenames); if(isfield(info,'SpacingBetweenSlices')), Scales(3)=info.SpacingBetweenSlices; end if(isfield(info,'PixelSpacing')), Scales(1:2)=info.PixelSpacing(1:2); end if(isfield(info,'ImagerPixelSpacing ')), Scales(1:2)=info.PixelSpacing(1:2); end if(isfield(info,'Rows')), Sizes(1)=info.Rows; end if(isfield(info,'Columns')), Sizes(2)=info.Columns; end if(isfield(info,'NumberOfFrames')), Sizes(3)=info.NumberOfFrames; end if(isfield(info,'SeriesInstanceUID')), SeriesInstanceUID=info.SeriesInstanceUID; end if(isfield(info,'SeriesDescription')), SeriesDescription=info.SeriesDescription; end if(isfield(info,'SeriesDate')),SeriesDate=info.SeriesDate; end if(isfield(info,'SeriesTime')),SeriesTime=info.SeriesTime; end if(isfield(info,'Modality')), Modality=info. Modality; end if(nf>1), Sizes(3)=nf; end if(nf>1) info1=dicominfo(datasets(i).Filenames{2}); if(isfield(info1,'ImagePositionPatient')) dis=abs(info1.ImagePositionPatient(3)-info.ImagePositionPatient(3)); if(dis>0), Scales(3)=dis; end end end datasets(i).Sizes=Sizes; datasets(i).Scales=Scales; datasets(i).DicomInfo=info; datasets(i).SeriesInstanceUID=SeriesInstanceUID; datasets(i).SeriesDescription=SeriesDescription; datasets(i).SeriesDate=SeriesDate; datasets(i).SeriesTime=SeriesTime; datasets(i).Modality= Modality; end function datasets=sortdicomfilelist(dicomfilelist,nfiles) datasetids=unique(dicomfilelist.hash(1:nfiles)); ndatasets=length(datasetids); for i=1:ndatasets h=find(dicomfilelist.hash(1:nfiles)==datasetids(i)); InstanceNumbers=dicomfilelist.InstanceNumber(h); ImagePositionPatient=dicomfilelist.ImagePositionPatient(h,:); if(length(unique(InstanceNumbers))==length(InstanceNumbers)) [temp ind]=sort(InstanceNumbers); else [temp ind]=sort(ImagePositionPatient(:,3)); end h=h(ind); datasets(i).Filenames=cell(length(h),1); for j=1:length(h) datasets(i).Filenames{j}=dicomfilelist.Filename{h(j)}; end end function [dicomfilelist nfiles]=getdicomfilelist(dirname,dicomfilelist,nfiles,filehash,subfolders) dirn=fullfile(dirname,''); if(~isempty(dirn)), filelist = dir(dirn); else filelist = dir; end for i=1:length(filelist) fullfilename=fullfile(dirname,filelist(i).name); if((filelist(i).isdir)) if((filelist(i).name(1)~='.')&&(subfolders)) [dicomfilelist nfiles]=getdicomfilelist(fullfilename ,dicomfilelist,nfiles,filehash,subfolders); end else if(file_is_dicom(fullfilename)) try info=dicominfo(fullfilename); catch me, info=[]; end if(~isempty(info)) InstanceNumber=0; ImagePositionPatient=[0 0 0]; SeriesInstanceUID=0; Filename=info.Filename; if(isfield(info,'InstanceNumber')), InstanceNumber=info.InstanceNumber; end if(isfield(info,'ImagePositionPatient')),ImagePositionPatient=info.ImagePositionPatient; end if(isfield(info,'SeriesInstanceUID')), SeriesInstanceUID=info.SeriesInstanceUID; end hash=string2hash([dirname SeriesInstanceUID]); if(isempty(filehash)||(filehash==hash)) nfiles=nfiles+1; dicomfilelist.Filename{ nfiles}=Filename; dicomfilelist.InstanceNumber( nfiles)=InstanceNumber; dicomfilelist.ImagePositionPatient(nfiles,:)=ImagePositionPatient(:)'; dicomfilelist.hash( nfiles)=hash; end end end end end function isdicom=file_is_dicom(filename) isdicom=false; try fid = fopen(filename, 'r'); status=fseek(fid,128,-1); if(status==0) tag = fread(fid, 4, 'uint8=>char')'; isdicom=strcmpi(tag,'DICM'); end fclose(fid); catch me end function hash=string2hash(str,type) % This function generates a hash value from a text string % % hash=string2hash(str,type); % % inputs, % str : The text string, or array with text strings. % outputs, % hash : The hash value, integer value between 0 and 2^32-1 % type : Type of has 'djb2' (default) or 'sdbm' % % From c-code on : http://www.cse.yorku.ca/~oz/hash.html % % djb2 % this algorithm was first reported by dan bernstein many years ago % in comp.lang.c % % sdbm % this algorithm was created for sdbm (a public-domain reimplementation of % ndbm) database library. it was found to do well in scrambling bits, % causing better distribution of the keys and fewer splits. it also happens % to be a good general hashing function with good distribution. % % example, % % hash=string2hash('hello world'); % disp(hash); % % Function is written by D.Kroon University of Twente (June 2010) % From string to double array str=double(str); if(nargin<2), type='djb2'; end switch(type) case 'djb2' hash = 5381*ones(size(str,1),1); for i=1:size(str,2), hash = mod(hash * 33 + str(:,i), 2^32-1); end case 'sdbm' hash = zeros(size(str,1),1); for i=1:size(str,2), hash = mod(hash * 65599 + str(:,i), 2^32-1); end otherwise error('string_hash:inputs','unknown type'); end
github
jacksky64/imageProcessing-master
dicom_write_volume.m
.m
imageProcessing-master/Matlab Viewer3D/ReadData3D/dicom/dicom_write_volume.m
2,219
utf_8
a3f41a386dcd02f121e040857f26b55a
function dicom_write_volume(Volume,filename,volscale,info) % This function DICOM_WRITE_VOLUME will write a Matlab 3D volume as % a stack of 2D slices in separate dicom files. % % dicom_write_volume(Volume,Filename,Scales,Info) % % inputs, % Volume: The 3D Matlab volume % Filename: The name of the dicom files % Scales: The dimensions of every voxel/pixel % Info: A struct with dicom tags and values % % Function is written by D.Kroon University of Twente (May 2009) % Check inputs if(exist('filename','var')==0), filename=[]; end if(exist('info','var')==0), info=[]; end if(exist('volscale','var')==0), volscale=[1 1 1]; end % Show file dialog if no file name specified if(isempty(filename)) [filename, pathname] = uiputfile('*.dcm', 'Save to Dicom'); filename= [pathname filename]; end % Add dicom tags to info structure if(~isstruct(info)) info=struct; % Make random series number SN=round(rand(1)*1000); % Get date of today today=[datestr(now,'yyyy') datestr(now,'mm') datestr(now,'dd')]; info.SeriesNumber=SN; info.AcquisitionNumber=SN; info.StudyDate=today; info.StudyID=num2str(SN); info.PatientID=num2str(SN); info.PatientPosition='HFS'; info.AccessionNumber=num2str(SN); info.StudyDescription=['StudyMAT' num2str(SN)]; info.SeriesDescription=['StudyMAT' num2str(SN)]; info.Manufacturer='Matlab Convert'; info.SliceThickness=volscale(3); info.PixelSpacing=volscale(1:2); info.SliceLocation=0; end % Remove filename extention pl=find(filename=='.'); if(~isempty(pl)), filename=filename(1:pl-1); end % Read Volume data disp('Writing Dicom Files...'); for slicenum=1:size(Volume,3) filenamedicom=[filename number2string(slicenum) '.dcm']; % Add slice specific dicom info info.InstanceNumber = slicenum; info.SliceLocation = info.SliceLocation+volscale(3); % Write the dicom file disp(['Writing : ' filenamedicom]); dicomwrite(Volume(:,:,slicenum), filenamedicom, info) end function numstr=number2string(num) num=num2str(num); numzeros='000000'; numstr=[numzeros(length(num):end) num];
github
jacksky64/imageProcessing-master
choose_from_list.m
.m
imageProcessing-master/Matlab Viewer3D/ReadData3D/dicom/choose_from_list.m
1,062
utf_8
9a5736ab8c4022c2092521054615df27
function [id,name] = choose_from_list(varargin) % % example : % % c{1}='apple' % c{2}='orange' % c{3}='berries' % [id,name]=choose_from_list(c,'Select a Fruit'); % if(strcmp(varargin{1},'press')) handles=guihandles; id=get(handles.listbox1,'Value'); setMyData(id); uiresume return end % listbox1 Position [12, 36 , 319, 226] % pushbutton [16,12,69,22] % figure position 520 528 348 273 handles.figure1=figure; c=varargin{1}; set(handles.figure1,'tag','figure1','Position',[520 528 348 273],'MenuBar','none','name',varargin{2}); handles.listbox1=uicontrol('tag','listbox1','Style','listbox','Position',[12 36 319 226],'String', c); handles.pushbutton1=uicontrol('tag','pushbutton1','Style','pushbutton','Position',[16 12 69 22],'String','Select','Callback','choose_from_list(''press'');'); uiwait(handles.figure1); id=getMyData(); name=c{id}; close(handles.figure1); function setMyData(data) % Store data struct in figure setappdata(gcf,'data3d',data); function data=getMyData() % Get data struct stored in figure data=getappdata(gcf,'data3d');
github
jacksky64/imageProcessing-master
mha_read_volume.m
.m
imageProcessing-master/Matlab Viewer3D/ReadData3D/mha/mha_read_volume.m
2,646
utf_8
21298fee32e8afb8010bca7385a11d6e
function V = mha_read_volume(info) % Function for reading the volume of a Insight Meta-Image (.mha, .mhd) file % % volume = tk_read_volume(file-header) % % examples: % 1: info = mha_read_header() % V = mha_read_volume(info); % imshow(squeeze(V(:,:,round(end/2))),[]); % % 2: V = mha_read_volume('test.mha'); if(~isstruct(info)), info=mha_read_header(info); end switch(lower(info.DataFile)) case 'local' otherwise % Seperate file info.Filename=fullfile(fileparts(info.Filename),info.DataFile); end % Open file switch(info.ByteOrder(1)) case ('true') fid=fopen(info.Filename','rb','ieee-be'); otherwise fid=fopen(info.Filename','rb','ieee-le'); end switch(lower(info.DataFile)) case 'local' % Skip header fseek(fid,info.HeaderSize,'bof'); otherwise fseek(fid,0,'bof'); end datasize=prod(info.Dimensions)*info.BitDepth/8; switch(info.CompressedData(1)) case 'f' % Read the Data switch(info.DataType) case 'char' V = int8(fread(fid,datasize,'char')); case 'uchar' V = uint8(fread(fid,datasize,'uchar')); case 'short' V = int16(fread(fid,datasize,'short')); case 'ushort' V = uint16(fread(fid,datasize,'ushort')); case 'int' V = int32(fread(fid,datasize,'int')); case 'uint' V = uint32(fread(fid,datasize,'uint')); case 'float' V = single(fread(fid,datasize,'float')); case 'double' V = double(fread(fid,datasize,'double')); end case 't' switch(info.DataType) case 'char', DataType='int8'; case 'uchar', DataType='uint8'; case 'short', DataType='int16'; case 'ushort', DataType='uint16'; case 'int', DataType='int32'; case 'uint', DataType='uint32'; case 'float', DataType='single'; case 'double', DataType='double'; end Z = fread(fid,inf,'uchar=>uint8'); V = zlib_decompress(Z,DataType); end fclose(fid); V = reshape(V,info.Dimensions); function M = zlib_decompress(Z,DataType) import com.mathworks.mlwidgets.io.InterruptibleStreamCopier a=java.io.ByteArrayInputStream(Z); b=java.util.zip.InflaterInputStream(a); isc = InterruptibleStreamCopier.getInterruptibleStreamCopier; c = java.io.ByteArrayOutputStream; isc.copyStream(b,c); M=typecast(c.toByteArray,DataType);
github
jacksky64/imageProcessing-master
raw_read_header.m
.m
imageProcessing-master/Matlab Viewer3D/ReadData3D/raw/raw_read_header.m
19,605
utf_8
4012e947c5ae87248c1a2034fb83864e
function varargout = raw_read_header(varargin) % function for reading header of raw volume file % % info = raw_read_header(filename); % % examples: % 1, info=raw_read_header() % 2, info=raw_read_header('volume.raw'); % Edit the above text to modify the response to help raw_read_header % Last Modified by GUIDE v2.5 06-Jul-2010 14:01:48 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @raw_read_header_OpeningFcn, ... 'gui_OutputFcn', @raw_read_header_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if (nargin>1) && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before raw_read_header is made visible. function raw_read_header_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to raw_read_header (see VARARGIN) % Choose default command line output for raw_read_header handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes raw_read_header wait for user response (see UIRESUME) if(isempty(varargin)) [filename, pathname] = uigetfile({'*.raw', 'Read Raw file (*.raw) ';'*.*', 'All Files (*.*)'}); filename = [pathname filename]; else filename=varargin{1}; end fileInfo = dir(filename); info.Filesize= fileInfo.bytes; info.Filename=filename; setMyData(info); updateGUIvalues(handles); uiwait(handles.figure1); function updateGUIvalues(handles) info=getMyData(); set(handles.text_filesize,'string',['File Size (Bytes) : ' num2str(info.Filesize)]); info.Headersize=str2double(get(handles.edit_header_size,'String')); info.Dimensions(1)=str2double(get(handles.edit_dimx,'String')); info.Dimensions(2)=str2double(get(handles.edit_dimy,'String')); info.Dimensions(3)=str2double(get(handles.edit_dimz,'String')); info.PixelDimensions(1)=str2double(get(handles.edit_scalex,'String')); info.PixelDimensions(2)=str2double(get(handles.edit_scaley,'String')); info.PixelDimensions(3)=str2double(get(handles.edit_scalez,'String')); switch(get(handles.popupmenu_dataclass,'Value')) case 1 info.Nbits=8; info.DataType='uchar'; case 2 info.Nbits=8; info.DataType='char'; case 3 info.Nbits=16; info.DataType='ushort'; case 4 info.Nbits=16; info.DataType='short'; case 5 info.Nbits=32; info.DataType='uint'; case 6 info.Nbits=32; info.DataType='int'; case 7 info.Nbits=32; info.DataType='float'; case 8 info.Nbits=64; info.DataType='double'; end switch(get(handles.popupmenu_data_alligment,'Value')) case 1 info.Alignment='LittleEndian'; case 2 info.Alignment='BigEndian'; end currentbytes=(info.Nbits/8)*info.Dimensions(1)*info.Dimensions(2)*info.Dimensions(3)+info.Headersize; set(handles.text_setbytes,'string',['Current (Bytes) : ' num2str(currentbytes)]); if(currentbytes==info.Filesize) set(handles.pushbutton1,'enable','on'); else set(handles.pushbutton1,'enable','off'); end drawnow setMyData(info); % --- Outputs from this function are returned to the command line. function varargout = raw_read_header_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure info=getMyData(); if(~isempty(info)) varargout{1} = info; end if(ishandle(hObject)) close(hObject) end function edit_header_size_Callback(hObject, eventdata, handles) % hObject handle to edit_header_size (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_header_size as text % str2double(get(hObject,'String')) returns contents of edit_header_size as a double updateGUIvalues(handles); % --- Executes during object creation, after setting all properties. function edit_header_size_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_header_size (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in popupmenu_data_alligment. function popupmenu_data_alligment_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_data_alligment (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_data_alligment contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_data_alligment updateGUIvalues(handles); % --- Executes during object creation, after setting all properties. function popupmenu_data_alligment_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_data_alligment (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on selection change in popupmenu_dataclass. function popupmenu_dataclass_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_dataclass (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_dataclass contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_dataclass updateGUIvalues(handles); % --- Executes during object creation, after setting all properties. function popupmenu_dataclass_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_dataclass (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_dimx_Callback(hObject, eventdata, handles) % hObject handle to edit_dimx (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_dimx as text % str2double(get(hObject,'String')) returns contents of edit_dimx as a double updateGUIvalues(handles); % --- Executes during object creation, after setting all properties. function edit_dimx_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_dimx (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_dimy_Callback(hObject, eventdata, handles) % hObject handle to edit_dimy (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_dimy as text % str2double(get(hObject,'String')) returns contents of edit_dimy as a double updateGUIvalues(handles); % --- Executes during object creation, after setting all properties. function edit_dimy_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_dimy (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_dimz_Callback(hObject, eventdata, handles) % hObject handle to edit_dimz (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_dimz as text % str2double(get(hObject,'String')) returns contents of edit_dimz as a double updateGUIvalues(handles); % --- Executes during object creation, after setting all properties. function edit_dimz_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_dimz (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_scalex_Callback(hObject, eventdata, handles) % hObject handle to edit_scalex (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_scalex as text % str2double(get(hObject,'String')) returns contents of edit_scalex as a double updateGUIvalues(handles); % --- Executes during object creation, after setting all properties. function edit_scalex_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_scalex (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_scaley_Callback(hObject, eventdata, handles) % hObject handle to edit_scaley (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_scaley as text % str2double(get(hObject,'String')) returns contents of edit_scaley as a double updateGUIvalues(handles); % --- Executes during object creation, after setting all properties. function edit_scaley_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_scaley (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_scalez_Callback(hObject, eventdata, handles) % hObject handle to edit_scalez (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_scalez as text % str2double(get(hObject,'String')) returns contents of edit_scalez as a double updateGUIvalues(handles); % --- Executes during object creation, after setting all properties. function edit_scalez_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_scalez (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) updateGUIvalues(handles); uiresume % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) setMyData(0); uiresume function setMyData(data) % Store data struct in figure setappdata(gcf,'rawinfo',data); function data=getMyData() % Get data struct stored in figure data=getappdata(gcf,'rawinfo'); % --- Executes on key press with focus on edit_header_size and none of its controls. function edit_header_size_KeyPressFcn(hObject, eventdata, handles) % hObject handle to edit_header_size (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA) updateGUIvalues(handles); % --- Executes on key press with focus on edit_dimx and none of its controls. function edit_dimx_KeyPressFcn(hObject, eventdata, handles) % hObject handle to edit_dimx (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA) updateGUIvalues(handles); % --- Executes on key press with focus on edit_dimy and none of its controls. function edit_dimy_KeyPressFcn(hObject, eventdata, handles) % hObject handle to edit_dimy (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA) updateGUIvalues(handles); % --- Executes on key press with focus on edit_dimz and none of its controls. function edit_dimz_KeyPressFcn(hObject, eventdata, handles) % hObject handle to edit_dimz (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA) updateGUIvalues(handles); % --- Executes on key press with focus on edit_scalex and none of its controls. function edit_scalex_KeyPressFcn(hObject, eventdata, handles) % hObject handle to edit_scalex (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA) updateGUIvalues(handles); % --- Executes on key press with focus on edit_scaley and none of its controls. function edit_scaley_KeyPressFcn(hObject, eventdata, handles) % hObject handle to edit_scaley (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA) updateGUIvalues(handles); % --- Executes on key press with focus on edit_scalez and none of its controls. function edit_scalez_KeyPressFcn(hObject, eventdata, handles) % hObject handle to edit_scalez (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA) updateGUIvalues(handles); % --- Executes on key press with focus on popupmenu_dataclass and none of its controls. function popupmenu_dataclass_KeyPressFcn(hObject, eventdata, handles) % hObject handle to popupmenu_dataclass (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA) updateGUIvalues(handles); % --- Executes on key press with focus on popupmenu_data_alligment and none of its controls. function popupmenu_data_alligment_KeyPressFcn(hObject, eventdata, handles) % hObject handle to popupmenu_data_alligment (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA) updateGUIvalues(handles); % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) info=getMyData(); currentbytes=(info.Nbits/8)*info.Dimensions(1)*info.Dimensions(2)*info.Dimensions(3); info.Headersize=info.Filesize-currentbytes; set(handles.edit_header_size,'String',num2str(info.Headersize)); updateGUIvalues(handles);
github
jacksky64/imageProcessing-master
par_read_header.m
.m
imageProcessing-master/Matlab Viewer3D/ReadData3D/par/par_read_header.m
9,281
utf_8
d35b414f478ff294a6ca3ab889e04551
function info =par_read_header(filename) % Function for reading the header of a Philips Par / Rec MR V4.* file % % info = par_read_header(filename); % % examples: % 1, info=par_read_header() % 2, info=par_read_header('volume.par'); if(exist('filename','var')==0) [filename, pathname] = uigetfile('*.par', 'Read par-file'); filename = [pathname filename]; end fid=fopen(filename,'rb'); if(fid<0) fprintf('could not open file %s\n',filename); return end info.Filename=filename; mode = -1; nHC=0; nIC=0; nSC=0; while(true) str=fgetl(fid); if ~ischar(str), break, end if(isempty(str)), continue, end if(strfind(str,'= DATA DESCRIPTION FILE =')), mode=0; end if(strfind(str,'= GENERAL INFORMATION =')), mode=1; end if(strfind(str,'= PIXEL VALUES =')), mode=2; end if(strfind(str,'= IMAGE INFORMATION DEFINITION =')), mode=3; fgetl(fid); str=fgetl(fid); % Skip a line end if(strfind(str,'= IMAGE INFORMATION =')), mode=4; end if(strfind(str,'= END OF DATA DESCRIPTION FILE =')), mode=5; end switch(mode) case -1; case 0 nHC=nHC+1; HeaderComment{nHC}=str; case 1 if(str(1)=='.') [type data]=General_Information_Line(str); switch(type) case 'PatientName' info.(type)=data; case 'ProtocolName' info.(type)=data; case 'ExaminationName' info.(type)=data; case 'ExaminationDateTime' info.(type)=data; case 'SeriesType' info.(type)=data; case 'AcquisitionNr' info.(type)=sscanf(data, '%d')'; case 'ReconstructionNr' info.(type)=sscanf(data, '%d')'; case 'ScanDuration' info.(type)=sscanf(data, '%lf')'; case 'MaxNumberOfCardiacPhases' info.(type)=sscanf(data, '%d')'; case 'MaxNumberOfEchoes' info.(type)=sscanf(data, '%d')'; case 'MaxNumberOfSlicesLocations' info.(type)=sscanf(data, '%d')'; case 'MaxNumberOfDynamics' info.(type)=sscanf(data, '%d')'; case 'MaxNumberOfMixes' info.(type)=sscanf(data, '%d')'; case 'PatientPosition' info.(type)=data; case 'PreparationDirection' info.(type)=data; case 'Technique' info.(type)=data; case 'ScanResolution' info.(type)=sscanf(data, '%d')'; case 'ScanMode' info.(type)=data; case 'RepetitionTime' info.(type)=sscanf(data, '%lf')'; case 'Fov' info.(type)=sscanf(data, '%lf')'; case 'WaterFatShift' info.(type)=sscanf(data, '%lf')'; case 'Angulation' info.(type)=sscanf(data, '%lf')'; case 'OffCentre' info.(type)=sscanf(data, '%lf')'; case 'FlowCompensation' info.(type)=sscanf(data, '%d')'; case 'Presaturation' info.(type)=sscanf(data, '%d')'; case 'PhaseEncodingVelocity' info.(type)=sscanf(data, '%lf')'; case 'Mtc' info.(type)=sscanf(data, '%lf')'; case 'Spir' info.(type)=sscanf(data, '%lf')'; case 'EpiFactor' info.(type)=sscanf(data, '%lf')'; case 'DynamicScan' info.(type)=sscanf(data, '%lf')'; case 'Diffusion' info.(type)=sscanf(data, '%lf')'; case 'DiffusionEchoTime' info.(type)=sscanf(data, '%lf')'; case 'MaxNumberOfDiffusionValues' info.(type)=sscanf(data, '%d')'; case 'MaxNumberOfGradientOrients' info.(type)=sscanf(data, '%d')'; case 'NumberOfLabelTypes' info.(type)=sscanf(data, '%d')'; case 'HeaderComment' otherwise info.(type)=data; end end case 2 case 3 if(str(1)=='#'); [type datatype datalength]=Image_Information_Line(str); if(~isempty(type)) nIC=nIC+1; ImageInformationTags(nIC).Name=type; ImageInformationTags(nIC).DataType=datatype; ImageInformationTags(nIC).NumberOfValues=datalength; end end case 4 if(str(1)~='#'); nSC=nSC+1; vals=regexp(str, '\s+','split'); vald=sscanf(str, '%lf')'; current_loc=0; for i=1:length(ImageInformationTags) IIT=ImageInformationTags(i); if(strcmp(IIT.DataType,'string')) SliceInformation(nSC).(IIT.Name)=vals{current_loc+1}; else SliceInformation(nSC).(IIT.Name)=vald(current_loc+1:current_loc+IIT.NumberOfValues); end current_loc=current_loc+IIT.NumberOfValues; end end case 5 otherwise %disp(str); end end fclose(fid); info.HeaderComment=HeaderComment; info.SliceInformation=SliceInformation; info.ImageInformationTags=ImageInformationTags; % Add Dimensions and Voxel Spacing. Warning, based on only 1 slice! infof=info.SliceInformation(1); if(isfield(infof,'ReconResolution')) if(isfield(info,'MaxNumberOfSlicesLocations')) zs(1)=info.MaxNumberOfSlicesLocations; zs(2)=length(SliceInformation)/zs(1); if((mod(zs(2),1)>0)||zs(2)==1) zs=length(SliceInformation); end else zs=length(SliceInformation); end info.Dimensions=[infof.ReconResolution zs]; else info.Dimensions=[info.ScanResolution length(SliceInformation)]; end if(isfield(infof,'PixelSpacing')) if(isfield(infof,'SliceThickness')&&isfield(infof,'SliceGap')) zs=infof.SliceThickness+infof.SliceGap; else zs=0; end info.Scales=[infof.PixelSpacing zs]; else info.Scales=[0 0 0]; end [folder,filen]=fileparts(info.Filename); info.FilenameREC=fullfile(folder,[filen '.rec']); % Add bith depth if(infof.ImagePixelSize) info.BitDepth=infof.ImagePixelSize; else if(exist(info.FilenameREC,'file')) file_info=dir(info.FilenameREC); bytes=file_info.bytes; info.BitDepth=(bytes/prod(info.Dimensions))*8; end end function [type datatype datalength]=Image_Information_Line(str) s=find(str=='(',1,'last'); if(isempty(s)), s=length(str); end type=str(1:s-1); data=str(s+1:end); type=regexp(type, '\s+|/|_', 'split'); type_clean=''; for i=1:length(type) part=type{i}; part(part=='#')=[]; part(part==' ')=[]; partu=uint8(part); if(~isempty(part)) check=((partu>=97)&(partu<=122))|((partu>=65)&(partu<=90)); if(check) part=lower(part); part(1)=upper(part(1)); type_clean=[type_clean part]; else break; end end end type=type_clean; while(~isempty(data)&&data(1)==' '), data=data(2:end); end while(~isempty(data)&&data(end)==' '), data=data(1:end-1); end if(~isempty(data)) data=data(1:end-1); s=find(data=='*',1,'first'); if(isempty(s)), datalength=1; datatype=data; else datalength=str2double(data(1:s-1)); datatype=data(s+1:end); end else datalength=0; datatype=''; type=''; end function [type data]=General_Information_Line(str) s=find(str==':',1,'first'); if(isempty(s)), s=length(str); end type=str(1:s-1); data=str(s+1:end); type=regexp(type, '\s+|/', 'split'); type_clean=''; for i=1:length(type) part=type{i}; part(part=='.')=[]; part(part==' ')=[]; partu=uint8(part); if(~isempty(part)) check=((partu>=97)&(partu<=122))|((partu>=65)&(partu<=90)); if(check) part=lower(part); part(1)=upper(part(1)); type_clean=[type_clean part]; else break; end end end type=type_clean; while(~isempty(data)&&data(1)==' '), data=data(2:end); end while(~isempty(data)&&data(end)==' '), data=data(1:end-1); end
github
jacksky64/imageProcessing-master
hdr_read_volume.m
.m
imageProcessing-master/Matlab Viewer3D/ReadData3D/hdr/hdr_read_volume.m
1,429
utf_8
ddbf082bf0adb5cc48c5ad55a65a4f07
function V=hdr_read_volume(info) % function for reading volume of HDR/IMG Analyze ( .hdr ) volume file % % volume = hdr_read_volume(file-header) % % examples: % 1: info = hdr_read_volume(() % V = hdr_read_volume(info); % imshow(squeeze(V(:,:,round(end/2))),[]); % % 2: V = hdr_read_volume(('test.hdr'); % if(~isstruct(info)), info=hdr_read_header(info); end if(exist('analyze75read','file')>0) V = analyze75read(info); else V = get_analyze_volume(info); end function V = get_analyze_volume(info) % Open img file [folder filename] = fileparts(info.Filename); Filename = fullfile(folder, [filename '.img']); fid=fopen(Filename,'rb',info.ByteOrder); datasize=prod(info.Dimensions)*(info.BitDepth/8); fseek(fid,0,'bof'); switch(info.ImgDataType) case 'DT_BINARY' V = logical(fread(fid,datasize,'bit1')); case 'DT_UNSIGNED_CHAR' V = uint8(fread(fid,datasize,'uchar')); case 'DT_SIGNED_SHORT' V = int16(fread(fid,datasize,'short')); case 'DT_SIGNED_INT' V = int32(fread(fid,datasize,'int')); case 'DT_FLOAT' V = single(fread(fid,datasize,'float')); case 'DT_DOUBLE' V = double(fread(fid,datasize,'double')); case 'DT_COMPLEX' case 'DT_RGB' case 'DT_ALL' end fclose(fid); % Reshape the volume data to the right dimensions V = reshape(V,info.Dimensions);
github
jacksky64/imageProcessing-master
hdr_read_header.m
.m
imageProcessing-master/Matlab Viewer3D/ReadData3D/hdr/hdr_read_header.m
4,707
utf_8
a2dc54e78b103557c78fd2f7652f1bfe
function info=hdr_read_header(filename) % function for reading header of HDR/IMG Analyze ( .hdr ) volume file % % info = hdr_read_header(filename); % % examples: % 1, info=hdr_read_header() % 2, info=hdr_read_header('volume.hdr'); if(exist('filename','var')==0) [filename, pathname] = uigetfile('*.hdr', 'Read hdr-file'); filename = [pathname filename]; end if(exist('analyze75info','file')>0) info=analyze75info(filename); else info=get_info_analyze_hdr(filename); end function info=get_info_analyze_hdr(filename) % Strings for data type (compatible names with analyze75info) strImgData{1}.ImgDataType = 'DT_UNKNOWN'; strImgData{1}.ColorType = 'unknown'; strImgData{2}.ImgDataType = 'DT_BINARY'; strImgData{2}.ColorType = 'grayscale'; strImgData{3}.ImgDataType = 'DT_UNSIGNED_CHAR'; strImgData{3}.ColorType = 'grayscale'; strImgData{5}.ImgDataType = 'DT_SIGNED_SHORT'; strImgData{5}.ColorType = 'grayscale'; strImgData{9}.ImgDataType = 'DT_SIGNED_INT'; strImgData{9}.ColorType = 'grayscale'; strImgData{17}.ImgDataType = 'DT_FLOAT'; strImgData{17}.ColorType = 'grayscale'; strImgData{33}.ImgDataType = 'DT_COMPLEX'; strImgData{33}.ColorType = 'grayscale'; strImgData{65}.ImgDataType = 'DT_DOUBLE'; strImgData{65}.ColorType = 'grayscale'; strImgData{129}.ImgDataType = 'DT_RGB'; strImgData{129}.ColorType = 'truecolor'; strImgData{256}.ImgDataType = 'DT_ALL'; strImgData{256}.ColorType = 'unknown'; strOriData{1} = 'Transverse unflipped'; strOriData{2} = 'Coronal unflipped'; strOriData{3} = 'Sagittal unflipped'; strOriData{4} = 'Transverse flipped'; strOriData{5} = 'Coronal flipped'; strOriData{6} = 'Sagittal flipped'; strOriData{7} = 'Orientation unavailable'; % Open the HDR-file, change MachineFormat if not the right % header size info.Filename=filename; fid = fopen(filename,'rb','l'); fseek(fid,0,'bof'); info.ByteOrder='ieee-le'; info.HdrFileSize = fread(fid, 1,'int32'); if(info.HdrFileSize>2000); fclose(fid); fid = fopen(filename,'rb','b'); fseek(fid,0,'bof'); info.ByteOrder='ieee-be'; info.HdrFileSize = fread(fid, 1,'int32'); end % Read the Whole Analyze Header info.Format='Analyze'; info.HdrDataType = fread(fid,10,'char=>char')'; info.DatabaseName = fread(fid,18,'char=>char')'; info.Extents = fread(fid, 1,'int32'); info.SessionError = fread(fid, 1,'int16'); info.Regular = fread(fid, 1,'char=>char')'; unused= fread(fid, 1,'uint8')'; dim = fread(fid,8,'int16')'; if (dim(1) < 3), dim(1) = 4; end info.Dimensions=dim(2:dim(1)+1); info.Width=info.Dimensions(1); info.Height=info.Dimensions(2); info.VoxelUnits = fread(fid,4,'char=>char')'; info.CalibrationUnits = fread(fid,8,'char=>char')'; unused = fread(fid,1,'int16'); ImgDataType = fread(fid,1,'int16'); info.ImgDataType=strImgData{ImgDataType+1}.ImgDataType; info.ColorType=strImgData{ImgDataType+1}.ColorType; info.BitDepth = fread(fid,1,'int16'); unused = fread(fid,1,'int16'); PixelDimensions = fread(fid,8,'float')'; info.PixelDimensions=PixelDimensions(2:length(info.Dimensions)+1); info.VoxelOffset = fread(fid,1,'float'); info.RoiScale = fread(fid,1,'float'); unused = fread(fid,1,'float'); unused = fread(fid,1,'float'); info.CalibrationMax = fread(fid,1,'float'); info.CalibrationMin = fread(fid,1,'float'); info.Compressed = fread(fid,1,'int32'); info.Verified = fread(fid,1,'int32'); info.GlobalMax = fread(fid,1,'int32'); info.GlobalMin = fread(fid,1,'int32'); info.Descriptor = fread(fid,80,'char=>char')'; info.AuxFile = fread(fid,24,'char=>char')'; Orientationt = fread(fid, 1,'uint8'); if((Orientationt>=48)&&(Orientationt<=53)), Orientationt = Orientationt -48; end info.Orientationt=strOriData{min(Orientationt,5)+1}; info.Originator = fread(fid,10,'char=>char')'; info.Generated = fread(fid,10,'char=>char')'; info.Scannumber = fread(fid,10,'char=>char')'; info.PatientID = fread(fid,10,'char=>char')'; info.ExposureDate = fread(fid,10,'char=>char')'; info.ExposureTime = fread(fid,10,'char=>char')'; unused = fread(fid, 3,'char=>char')'; info.Views = fread(fid, 1,'int32'); info.VolumesAdded = fread(fid, 1,'int32'); info.StartField = fread(fid, 1,'int32'); info.FieldSkip = fread(fid, 1,'int32'); info.Omax = fread(fid, 1,'int32'); info.Omin = fread(fid, 1,'int32'); info.Smax = fread(fid, 1,'int32'); info.Smin = fread(fid, 1,'int32'); fclose(fid); % Remove empty string parts from the info struct names = fieldnames(info); for i=1:length(names) value=info.(names{i}); if(ischar(value)) value(uint8(value)==0)=[]; if(isempty(value)), info.(names{i})=''; else info.(names{i})=value; end end end
github
jacksky64/imageProcessing-master
ErrorData3D.m
.m
imageProcessing-master/Matlab Viewer3D/ReadData3D/subfunctions/ErrorData3D.m
3,246
utf_8
66924055ba5a507e5363c6d4666bdac8
function varargout = ErrorData3D(varargin) % ERRORDATA3D M-file for ErrorData3D.fig % ERRORDATA3D, by itself, creates a new ERRORDATA3D or raises the existing % singleton*. % % H = ERRORDATA3D returns the handle to a new ERRORDATA3D or the handle to % the existing singleton*. % % ERRORDATA3D('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in ERRORDATA3D.M with the given input arguments. % % ERRORDATA3D('Property','Value',...) creates a new ERRORDATA3D or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before ErrorData3D_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to ErrorData3D_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help ErrorData3D % Last Modified by GUIDE v2.5 05-Jul-2010 15:17:44 % Begin initialization code - DO NOT EDIT gui_Singleton = 0; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @ErrorData3D_OpeningFcn, ... 'gui_OutputFcn', @ErrorData3D_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before ErrorData3D is made visible. function ErrorData3D_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to ErrorData3D (see VARARGIN) % Choose default command line output for ErrorData3D handles.output = hObject; % Update handles structure guidata(hObject, handles); if (~isempty(varargin)) set(handles.text1,'string',varargin{1}) end % UIWAIT makes ErrorData3D wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = ErrorData3D_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) delete(handles.figure1);
github
jacksky64/imageProcessing-master
InfoData3D.m
.m
imageProcessing-master/Matlab Viewer3D/ReadData3D/subfunctions/InfoData3D.m
3,553
utf_8
da6f4f6491166d601be56e443974a131
function varargout = InfoData3D(varargin) % INFODATA3D M-file for InfoData3D.fig % INFODATA3D, by itself, creates a new INFODATA3D or raises the existing % singleton*. % % H = INFODATA3D returns the handle to a new INFODATA3D or the handle to % the existing singleton*. % % INFODATA3D('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in INFODATA3D.M with the given input arguments. % % INFODATA3D('Property','Value',...) creates a new INFODATA3D or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before InfoData3D_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to InfoData3D_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help InfoData3D % Last Modified by GUIDE v2.5 05-Jul-2010 15:13:54 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @InfoData3D_OpeningFcn, ... 'gui_OutputFcn', @InfoData3D_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before InfoData3D is made visible. function InfoData3D_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to InfoData3D (see VARARGIN) % Choose default command line output for InfoData3D handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes InfoData3D wait for user response (see UIRESUME) % uiwait(handles.figure1); info=varargin{1}; infocell=cell(100000,2); [infocell,poscell]=showinfo(info,infocell,0,''); infocell(poscell+1:end,:)=[]; set(handles.uitable1,'Data',infocell) function [infocell,poscell] = showinfo(info,infocell,poscell,s) fnames=fieldnames(info); for i=1:length(fnames) type=fnames{i}; data=info.(type); if(isnumeric(data)) poscell=poscell+1; infocell{poscell,1}=[s type]; infocell{poscell,2}=num2str(data(:)'); elseif(ischar(data)) poscell=poscell+1; infocell{poscell,1}=[s type]; infocell{poscell,2}=data; elseif(iscell(data)) elseif(isstruct(data)) [infocell,poscell]=showinfo(data,infocell,poscell,[type '.']); end end % --- Outputs from this function are returned to the command line. function varargout = InfoData3D_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output;
github
jacksky64/imageProcessing-master
render_color.m
.m
imageProcessing-master/Matlab Viewer3D/Old_Viewer3D_with_c_code/render_color.m
15,776
utf_8
87aefba963f0a02cb4434837aed8651d
function render_image = render_color(V, image_size, Mview,alphatable,colortable) % Function RENDER_COLOR will volume render a Image of a 3D volume with % transperancy and colortable. % % I = RENDER_COLOR(V, SIZE, Mview, ALPHATABLE, COLORTABLE); % % inputs, % V: Input image volume % SIZE: Sizes (height and length) of output image % Mview: Viewer (Transformation) matrix 4x4 % ALPHATABLE: Mapping from intensities to transperancy % range [0 1], dimensions Nx1 % COLORTALBE: Mapping form intensities to color % range [0 1], dimensions Nx3 % % outputs, % I: The maximum intensity output image % % Volume Data, % Range of V must be [0 1] in case of double or single otherwise % mex function will crash. Data of type double has short render times, % uint16 the longest. % % example, % % Load data % load TestVolume; % % Parameters % sizes=[400 400]; % Mview=makeViewMatrix([45 45 0],[0.5 0.5 0.5],[0 0 0]); % alphatable=(0:999)/999; % colortable=hsv(1000); % % Render and show image % I = render_color(V, sizes, Mview,alphatable,colortable); % imshow(I); % % Function is written by D.Kroon University of Twente (October 2008) % Needed to convert intensities to range [0 1] imax=1; if(isa(V,'uint8')), imax=2^8-1; end if(isa(V,'uint16')), imax=2^16-1; end if(isa(V,'uint32')), imax=2^32-1; end % Calculate the Shear and Warp Matrices [Mshear,Mwarp2D,c]=makeShearWarpMatrix(Mview,size(V)); Mwarp2Dinv=inv(double(Mwarp2D)); Mshearinv=inv(Mshear); % Store Volume sizes Iin_sizex=size(V,1); Iin_sizey=size(V,2); Iin_sizez=size(V,3); % Create Shear (intimidate) buffer Ibuffer_sizex=ceil(1.7321*max(size(V))+1); Ibuffer_sizey=Ibuffer_sizex; Ibuffer=zeros([Ibuffer_sizex Ibuffer_sizey 3]); % Split Colortable in R,G,B if(size(colortable,2)>size(colortable,1)), colortable=colortable'; end colortable_r=colortable(:,1); colortable_g=colortable(:,2); colortable_b=colortable(:,3); switch (c) case 1 for z=0:(Iin_sizex-1); % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizex/2)+Iin_sizey/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizex/2)+Iin_sizez/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizez-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizey-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(z+1,xBas, yBas))); intensity_xyz2=double(squeeze(V(z+1,xBas, yBas1))); intensity_xyz3=double(squeeze(V(z+1,xBas1, yBas))); intensity_xyz4=double(squeeze(V(z+1,xBas1, yBas1))); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b); end case 2 for z=0:(Iin_sizey-1), % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizey/2)+Iin_sizez/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizey/2)+Iin_sizex/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizex-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizez-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(yBas, z+1,xBas))); intensity_xyz2=double(squeeze(V(yBas1, z+1,xBas))); intensity_xyz3=double(squeeze(V(yBas, z+1,xBas1))); intensity_xyz4=double(squeeze(V(yBas1, z+1,xBas1))); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b); end case 3 for z=0:(Iin_sizez-1), % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizez/2)+Iin_sizex/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizez/2)+Iin_sizey/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizey-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizex-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(V(xBas, yBas, z+1)); intensity_xyz2=double(V(xBas, yBas1, z+1)); intensity_xyz3=double(V(xBas1, yBas, z+1)); intensity_xyz4=double(V(xBas1, yBas1, z+1)); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b); end case 4 for z=(Iin_sizex-1):-1:0, % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizex/2)+Iin_sizey/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizex/2)+Iin_sizez/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizez-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizey-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(z+1,xBas, yBas))); intensity_xyz2=double(squeeze(V(z+1,xBas, yBas1))); intensity_xyz3=double(squeeze(V(z+1,xBas1, yBas))); intensity_xyz4=double(squeeze(V(z+1,xBas1, yBas1))); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b); end case 5 for z=(Iin_sizey-1):-1:0, % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizey/2)+Iin_sizez/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizey/2)+Iin_sizex/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizex-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizez-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(yBas, z+1,xBas))); intensity_xyz2=double(squeeze(V(yBas1, z+1,xBas))); intensity_xyz3=double(squeeze(V(yBas, z+1,xBas1))); intensity_xyz4=double(squeeze(V(yBas1, z+1,xBas1))); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b); end case 6 for z=(Iin_sizez-1):-1:0, % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizez/2)+Iin_sizex/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizez/2)+Iin_sizey/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizey-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizex-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(V(xBas, yBas, z+1)); intensity_xyz2=double(V(xBas, yBas1, z+1)); intensity_xyz3=double(V(xBas1, yBas, z+1)); intensity_xyz4=double(V(xBas1, yBas1, z+1)); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b); end end render_image = warp(Ibuffer, image_size(1:2),Mshearinv,Mwarp2Dinv,c); function Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b) % Rotate image for two main view directions if(c==2||c==5), intensity_loc=intensity_loc'; end % Calculate index in alpha transparency look up table indexAlpha=round(intensity_loc*(length(alphatable)-1))+1; % Calculate index in color look up table indexColor=round(intensity_loc*(length(colortable_r)-1))+1; % calculate current alphaimage alphaimage=alphatable(indexAlpha); % Update the current pixel in the shear image buffer Ibuffer(px,py,1)=(1-alphaimage).*Ibuffer(px,py,1)+alphaimage.*colortable_r(indexColor); Ibuffer(px,py,2)=(1-alphaimage).*Ibuffer(px,py,2)+alphaimage.*colortable_g(indexColor); Ibuffer(px,py,3)=(1-alphaimage).*Ibuffer(px,py,3)+alphaimage.*colortable_b(indexColor);
github
jacksky64/imageProcessing-master
viewer3d_histogram.m
.m
imageProcessing-master/Matlab Viewer3D/Old_Viewer3D_with_c_code/viewer3d_histogram.m
4,424
utf_8
04cc06c842af8e3042d6ea77f91aedfb
function varargout = viewer3d_histogram(varargin) % This function is part of VIEWER3D % % color and alpha maps can be changed on the fly by dragging and creating % new color/alpha markers with the left mouse button. % % Function is written by D.Kroon University of Twente (October 2008) % Edit the above text to modify the response to help viewer3d_histogram % Last Modified by GUIDE v2.5 01-Nov-2008 21:04:04 % Begin initialization code - DO NOT EDIT gui_Singleton = 0; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_histogram_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_histogram_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d_histogram is made visible. function viewer3d_histogram_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d_histogram (see VARARGIN) % Choose default command line output for viewer3d_histogram handles.output = hObject; % Update handles structure guidata(hObject, handles); function figure1_WindowButtonMotionFcn(hObject, eventdata, handles) function varargout = viewer3d_histogram_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes during object creation, after setting all properties. function popupmenu_colors_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_colors (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. set(hObject,'String',{'jet','hsv','hot','cool','spring','summer','autumn','winter','gray','bone','copper','pink'}); set(hObject,'Value',3); if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function setMyData(data) % Store data struct in figure setappdata(gcf,'data3d',data); function data=getMyData() % Get data struct stored in figure data=getappdata(gcf,'data3d'); % -------------------------------------------------------------------- function menu_file_Callback(hObject, eventdata, handles) % hObject handle to menu_file (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_load_Callback(hObject, eventdata, handles) % hObject handle to menu_load (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_save_Callback(hObject, eventdata, handles) % hObject handle to menu_save (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on selection change in popupmenu_colors. function popupmenu_colors_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_colors (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns popupmenu_colors contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_colors
github
jacksky64/imageProcessing-master
makeViewMatrix.m
.m
imageProcessing-master/Matlab Viewer3D/Old_Viewer3D_with_c_code/makeViewMatrix.m
1,190
utf_8
49d443a4402c434f497d4b2dba34f211
function Mview=makeViewMatrix(r,s,t) % function makeViewMatrix construct a 4x4 transformation matrix from % rotation, resize and translation variables. % % Mview=makeViewMatrix(R,S,T) % % inputs, % R: Rotation vector [Rx, Ry, Rz]; % S: Resize vector [Sx, Sy, Sz]; % T: Translation vector [Tx, Ty, Tz]; % % outputs, % Mview: 4x4 transformation matrix % % Example, % Mview=makeViewMatrix([45 45 0],[1 1 1],[0 0 0]); % disp(Mview); % % Function is written by D.Kroon University of Twente (October 2008) R=RotationMatrix(r); S=ResizeMatrix(s); T=TranslateMatrix(t); Mview=R*S*T; function R=RotationMatrix(r) % Determine the rotation matrix (View matrix) for rotation angles xyz ... Rx=[1 0 0 0; 0 cosd(r(1)) -sind(r(1)) 0; 0 sind(r(1)) cosd(r(1)) 0; 0 0 0 1]; Ry=[cosd(r(2)) 0 sind(r(2)) 0; 0 1 0 0; -sind(r(2)) 0 cosd(r(2)) 0; 0 0 0 1]; Rz=[cosd(r(3)) -sind(r(3)) 0 0; sind(r(3)) cosd(r(3)) 0 0; 0 0 1 0; 0 0 0 1]; R=Rx*Ry*Rz; function S=ResizeMatrix(s) S=[1/s(1) 0 0 0; 0 1/s(2) 0 0; 0 0 1/s(3) 0; 0 0 0 1]; function T=TranslateMatrix(t) T=[1 0 0 -t(1); 0 1 0 -t(2); 0 0 1 -t(3); 0 0 0 1];
github
jacksky64/imageProcessing-master
render_shaded.m
.m
imageProcessing-master/Matlab Viewer3D/Old_Viewer3D_with_c_code/render_shaded.m
19,351
utf_8
8c97f4730b447f5fb0c7ee9ac5424e62
function render_image = render_shaded(V, image_size, Mview,alphatable,colortable,LVector,VVector,shadingtype) % Function RENDER_SHADED will volume render a shaded Image of a 3D volume, % with transperancy and colortable. % % I = RENDER_SHADED(V, SIZE, Mview, ALPHATABLE, COLORTABLE,LightVector,ViewerVector,SHADINGMATERIAL); % % inputs, % V: Input image volume % SIZE: Sizes (height and length) of output image % Mview: Viewer (Transformation) matrix 4x4 % ALPHATABLE: Mapping from intensities to transperancy % range [0 1], dimensions Nx1 % COLORTALBE: Mapping form intensities to color % range [0 1], dimensions Nx3 % LightVector: Light direction % ViewerVector: Viewer direction % SHADINGMATERIAL: 'shiny' or 'dull' or 'metal', set the % object shading look % % outputs, % I: The maximum intensity output image % % Volume Data, % Range of V must be [0 1] in case of double or single otherwise % mex function will crash. Data of type double has short render times, % uint16 the longest. % % example, % % Load data % load TestVolume2; % % Output image size % sizes=[400 400]; % % color and alpha table % alphatable=[0 0 0 0 0 1 1 1 1 1]; % colortable=[1 0 0;1 0 0;1 0 0;1 0 0;1 0 0;1 0 0;1 0 0]; % % Viewer and Light direction % Vd = [0 0 1]; % Ld = [0.67 0.33 0.67]; % % Viewer Matrix % Mview=makeViewMatrix([0 0 0],[0.5 0.5 0.5],[0 0 0]); % % Render and show image % figure, % I = render_shaded(V, sizes, Mview,alphatable,colortable,Ld,Vd,'shiny'); % imshow(I); % % Function is written by D.Kroon University of Twente (November 2008) % Needed to convert intensities to range [0 1] imax=1; if(isa(V,'uint8')), imax=2^8-1; end if(isa(V,'uint16')), imax=2^16-1; end if(isa(V,'uint32')), imax=2^32-1; end % Calculate the Shear and Warp Matrices [Mshear,Mwarp2D,c]=makeShearWarpMatrix(Mview,size(V)); Mwarp2Dinv=inv(double(Mwarp2D)); Mshearinv=inv(Mshear); % Store Volume sizes Iin_sizex=size(V,1); Iin_sizey=size(V,2); Iin_sizez=size(V,3); % Create Shear (intimidate) buffer Ibuffer_sizex=ceil(1.7321*max(size(V))+1); Ibuffer_sizey=Ibuffer_sizex; Ibuffer=zeros([Ibuffer_sizex Ibuffer_sizey 3]); % Adjust alpha table by voxel length change because of rotation lengthcor=sqrt(1+(Mshearinv(1,3)^2+Mshearinv(2,3)^2)); alphatable= alphatable*lengthcor; % Split Colortable in R,G,B if(size(colortable,2)>size(colortable,1)), colortable=colortable'; end colortable_r=colortable(:,1); colortable_g=colortable(:,2); colortable_b=colortable(:,3); % Shading type -> Phong values switch lower(shadingtype) case {'shiny'} materialc=[0.7, 0.6, 0.9, 20]; case {'dull'} materialc=[0.7, 0.8, 0.0, 10]; case {'metal'} materialc=[0.7, 0.3, 1.0, 25]; otherwise materialc=[0.7, 0.6, 0.9, 20]; end % Normalize Light and Viewer vectors LightVector=[LVector(:);0]; LightVector=LightVector./sqrt(sum(LightVector(1:3).^2)); ViewerVector=[VVector(:);0]; ViewerVector=ViewerVector./sqrt(sum(ViewerVector(1:3).^2)); switch (c) case 1 for z=0:(Iin_sizex-1); % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizex/2)+Iin_sizey/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizex/2)+Iin_sizez/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizez-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizey-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(z+1,xBas, yBas))); intensity_xyz2=double(squeeze(V(z+1,xBas, yBas1))); intensity_xyz3=double(squeeze(V(z+1,xBas1, yBas))); intensity_xyz4=double(squeeze(V(z+1,xBas1, yBas1))); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer N=returnnormal(z+1,xBas, yBas,V,Mview,c); Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b,LightVector,ViewerVector,materialc,N); end case 2 for z=0:(Iin_sizey-1), % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizey/2)+Iin_sizez/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizey/2)+Iin_sizex/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizex-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizez-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(yBas, z+1,xBas))); intensity_xyz2=double(squeeze(V(yBas1, z+1,xBas))); intensity_xyz3=double(squeeze(V(yBas, z+1,xBas1))); intensity_xyz4=double(squeeze(V(yBas1, z+1,xBas1))); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer N=returnnormal(yBas, z+1,xBas,V,Mview,c); Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b,LightVector,ViewerVector,materialc,N); end case 3 for z=0:(Iin_sizez-1), % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizez/2)+Iin_sizex/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizez/2)+Iin_sizey/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizey-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizex-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(V(xBas, yBas, z+1)); intensity_xyz2=double(V(xBas, yBas1, z+1)); intensity_xyz3=double(V(xBas1, yBas, z+1)); intensity_xyz4=double(V(xBas1, yBas1, z+1)); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer N=returnnormal(xBas,yBas,z+1,V,Mview,c); Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b,LightVector,ViewerVector,materialc,N); end case 4 for z=(Iin_sizex-1):-1:0, % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizex/2)+Iin_sizey/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizex/2)+Iin_sizez/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizez-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizey-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(z+1,xBas, yBas))); intensity_xyz2=double(squeeze(V(z+1,xBas, yBas1))); intensity_xyz3=double(squeeze(V(z+1,xBas1, yBas))); intensity_xyz4=double(squeeze(V(z+1,xBas1, yBas1))); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer N=returnnormal(z+1,xBas,yBas,V,Mview,c); Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b,LightVector,ViewerVector,materialc,N); end case 5 for z=(Iin_sizey-1):-1:0, % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizey/2)+Iin_sizez/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizey/2)+Iin_sizex/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizex-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizez-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(yBas, z+1,xBas))); intensity_xyz2=double(squeeze(V(yBas1, z+1,xBas))); intensity_xyz3=double(squeeze(V(yBas, z+1,xBas1))); intensity_xyz4=double(squeeze(V(yBas1, z+1,xBas1))); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer N=returnnormal(yBas,z+1,xBas,V,Mview,c); Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b,LightVector,ViewerVector,materialc,N); end case 6 for z=(Iin_sizez-1):-1:0, % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizez/2)+Iin_sizex/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizez/2)+Iin_sizey/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizey-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizex-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(V(xBas, yBas, z+1)); intensity_xyz2=double(V(xBas, yBas1, z+1)); intensity_xyz3=double(V(xBas1, yBas, z+1)); intensity_xyz4=double(V(xBas1, yBas1, z+1)); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer N=returnnormal(xBas,yBas,z+1,V,Mview,c); Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b,LightVector,ViewerVector,materialc,N); end end render_image = warp(Ibuffer, image_size(1:2),Mshearinv,Mwarp2Dinv,c); function N=returnnormal(x,y,z,V,Mview,c) x1=x; y1=y; z1=z; x2=x1+1; check=x2>size(V,1); if(nnz(check)>0) x1(check)=x1-1; x2(x2>size(V,1))=size(V,1); end y2=y1+1; check=y2>size(V,2); if(nnz(check)>0) y1(check)=y1-1; y2(check)=size(V,2); end z2=z1+1; check=z2>size(V,3); if(nnz(check)>0) z1(check)=z1-1; z2(check)=size(V,3); end S(:,:,1)=squeeze(V(x2,y1,z1)-V(x1,y1,z1)); S(:,:,2)=squeeze(V(x1,y2,z1)-V(x1,y1,z1)); S(:,:,3)=squeeze(V(x1,y1,z2)-V(x1,y1,z1)); if(c==2||c==5), S2=zeros([size(S,2) size(S,1) 3]); S2(:,:,1)=S(:,:,1)'; S2(:,:,2)=S(:,:,2)'; S2(:,:,3)=S(:,:,3)'; S=S2; end N=zeros(size(S)); % Rotate the gradient and normalize to get the surface normal in direction of the viewer N(:,:,1)=Mview(1,1)*S(:,:,1)+Mview(1,2)*S(:,:,2)+Mview(1,3)*S(:,:,3); N(:,:,2)=Mview(2,1)*S(:,:,1)+Mview(2,2)*S(:,:,2)+Mview(2,3)*S(:,:,3); N(:,:,3)=Mview(3,1)*S(:,:,1)+Mview(3,2)*S(:,:,2)+Mview(3,3)*S(:,:,3); nlength=sqrt(N(:,:,1).^2+N(:,:,2).^2+N(:,:,3).^2)+0.000001; N(:,:,1)=N(:,:,1)./nlength; N(:,:,2)=N(:,:,2)./nlength; N(:,:,3)=N(:,:,3)./nlength; function Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable,colortable_r,colortable_g,colortable_b,L,V,material,N) % Rotate image for two main view directions if(c==2||c==5), intensity_loc=intensity_loc'; end % Calculate index in alpha transparency look up table indexAlpha=round(intensity_loc*(length(alphatable)-1))+1; % Calculate index in color look up table indexColor=round(intensity_loc*(length(colortable_r)-1))+1; Ia=1; % Id = dot(N,L); Id=N(:,:,1)*L(1)+N(:,:,2)*L(2)+N(:,:,3)*L(3); % R = 2.0*dot(N,L)*N - L; R(:,:,1)=2*Id.*N(:,:,1)-L(1); R(:,:,2)=2*Id.*N(:,:,2)-L(2); R(:,:,3)=2*Id.*N(:,:,3)-L(3); %Is = max(pow(dot(R,V),3),0); Is=R(:,:,1)*V(1)+R(:,:,2)*V(2)+R(:,:,3)*V(3); Is(Is<0)=0; % Specular exponent Is=Is.^material(4); % Phong shading values Ipar=zeros([size(Id) 3]); Ipar(:,:,1)=material(1)*Ia; Ipar(:,:,2)=material(2)*Id; Ipar(:,:,3)=material(3)*Is; % calculate current alphaimage alphaimage=alphatable(indexAlpha); % Update the current pixel in the shear image buffer Ibuffer(px,py,1)=(1-alphaimage).*Ibuffer(px,py,1)+alphaimage.*(colortable_r(indexColor).*(Ipar(:,:,1)+Ipar(:,:,2))+Ipar(:,:,3)); Ibuffer(px,py,2)=(1-alphaimage).*Ibuffer(px,py,2)+alphaimage.*(colortable_g(indexColor).*(Ipar(:,:,1)+Ipar(:,:,2))+Ipar(:,:,3)); Ibuffer(px,py,3)=(1-alphaimage).*Ibuffer(px,py,3)+alphaimage.*(colortable_b(indexColor).*(Ipar(:,:,1)+Ipar(:,:,2))+Ipar(:,:,3));
github
jacksky64/imageProcessing-master
viewer3d.m
.m
imageProcessing-master/Matlab Viewer3D/Old_Viewer3D_with_c_code/viewer3d.m
39,153
utf_8
9fa9fa60946c257acdeb09c113487637
function varargout = viewer3d(varargin) % VIEWER3D a Matlab 3D volume renderer using the fast shearwarp algorithm. % % VIEWER3D(V, RENDERTYPE, SCALES); % % inputs, % V : 3D Input image volume, of type double, single, uint8, uint16 or % uint32 % (the render process uses only double calculations) % RENDERTYPE: 'MIP' Maximum Intensity Render (default) % 'VR' Volume Rendering % 'VRC' Volume Rendering Color % 'VRS' Volume Rendering with Shading % SCALES: The sizes(height, width, depth) of one voxel. (default [1 1 1]) % % Volume Data, % Range of V must be [0 1] in case of double or single. Volume Data of % type double has shorter render times than data of uint8 or uint16. % % example, % % Load data % load TestVolume; % viewer3d(V); % % See also: render_mip, render_bw, render_color, render_shaded % % Function is written by D.Kroon University of Twente (November 2008) % Edit the above text to modify the response to help viewer3d % Last Modified by GUIDE v2.5 04-Nov-2008 14:16:11 % Begin initialization code - DO NOT EDIT gui_Singleton = 0; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d is made visible. function viewer3d_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d (see VARARGIN) % Choose default command line output for viewer3d handles.output = hObject; % Update handles structure guidata(hObject, handles); %matlabpool(3); % addpath mexcode and help try functionname='viewer3d.m'; functiondir=which(functionname); functiondir=functiondir(1:end-length(functionname)); addpath([functiondir '/help']) catch end % Initialized data storage structure data.mouse_pressed=false; data.mouse_button=''; % Get input voxel volume and convert to double if (isempty(varargin)), data.volume=zeros(3,3,3); data.volume_preview=zeros(3,3,3); else if(ndims(varargin{1})==3) data.volume=varargin{1}; switch(class(data.volume)) case {'uint8','uint16'} case 'single' data.volume(data.volume<0)=0; data.volume(data.volume>1)=1; case 'double' data.volume(data.volume<0)=0; data.volume(data.volume>1)=1; otherwise warning('viewer3d:inputs', 'Unsupported input datatype converted to double'); data.volume=im2double(data.volume); data.volume(data.volume<0)=0; data.volume(data.volume>1)=1; end data.volume_preview=imresize3d(data.volume,[],[32 32 32],'linear'); else error('viewer3d:inputs', 'Input image not 3 dimensional'); end end % Get input render type if(length(varargin)>1) switch lower(varargin{2}) case 'mip' data.render_type='mip'; case 'vr' data.render_type='vr'; case 'vrc' data.render_type='vrc'; case 'vrs' data.render_type='vrs'; otherwise error('viewer3d:inputs', 'Render type unknown'); end else data.render_type='mip'; end % Get input voxelvolume scaling if(length(varargin)>2) Scales=varargin{3}; Scales=sqrt(3)*Scales./sqrt(sum(Scales.^2)); data.viewer_matrix=[Scales(1) 0 0 0; 0 Scales(2) 0 0; 0 0 Scales(3) 0; 0 0 0 1]; else data.viewer_matrix=[1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1]; end data.handle_viewer3d=gcf; data.handle_histogram=[]; data.histogram_positions = [0.2 0.4 0.6 0.9]; data.histogram_alpha = [0 0.5 0.35 1]; data.histogram_colors= [0 0 0; 1 0 0; 1 1 0; 1 1 1]; data.first_render=true; data.axes_size=[400 400]; data.histogram_pointselected=[]; data.mouse_position_pressed=[0 0]; data.mouse_position=[0 0]; data.mouse_position_last=[0 0]; data.shading_material='shiny'; data=loadmousepointershapes(data); data.handles=handles; setMyData(data); createAlphaColorTable(); % Show the data show3d(false) % UIWAIT makes viewer3d wait for user response (see UIRESUME) % uiwait(handles.figure1); function createAlphaColorTable() % This function creates a Matlab colormap and alphamap from the markers data=getMyData(); if(isempty(data)), return, end data.colortable=zeros(1000,3); data.alphatable=zeros(1000,1); % Loop through all 256 color/alpha indexes for j=0:999 i=j/999; if (i<data.histogram_positions(1)), alpha=0; color=data.histogram_colors(1,:); elseif(i>data.histogram_positions(end)), alpha=0; color=data.histogram_colors(end,:); elseif(i==data.histogram_positions(1)), alpha=data.histogram_alpha(1); color=data.histogram_colors(1,:); elseif(i==data.histogram_positions(end)), alpha=data.histogram_alpha(end); color=data.histogram_colors(end,:); else % Linear interpolate the color and alpha between markers index_down=find(data.histogram_positions<=i); index_down=index_down(end); index_up=find(data.histogram_positions>i); index_up=index_up(1); perc=(i-data.histogram_positions(index_down)) / (data.histogram_positions(index_up) - data.histogram_positions(index_down)); color=(1-perc)*data.histogram_colors(index_down,:)+perc*data.histogram_colors(index_up,:); alpha=(1-perc)*data.histogram_alpha(index_down)+perc*data.histogram_alpha(index_up); end data.colortable(j+1,:)=color; data.alphatable(j+1)=alpha; end setMyData(data); function data=loadmousepointershapes(data) I=1-(imread('icon_mouse_rotate1.png')>0); I(I==0)=NaN; data.icon_mouse_rotate1=I; I=1-(imread('icon_mouse_rotate2.png')>0); I(I==0)=NaN; data.icon_mouse_rotate2=I; I=1-(imread('icon_mouse_zoom.png')>0); I(I==0)=NaN; data.icon_mouse_zoom=I; I=1-(imread('icon_mouse_pan.png')>0); I(I==0)=NaN; data.icon_mouse_pan=I; function show3d(preview) data=getMyData(); if(isempty(data)), return, end % Calculate light and viewer vectors data.ViewerVector = [0 0 1]; data.LightVector = [0.67 0.33 0.67]; if(preview) viewer_matrix=data.viewer_matrix*ResizeMatrix(size(data.volume_preview)./size(data.volume)); switch data.render_type case 'mip' data.render_image = render_mip(data.volume_preview, data.axes_size(1:2), viewer_matrix); case 'vr' data.render_image = render_bw(data.volume_preview, data.axes_size(1:2), viewer_matrix, data.alphatable); case 'vrc' data.render_image = render_color(data.volume_preview, data.axes_size(1:2), viewer_matrix, data.alphatable, data.colortable); case 'vrs' data.render_image = render_shaded(data.volume_preview, data.axes_size(1:2), viewer_matrix, data.alphatable, data.colortable, data.LightVector, data.ViewerVector,data.shading_material); end else set_mouse_shape('watch',data); pause(0.001); switch data.render_type case 'mip' data.render_image = render_mip(data.volume, data.axes_size(1:2), data.viewer_matrix); case 'vr' data.render_image = render_bw(data.volume, data.axes_size(1:2), data.viewer_matrix, data.alphatable); case 'vrc' data.render_image = render_color(data.volume, data.axes_size(1:2), data.viewer_matrix, data.alphatable, data.colortable); case 'vrs' data.render_image = render_shaded(data.volume, data.axes_size(1:2), data.viewer_matrix, data.alphatable, data.colortable, data.LightVector, data.ViewerVector,data.shading_material); end set_mouse_shape('arrow',data); pause(0.001); end if(data.first_render) data.imshow_handle=imshow(data.render_image); data.first_render=false; else set(data.imshow_handle,'Cdata',data.render_image); end data.axes_size=get(data.handles.axes3d,'PlotBoxAspectRatio'); set(get(data.handles.axes3d,'Children'),'ButtonDownFcn','viewer3d(''axes3d_ButtonDownFcn'',gcbo,[],guidata(gcbo))'); setMyData(data); % --- Outputs from this function are returned to the command line. function varargout = viewer3d_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on mouse motion over figure - except title and menu. function figure1_WindowButtonMotionFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) cursor_position_in_axes(hObject,handles); data=getMyData(); if(isempty(data)), return, end if(isempty(data)), return, end; if(data.mouse_pressed) switch(data.mouse_button) case 'rotate1' r1=-360*(data.mouse_position_last(1)-data.mouse_position(1)); r2=360*(data.mouse_position_last(2)-data.mouse_position(2)); R=RotationMatrix([r1 r2 0]); data.viewer_matrix=R*data.viewer_matrix; setMyData(data); show3d(true) case 'rotate2' r1=100*(data.mouse_position_last(1)-data.mouse_position(1)); r2=100*(data.mouse_position_last(2)-data.mouse_position(2)); if(data.mouse_position(2)>0.5), r1=-r1; end if(data.mouse_position(1)<0.5), r2=-r2; end r3=r1+r2; R=RotationMatrix([0 0 r3]); data.viewer_matrix=R*data.viewer_matrix; setMyData(data); show3d(true) case 'pan' t2=200*(data.mouse_position_last(1)-data.mouse_position(1)); t1=200*(data.mouse_position_last(2)-data.mouse_position(2)); M=TranslateMatrix([t1 t2 0]); data.viewer_matrix=M*data.viewer_matrix; setMyData(data); show3d(true) case 'zoom' z1=1+2*(data.mouse_position_last(1)-data.mouse_position(1)); z2=1+2*(data.mouse_position_last(2)-data.mouse_position(2)); z=0.5*(z1+z2); %sqrt(z1.^2+z2.^2); R=ResizeMatrix([z z z]); data.viewer_matrix=R*data.viewer_matrix; setMyData(data); show3d(true) otherwise end end function R=RotationMatrix(r) % Determine the rotation matrix (View matrix) for rotation angles xyz ... Rx=[1 0 0 0; 0 cosd(r(1)) -sind(r(1)) 0; 0 sind(r(1)) cosd(r(1)) 0; 0 0 0 1]; Ry=[cosd(r(2)) 0 sind(r(2)) 0; 0 1 0 0; -sind(r(2)) 0 cosd(r(2)) 0; 0 0 0 1]; Rz=[cosd(r(3)) -sind(r(3)) 0 0; sind(r(3)) cosd(r(3)) 0 0; 0 0 1 0; 0 0 0 1]; R=Rx*Ry*Rz; function M=ResizeMatrix(s) M=[1/s(1) 0 0 0; 0 1/s(2) 0 0; 0 0 1/s(3) 0; 0 0 0 1]; function M=TranslateMatrix(t) M=[1 0 0 -t(1); 0 1 0 -t(2); 0 0 1 -t(3); 0 0 0 1]; function cursor_position_in_axes(hObject,handles) data=getMyData(); if(isempty(data)), return, end; data.mouse_position_last=data.mouse_position; % Get position of the mouse in the large axes p = get(0, 'PointerLocation'); pf = get(hObject, 'pos'); p(1:2) = p(1:2)-pf(1:2); set(gcf, 'CurrentPoint', p(1:2)); p = get(handles.axes3d, 'CurrentPoint'); data.mouse_position=[p(1, 1) p(1, 2)]./data.axes_size(1:2); setMyData(data); function setMyData(data) % Store data struct in figure setappdata(gcf,'data3d',data); function data=getMyData() % Get data struct stored in figure data=getappdata(gcf,'data3d'); % --- Executes on mouse press over axes background. function axes3d_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to axes3d (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.mouse_pressed=true; data.mouse_button=get(handles.figure1,'SelectionType'); if(strcmp(data.mouse_button,'normal')) if(sum((data.mouse_position-[0.5 0.5]).^2)<0.15) data.mouse_button='rotate1'; set_mouse_shape('rotate1',data) else data.mouse_button='rotate2'; set_mouse_shape('rotate2',data) end end if(strcmp(data.mouse_button,'extend')) data.mouse_button='pan'; set_mouse_shape('pan',data) end if(strcmp(data.mouse_button,'alt')) data.mouse_button='zoom'; set_mouse_shape('zoom',data) end data.mouse_position_pressed=data.mouse_position; setMyData(data); function set_mouse_shape(type,data) switch(type) case 'rotate1' set(gcf,'Pointer','custom','PointerShapeCData',data.icon_mouse_rotate1,'PointerShapeHotSpot',round(size(data.icon_mouse_rotate1)/2)) set(data.handles.figure1,'Pointer','custom'); case 'rotate2' set(gcf,'Pointer','custom','PointerShapeCData',data.icon_mouse_rotate2,'PointerShapeHotSpot',round(size(data.icon_mouse_rotate2)/2)) set(data.handles.figure1,'Pointer','custom'); case 'zoom' set(gcf,'Pointer','custom','PointerShapeCData',data.icon_mouse_zoom,'PointerShapeHotSpot',round(size(data.icon_mouse_zoom)/2)) set(data.handles.figure1,'Pointer','custom'); case 'pan' set(gcf,'Pointer','custom','PointerShapeCData',data.icon_mouse_pan,'PointerShapeHotSpot',round(size(data.icon_mouse_pan)/2)) set(data.handles.figure1,'Pointer','custom'); otherwise set(data.handles.figure1,'Pointer',type); end % --- Executes on mouse press over figure background, over a disabled or % --- inactive control, or over an axes background. function figure1_WindowButtonUpFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.mouse_pressed=false; setMyData(data); show3d(false) set(handles.figure1,'Pointer','arrow'); function A=imresize3d(V,scale,tsize,ntype,npad) % This function resizes a 3D image volume to new dimensions % Vnew = imresize3d(V,scale,nsize,ntype,npad); % % inputs, % V: The input image volume % scale: scaling factor, when used set tsize to []; % nsize: new dimensions, when used set scale to []; % ntype: Type of interpolation ('nearest', 'linear', or 'cubic') % npad: Boundary condition ('replicate', 'symmetric', 'circular', 'fill', or 'bound') % % outputs, % Vnew: The resized image volume % % example, % load('mri','D'); D=squeeze(D); % Dnew = imresize3d(D,[],[80 80 40],'nearest','bound'); % % This function is written by D.Kroon University of Twente (July 2008) % Check the inputs if(exist('ntype', 'var') == 0), ntype='nearest'; end if(exist('npad', 'var') == 0), npad='bound'; end if(exist('scale', 'var')&&~isempty(scale)), tsize=round(size(V)*scale); end if(exist('tsize', 'var')&&~isempty(tsize)), scale=(tsize./size(V)); end % Make transformation structure T = makehgtform('scale',scale); tform = maketform('affine', T); % Specify resampler R = makeresampler(ntype, npad); % Resize the image volueme A = tformarray(V, tform, R, [1 2 3], [1 2 3], tsize, [], 0); function [Mshear,Mwarp2D,c]=matrixshearwarp(Mview,sizes) % Find the principal viewing axis Vo=[Mview(1,2)*Mview(2,3) - Mview(2,2)*Mview(1,3); Mview(2,1)*Mview(1,3) - Mview(1,1)*Mview(2,3); Mview(1,1)*Mview(2,2) - Mview(2,1)*Mview(1,2)]; [maxv,c]=max(abs(Vo)); % Choose the corresponding Permutation matrix P switch(c) case 1, %yzx P=[0 1 0 0; 0 0 1 0; 1 0 0 0; 0 0 0 1;]; case 2, % zxy P=[0 0 1 0; 1 0 0 0; 0 1 0 0; 0 0 0 1;]; case 3, % xyz P=[1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1;]; end % Compute the permuted view matrix from Mview and P Mview_p=Mview*inv(P); % 180 degrees rotate detection if(Mview_p(3,3)<0), c=c+3; end % Compute the shear coeficients from the permuted view matrix Si = (Mview_p(2,2)* Mview_p(1,3) - Mview_p(1,2)* Mview_p(2,3)) / (Mview_p(1,1)* Mview_p(2,2) - Mview_p(2,1)* Mview_p(1,2)); Sj = (Mview_p(1,1)* Mview_p(2,3) - Mview_p(2,1)* Mview_p(1,3)) / (Mview_p(1,1)* Mview_p(2,2) - Mview_p(2,1)* Mview_p(1,2)); % Compute the translation between the orgins of standard object coordinates % and intermdiate image coordinates if((c==1)||(c==4)), kmax=sizes(1)-1; end if((c==2)||(c==5)), kmax=sizes(2)-1; end if((c==3)||(c==6)), kmax=sizes(3)-1; end if ((Si>=0)&&(Sj>=0)), Ti = 0; Tj = 0; end if ((Si>=0)&&(Sj<0)), Ti = 0; Tj = -Sj*kmax; end if ((Si<0)&&(Sj>=0)), Ti = -Si*kmax; Tj = 0; end if ((Si<0)&&(Sj<0)), Ti = -Si*kmax; Tj = -Sj*kmax; end % Compute the shear matrix Mshear=[1 0 Si Ti; 0 1 Sj Tj; 0 0 1 0; 0 0 0 1]; % Compute the 2Dwarp matrix Mwarp2D=[Mview_p(1,1) Mview_p(1,2) (Mview_p(1,4)-Ti*Mview_p(1,1)-Tj*Mview_p(1,2)); Mview_p(2,1) Mview_p(2,2) (Mview_p(2,4)-Ti*Mview_p(2,1)-Tj*Mview_p(2,2)); 0 0 1 ]; % Compute the 3Dwarp matrix % Mwarp3Da=[Mview_p(1,1) Mview_p(1,2) (Mview_p(1,3)-Si*Mview_p(1,1)-Sj*Mview_p(1,2)) Mview_p(1,4); % Mview_p(2,1) Mview_p(2,2) (Mview_p(2,3)-Si*Mview_p(2,1)-Sj*Mview_p(2,2)) Mview_p(2,4); % Mview_p(3,1) Mview_p(3,2) (Mview_p(3,3)-Si*Mview_p(3,1)-Sj*Mview_p(3,2)) Mview_p(3,4); % 0 0 0 1 ]; % Mwarp3Db=[1 0 0 -Ti; % 0 1 0 -Tj; % 0 0 1 0; % 0 0 0 1]; % Mwarp3D=Mwarp3Da*Mwarp3Db; % % Control matrix Mview % Mview_control = Mwarp3D*Mshear*P; % disp(Mview) % disp(Mview_control) % -------------------------------------------------------------------- function menu_file_Callback(hObject, eventdata, handles) % hObject handle to menu_file (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_config_Callback(hObject, eventdata, handles) % hObject handle to menu_config (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_change_alpha_colors_Callback(hObject, eventdata, handles) % hObject handle to menu_change_alpha_colors (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.handle_histogram=viewer3d_histogram(data.handle_viewer3d); handles_histogram=guidata(data.handle_histogram); data.handle_histogram_axes=handles_histogram.axes_histogram; setMyData(data); createHistogram(); drawHistogramPoints(); % -------------------------------------------------------------------- function menu_load_view_Callback(hObject, eventdata, handles) % hObject handle to menu_load_view (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) dataold=getMyData(); dataold.volume=[]; if(ishandle(dataold.handle_histogram)), close(dataold.handle_histogram); end uiload(); if(exist('data','var')) data.first_render=true; data.handle_viewer3d=dataold.handle_viewer3d; data.handles.axes3d=dataold.handles.axes3d; data.handles.figure1=dataold.handles.figure1; setMyData(data); createAlphaColorTable(); show3d(false); else viewer3d_error({'Matlab File does not contain','data from "Save Render"'}) end % -------------------------------------------------------------------- function menu_save_view_Callback(hObject, eventdata, handles) % hObject handle to menu_save_view (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end uisave('data'); function menu_load_histogram_Callback(hObject, eventdata, handles) % hObject handle to menu_load_view (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end alpha=0; uiload; if(exist('positions','var')) data.histogram_positions=positions; data.histogram_colors=colors; data.histogram_alpha=alpha; setMyData(data); drawHistogramPoints(); createAlphaColorTable(); show3d(false); else viewer3d_error({'Matlab File does not contain','data from "Save AlphaColors"'}) end % -------------------------------------------------------------------- function menu_save_histogram_Callback(hObject, eventdata, handles) % hObject handle to menu_save_view (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end positions=data.histogram_positions; colors=data.histogram_colors; alpha=data.histogram_alpha; uisave({'positions','colors','alpha'}); % -------------------------------------------------------------------- function menu_render_Callback(hObject, eventdata, handles) % hObject handle to menu_render (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_render_Mip_Callback(hObject, eventdata, handles) % hObject handle to menu_render_Mip (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.render_type='mip'; data.first_render=true; setMyData(data); show3d(false); % -------------------------------------------------------------------- function menu_render_vr_Callback(hObject, eventdata, handles) % hObject handle to menu_render_vr (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.render_type='vr'; data.first_render=true; setMyData(data); show3d(false); % -------------------------------------------------------------------- function menu_render_vrc_Callback(hObject, eventdata, handles) % hObject handle to menu_render_vrc (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.render_type='vrc'; data.first_render=true; setMyData(data); show3d(false); % -------------------------------------------------------------------- function menu_render_vrs_Callback(hObject, eventdata, handles) % hObject handle to menu_render_vrs (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.render_type='vrs'; data.first_render=true; setMyData(data); show3d(false); % -------------------------------------------------------------------- function menu_info_Callback(hObject, eventdata, handles) % hObject handle to menu_info (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_save_picture_Callback(hObject, eventdata, handles) % hObject handle to menu_save_picture (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [filename, pathname] = uiputfile({'*.png';'*.jpg'}, 'Save Rendered Image as'); data=getMyData(); if(isempty(data)), return, end imwrite(data.render_image,[pathname filename]); % -------------------------------------------------------------------- function menu_about_Callback(hObject, eventdata, handles) % hObject handle to menu_about (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) viewer3d_about function createHistogram() % This function creates and show the (log) histogram of the data data=getMyData(); if(isempty(data)), return, end % Get histogram [data.histogram_countsy, data.histogram_countsx]=imhist(data.volume(:)); % Log the histogram data data.histogram_countsy=log(data.histogram_countsy+100); data.histogram_countsy=data.histogram_countsy-min(data.histogram_countsy); data.histogram_countsx=data.histogram_countsx./max(data.histogram_countsx(:)); data.histogram_countsy=data.histogram_countsy./max(data.histogram_countsy(:)); % Focus on histogram axes figure(data.handle_histogram) % Display the histogram stem(data.handle_histogram_axes,data.histogram_countsx,data.histogram_countsy,'Marker', 'none'); hold(data.handle_histogram_axes,'on'); % Set the axis of the histogram axes data.histogram_maxy=max(data.histogram_countsy(:)); data.histogram_maxx=max(data.histogram_countsx(:)); set(data.handle_histogram_axes,'yLim', [0 1]); set(data.handle_histogram_axes,'xLim', [0 1]); setMyData(data); % --- Executes on selection change in popupmenu_colors. function popupmenu_colors_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_colors (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns popupmenu_colors contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_colors data=getMyData(); if(isempty(data)), return, end % Generate the new color markers c_choice=get(handles.popupmenu_colors,'Value'); ncolors=length(data.histogram_positions); switch c_choice, case 1,new_colormap=jet(1000); case 2, new_colormap=hsv(1000); case 3, new_colormap=hot(1000); case 4, new_colormap=cool(1000); case 5, new_colormap=spring(1000); case 6, new_colormap=summer(1000); case 7, new_colormap=autumn(1000); case 8, new_colormap=winter(1000); case 9, new_colormap=gray(1000); case 10, new_colormap=bone(1000); case 11, new_colormap=copper(1000); case 12, new_colormap=pink(1000); otherwise, new_colormap=hot(1000); end new_colormap=new_colormap(round(1:(end-1)/(ncolors-1):end),:); data.histogram_colors=new_colormap; % Draw the new color markers and make the color and alpha map setMyData(data); drawHistogramPoints(); createAlphaColorTable(); show3d(false); function drawHistogramPoints() data=getMyData(); if(isempty(data)), return, end % Delete old points and line try delete(data.histogram_linehandle), for i=1:length(data.histogram_pointhandle), delete(data.histogram_pointhandle(i)), end, catch end stem(data.handle_histogram_axes,data.histogram_countsx,data.histogram_countsy,'Marker', 'none'); hold(data.handle_histogram_axes,'on'); % Display the markers and line through the markers. data.histogram_linehandle=plot(data.handle_histogram_axes,data.histogram_positions,data.histogram_alpha*data.histogram_maxy,'m'); set(data.histogram_linehandle,'ButtonDownFcn','viewer3d(''lineHistogramButtonDownFcn'',gcbo,[],guidata(gcbo))'); for i=1:length(data.histogram_positions) data.histogram_pointhandle(i)=plot(data.handle_histogram_axes,data.histogram_positions(i),data.histogram_alpha(i)*data.histogram_maxy,'bo','MarkerFaceColor',data.histogram_colors(i,:)); set(data.histogram_pointhandle(i),'ButtonDownFcn','viewer3d(''pointHistogramButtonDownFcn'',gcbo,[],guidata(gcbo))'); end % For detection of mouse up, down and motion in histogram figure. set(data.handle_histogram, 'WindowButtonDownFcn','viewer3d(''HistogramButtonDownFcn'',gcbo,[],guidata(gcbo))'); set(data.handle_histogram, 'WindowButtonMotionFcn','viewer3d(''HistogramButtonMotionFcn'',gcbo,[],guidata(gcbo))'); set(data.handle_histogram, 'WindowButtonUpFcn','viewer3d(''HistogramButtonUpFcn'',gcbo,[],guidata(gcbo))'); setMyData(data); function pointHistogramButtonDownFcn(hObject, eventdata, handles) data=getMyData(); if(isempty(data)), return, end data.mouse_button=get(data.handle_histogram,'SelectionType'); if(strcmp(data.mouse_button,'normal')) data.histogram_pointselected=find(data.histogram_pointhandle==gcbo); data.histogram_pointselectedhandle=gcbo; set(data.histogram_pointselectedhandle, 'MarkerSize',8); setMyData(data); elseif(strcmp(data.mouse_button,'extend')) data.histogram_pointselected=find(data.histogram_pointhandle==gcbo); data.histogram_colors(data.histogram_pointselected,:)=rand(1,3); data.histogram_pointselected=[]; setMyData(data); drawHistogramPoints(); createAlphaColorTable(); show3d(false); elseif(strcmp(data.mouse_button,'alt')) data.histogram_pointselected=find(data.histogram_pointhandle==gcbo); data.histogram_positions(data.histogram_pointselected)=[]; data.histogram_colors(data.histogram_pointselected,:)=[]; data.histogram_alpha(data.histogram_pointselected)=[]; data.histogram_pointselected=[]; setMyData(data); drawHistogramPoints(); createAlphaColorTable(); show3d(false); end function HistogramButtonDownFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) function HistogramButtonUpFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end if(~isempty(data.histogram_pointselected)) set(data.histogram_pointselectedhandle, 'MarkerSize',6); data.histogram_pointselected=[]; setMyData(data); createAlphaColorTable(); % Show the data show3d(false) end function HistogramButtonMotionFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) cursor_position_in_histogram_axes(hObject,handles); data=getMyData(); if(isempty(data)), return, end if(~isempty(data.histogram_pointselected)) % Set point to location mouse data.histogram_positions(data.histogram_pointselected)=data.histogram_mouse_position(1,1); data.histogram_alpha(data.histogram_pointselected)=data.histogram_mouse_position(1,2); % Correct new location if(data.histogram_alpha(data.histogram_pointselected)<0), data.histogram_alpha(data.histogram_pointselected)=0; end if(data.histogram_alpha(data.histogram_pointselected)>1), data.histogram_alpha(data.histogram_pointselected)=1; end if(data.histogram_positions(data.histogram_pointselected)<0), data.histogram_positions(data.histogram_pointselected)=0; end if(data.histogram_positions(data.histogram_pointselected)>1), data.histogram_positions(data.histogram_pointselected)=1; end if((data.histogram_pointselected>1)&&(data.histogram_positions(data.histogram_pointselected-1)>data.histogram_positions(data.histogram_pointselected))) data.histogram_positions(data.histogram_pointselected)=data.histogram_positions(data.histogram_pointselected-1); end if((data.histogram_pointselected<length(data.histogram_positions))&&(data.histogram_positions(data.histogram_pointselected+1)<data.histogram_positions(data.histogram_pointselected))) data.histogram_positions(data.histogram_pointselected)=data.histogram_positions(data.histogram_pointselected+1); end % Move point set(data.histogram_pointselectedhandle, 'xdata', data.histogram_positions(data.histogram_pointselected)); set(data.histogram_pointselectedhandle, 'ydata', data.histogram_alpha(data.histogram_pointselected)); % Move line set(data.histogram_linehandle, 'xdata',data.histogram_positions); set(data.histogram_linehandle, 'ydata',data.histogram_alpha); end setMyData(data); function lineHistogramButtonDownFcn(hObject, eventdata, handles) data=getMyData(); if(isempty(data)), return, end % New point on mouse location newposition=data.histogram_mouse_position(1,1); % List for the new markers newpositions=zeros(1,length(data.histogram_positions)+1); newalphas=zeros(1,length(data.histogram_alpha)+1); newcolors=zeros(size(data.histogram_colors,1)+1,3); % Check if the new point is between old points index_down=find(data.histogram_positions<=newposition); if(isempty(index_down)) else index_down=index_down(end); index_up=find(data.histogram_positions>newposition); if(isempty(index_up)) else index_up=index_up(1); % Copy the (first) old markers to the new lists newpositions(1:index_down)=data.histogram_positions(1:index_down); newalphas(1:index_down)=data.histogram_alpha(1:index_down); newcolors(1:index_down,:)=data.histogram_colors(1:index_down,:); % Add the new interpolated marker perc=(newposition-data.histogram_positions(index_down)) / (data.histogram_positions(index_up) - data.histogram_positions(index_down)); color=(1-perc)*data.histogram_colors(index_down,:)+perc*data.histogram_colors(index_up,:); alpha=(1-perc)*data.histogram_alpha(index_down)+perc*data.histogram_alpha(index_up); newpositions(index_up)=newposition; newalphas(index_up)=alpha; newcolors(index_up,:)=color; % Copy the (last) old markers to the new lists newpositions(index_up+1:end)=data.histogram_positions(index_up:end); newalphas(index_up+1:end)=data.histogram_alpha(index_up:end); newcolors(index_up+1:end,:)=data.histogram_colors(index_up:end,:); % Make the new lists the used marker lists data.histogram_positions=newpositions; data.histogram_alpha=newalphas; data.histogram_colors=newcolors; end end % Update the histogram window cla(data.handle_histogram_axes); setMyData(data); drawHistogramPoints(); createAlphaColorTable(); show3d(false); function cursor_position_in_histogram_axes(hObject,handles) data=getMyData(); if(isempty(data)), return, end % Get position of the mouse in the large axes p = get(0, 'PointerLocation'); pf = get(hObject, 'pos'); p(1:2) = p(1:2)-pf(1:2); set(data.handle_histogram, 'CurrentPoint', p(1:2)); p = get(data.handle_histogram_axes, 'CurrentPoint'); data.histogram_mouse_position=[p(1, 1) p(1, 2)]; setMyData(data); % -------------------------------------------------------------------- function menu_help_Callback(hObject, eventdata, handles) % hObject handle to menu_help (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) web('info.html'); % --- Executes when user attempts to close figure1. function figure1_CloseRequestFcn(hObject, eventdata, handles) % hObject handle to figure1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: delete(hObject) closes the figure data=getMyData(); if(isempty(data)), return, end try delete(data.handle_histogram); catch end try rmappdata(gcf,'data3d'); catch end delete(hObject); % parallel % matlabpool close; % -------------------------------------------------------------------- function menu_shiny_Callback(hObject, eventdata, handles) % hObject handle to menu_shiny (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.shading_material='shiny'; setMyData(data); show3d(false); % -------------------------------------------------------------------- function menu_dull_Callback(hObject, eventdata, handles) % hObject handle to menu_dull (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.shading_material='dull'; setMyData(data); show3d(false); % -------------------------------------------------------------------- function menu_metal_Callback(hObject, eventdata, handles) % hObject handle to menu_metal (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.shading_material='metal'; setMyData(data); show3d(false); % -------------------------------------------------------------------- function menu_rendersize400_Callback(hObject, eventdata, handles) % hObject handle to menu_rendersize400 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.axes_size=[400 400]; data.first_render=true; setMyData(data); show3d(false); % -------------------------------------------------------------------- function menu_rendersize800_Callback(hObject, eventdata, handles) % hObject handle to menu_rendersize800 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.axes_size=[800 800]; data.first_render=true; setMyData(data); show3d(false);
github
jacksky64/imageProcessing-master
render_bw.m
.m
imageProcessing-master/Matlab Viewer3D/Old_Viewer3D_with_c_code/render_bw.m
14,821
utf_8
2cb5030bd45ce542008cf0137d46a44a
function render_image = render_bw(V, image_size, Mview,alphatable) % Function RENDER_BW will volume render a Image of a 3D volume with % a transperancy table. % % I = RENDER_MIP(V, SIZE, Mview, ALPHAtable); % % inputs, % V: Input image volume % SIZE: Sizes (height and length) of output image % Mview: Viewer (Transformation) matrix 4x4 % ALPHATABLE: Mapping from intensities to transperancy % range [0 1], dimensions Nx1 % outputs, % I: The maximum intensity output image % % Volume Data, % Range of V must be [0 1] in case of double or single otherwise % mex function will crash. Data of type double has short render times, % uint16 the longest. % % example, % % Load data % load TestVolume; % % Parameters % sizes=[400 400]; % Mview=makeViewMatrix([45 45 0],[0.5 0.5 0.5],[0 0 0]); % alphatable=(0:999)/999; % % Render and show image % I = render_bw(V, sizes, Mview,alphatable); % imshow(I); % % Function is written by D.Kroon University of Twente (November 2008) % Needed to convert intensities to range [0 1] imax=1; if(isa(V,'uint8')), imax=2^8-1; end if(isa(V,'uint16')), imax=2^16-1; end if(isa(V,'uint32')), imax=2^32-1; end % Calculate the Shear and Warp Matrices [Mshear,Mwarp2D,c]=makeShearWarpMatrix(Mview,size(V)); Mwarp2Dinv=inv(double(Mwarp2D)); Mshearinv=inv(Mshear); % Store Volume sizes Iin_sizex=size(V,1); Iin_sizey=size(V,2); Iin_sizez=size(V,3); % Create Shear (intimidate) buffer Ibuffer_sizex=ceil(1.7321*max(size(V))+1); Ibuffer_sizey=Ibuffer_sizex; Ibuffer=zeros([Ibuffer_sizex Ibuffer_sizey]); switch (c) case 1 for z=0:(Iin_sizex-1); % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizex/2)+Iin_sizey/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizex/2)+Iin_sizez/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizez-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizey-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(z+1,xBas, yBas))); intensity_xyz2=double(squeeze(V(z+1,xBas, yBas1))); intensity_xyz3=double(squeeze(V(z+1,xBas1, yBas))); intensity_xyz4=double(squeeze(V(z+1,xBas1, yBas1))); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable); end case 2 for z=0:(Iin_sizey-1), % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizey/2)+Iin_sizez/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizey/2)+Iin_sizex/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizex-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizez-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(yBas, z+1,xBas))); intensity_xyz2=double(squeeze(V(yBas1, z+1,xBas))); intensity_xyz3=double(squeeze(V(yBas, z+1,xBas1))); intensity_xyz4=double(squeeze(V(yBas1, z+1,xBas1))); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable); end case 3 for z=0:(Iin_sizez-1), % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizez/2)+Iin_sizex/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizez/2)+Iin_sizey/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizey-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizex-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(V(xBas, yBas, z+1)); intensity_xyz2=double(V(xBas, yBas1, z+1)); intensity_xyz3=double(V(xBas1, yBas, z+1)); intensity_xyz4=double(V(xBas1, yBas1, z+1)); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable); end case 4 for z=(Iin_sizex-1):-1:0, % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizex/2)+Iin_sizey/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizex/2)+Iin_sizez/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizez-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizey-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(z+1,xBas, yBas))); intensity_xyz2=double(squeeze(V(z+1,xBas, yBas1))); intensity_xyz3=double(squeeze(V(z+1,xBas1, yBas))); intensity_xyz4=double(squeeze(V(z+1,xBas1, yBas1))); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable); end case 5 for z=(Iin_sizey-1):-1:0, % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizey/2)+Iin_sizez/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizey/2)+Iin_sizex/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizex-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizez-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(yBas, z+1,xBas))); intensity_xyz2=double(squeeze(V(yBas1, z+1,xBas))); intensity_xyz3=double(squeeze(V(yBas, z+1,xBas1))); intensity_xyz4=double(squeeze(V(yBas1, z+1,xBas1))); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable); end case 6 for z=(Iin_sizez-1):-1:0, % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizez/2)+Iin_sizex/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizez/2)+Iin_sizey/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizey-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizex-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(V(xBas, yBas, z+1)); intensity_xyz2=double(V(xBas, yBas1, z+1)); intensity_xyz3=double(V(xBas1, yBas, z+1)); intensity_xyz4=double(V(xBas1, yBas1, z+1)); % Calculate the interpolated intensity intensity_loc=(intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4))/imax; % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable); end end render_image = warp(Ibuffer, image_size(1:2),Mshearinv,Mwarp2Dinv,c); function Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c,alphatable) % Rotate image for two main view directions if(c==2||c==5), intensity_loc=intensity_loc'; end % Calculate index in alpha transparency look up table indexAlpha=round(intensity_loc*(length(alphatable)-1))+1; % calculate current alphaimage alphaimage=alphatable(indexAlpha); % Update the current pixel in the shear image buffer Ibuffer(px,py)=(1-alphaimage).*Ibuffer(px,py)+alphaimage.*intensity_loc;
github
jacksky64/imageProcessing-master
viewer3d_error.m
.m
imageProcessing-master/Matlab Viewer3D/Old_Viewer3D_with_c_code/viewer3d_error.m
3,313
utf_8
abc306910c64efef252c1762e396a06b
function varargout = viewer3d_error(varargin) % VIEWER3D_ERROR M-file for viewer3d_error.fig % VIEWER3D_ERROR, by itself, creates a new VIEWER3D_ERROR or raises the existing % singleton*. % % H = VIEWER3D_ERROR returns the handle to a new VIEWER3D_ERROR or the handle to % the existing singleton*. % % VIEWER3D_ERROR('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in VIEWER3D_ERROR.M with the given input arguments. % % VIEWER3D_ERROR('Property','Value',...) creates a new VIEWER3D_ERROR or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before viewer3d_error_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to viewer3d_error_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help viewer3d_error % Last Modified by GUIDE v2.5 05-Nov-2008 14:39:24 % Begin initialization code - DO NOT EDIT gui_Singleton = 0; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_error_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_error_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d_error is made visible. function viewer3d_error_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d_error (see VARARGIN) % Choose default command line output for viewer3d_error handles.output = hObject; % Update handles structure guidata(hObject, handles); if (~isempty(varargin)) set(handles.text1,'string',varargin{1}) end % UIWAIT makes viewer3d_error wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = viewer3d_error_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) delete(handles.figure1);
github
jacksky64/imageProcessing-master
viewer3d_about.m
.m
imageProcessing-master/Matlab Viewer3D/Old_Viewer3D_with_c_code/viewer3d_about.m
2,927
utf_8
9e977443451bfd53ee2b650fe96f2246
function varargout = viewer3d_about(varargin) % VIEWER3D_ABOUT M-file for viewer3d_about.fig % VIEWER3D_ABOUT, by itself, creates a new VIEWER3D_ABOUT or raises the existing % singleton*. % % H = VIEWER3D_ABOUT returns the handle to a new VIEWER3D_ABOUT or the handle to % the existing singleton*. % % VIEWER3D_ABOUT('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in VIEWER3D_ABOUT.M with the given input arguments. % % VIEWER3D_ABOUT('Property','Value',...) creates a new VIEWER3D_ABOUT or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before viewer3d_about_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to viewer3d_about_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help viewer3d_about % Last Modified by GUIDE v2.5 30-Oct-2008 19:58:12 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_about_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_about_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d_about is made visible. function viewer3d_about_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d_about (see VARARGIN) % Choose default command line output for viewer3d_about handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes viewer3d_about wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = viewer3d_about_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output;
github
jacksky64/imageProcessing-master
render_mip.m
.m
imageProcessing-master/Matlab Viewer3D/Old_Viewer3D_with_c_code/render_mip.m
14,111
utf_8
c8a9c3c0b5d6a93f349bfba6f1cbc48b
function render_image = render_mip(V, image_size, Mview) % Function RENDER_MIP will render a Maximum Intensity Image of a 3D volume % % I = RENDER_MIP(V, SIZE, Mview); % % inputs, % V: Input image volume % SIZE: Sizes (height and length) of output image % Mview: Transformation matrix % % outputs, % I: The maximum intensity output image % % example, % % Load data % load TestVolume; % % Parameters % sizes=[400 400]; % Mview=makeViewMatrix([45 45 0],[0.5 0.5 0.5],[0 0 0]); % % Render and show image % I = render_mip(V, sizes, Mview); % imshow(I); % % Function is written by D.Kroon University of Twente (November 2008) % Needed to convert intensities to range [0 1] imax=1; if(isa(V,'uint8')), imax=2^8-1; end if(isa(V,'uint16')), imax=2^16-1; end if(isa(V,'uint32')), imax=2^32-1; end % Calculate the Shear and Warp Matrices [Mshear,Mwarp2D,c]=makeShearWarpMatrix(Mview,size(V)); Mwarp2Dinv=inv(double(Mwarp2D)); Mshearinv=inv(Mshear); % Store Volume sizes Iin_sizex=size(V,1); Iin_sizey=size(V,2); Iin_sizez=size(V,3); % Create Shear (intimidate) buffer Ibuffer_sizex=ceil(1.7321*max(size(V))+1); Ibuffer_sizey=Ibuffer_sizex; Ibuffer=zeros([Ibuffer_sizex Ibuffer_sizey]); switch (c) case 1 for z=0:(Iin_sizex-1); % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizex/2)+Iin_sizey/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizex/2)+Iin_sizez/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizez-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizey-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(z+1,xBas, yBas))); intensity_xyz2=double(squeeze(V(z+1,xBas, yBas1))); intensity_xyz3=double(squeeze(V(z+1,xBas1, yBas))); intensity_xyz4=double(squeeze(V(z+1,xBas1, yBas1))); % Calculate the interpolated intensity intensity_loc=intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4); % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c); end case 2 for z=0:(Iin_sizey-1), % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizey/2)+Iin_sizez/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizey/2)+Iin_sizex/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizex-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizez-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(yBas, z+1,xBas))); intensity_xyz2=double(squeeze(V(yBas1, z+1,xBas))); intensity_xyz3=double(squeeze(V(yBas, z+1,xBas1))); intensity_xyz4=double(squeeze(V(yBas1, z+1,xBas1))); % Calculate the interpolated intensity intensity_loc=intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4); % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c); end case 3 for z=0:(Iin_sizez-1), % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizez/2)+Iin_sizex/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizez/2)+Iin_sizey/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizey-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizex-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(V(xBas, yBas, z+1)); intensity_xyz2=double(V(xBas, yBas1, z+1)); intensity_xyz3=double(V(xBas1, yBas, z+1)); intensity_xyz4=double(V(xBas1, yBas1, z+1)); % Calculate the interpolated intensity intensity_loc=intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4); % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c); end case 4 for z=(Iin_sizex-1):-1:0, % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizex/2)+Iin_sizey/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizex/2)+Iin_sizez/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizez-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizey-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(z+1,xBas, yBas))); intensity_xyz2=double(squeeze(V(z+1,xBas, yBas1))); intensity_xyz3=double(squeeze(V(z+1,xBas1, yBas))); intensity_xyz4=double(squeeze(V(z+1,xBas1, yBas1))); % Calculate the interpolated intensity intensity_loc=intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4); % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c); end case 5 for z=(Iin_sizey-1):-1:0, % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizey/2)+Iin_sizez/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizey/2)+Iin_sizex/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizex-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizez-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(squeeze(V(yBas, z+1,xBas))); intensity_xyz2=double(squeeze(V(yBas1, z+1,xBas))); intensity_xyz3=double(squeeze(V(yBas, z+1,xBas1))); intensity_xyz4=double(squeeze(V(yBas1, z+1,xBas1))); % Calculate the interpolated intensity intensity_loc=intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4); % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c); end case 6 for z=(Iin_sizez-1):-1:0, % Offset calculation xd=(-Ibuffer_sizex/2)+Mshearinv(1,3)*(z-Iin_sizez/2)+Iin_sizex/2; yd=(-Ibuffer_sizey/2)+Mshearinv(2,3)*(z-Iin_sizez/2)+Iin_sizey/2; xdfloor=floor(xd); ydfloor=floor(yd); % Linear interpolation constants (percentages) xCom=xd-floor(xd); yCom=yd-floor(yd); perc(1)=(1-xCom) * (1-yCom); perc(2)=(1-xCom) * yCom; perc(3)=xCom * (1-yCom); perc(4)=xCom * yCom; %Calculate the coordinates on which a image slice starts and %ends in the temporary shear image (buffer) pystart=-ydfloor; if(pystart<0), pystart=0; end pyend=Iin_sizey-ydfloor; if(pyend>Ibuffer_sizey), pyend=Ibuffer_sizey; end pxstart=-xdfloor; if(pxstart<0), pxstart=0; end pxend=Iin_sizex-xdfloor; if(pxend>Ibuffer_sizex), pxend=Ibuffer_sizex; end py=(pystart+1:pyend-1); % Determine y coordinates of pixel(s) which will be come current pixel yBas=py+ydfloor; px=(pxstart+1:pxend-1); %Determine x coordinates of pixel(s) which will be come current pixel xBas=px+xdfloor; xBas1=xBas+1; xBas1(end)=xBas1(end)-1; yBas1=yBas+1; yBas1(end)=yBas1(end)-1; % Get the intensities intensity_xyz1=double(V(xBas, yBas, z+1)); intensity_xyz2=double(V(xBas, yBas1, z+1)); intensity_xyz3=double(V(xBas1, yBas, z+1)); intensity_xyz4=double(V(xBas1, yBas1, z+1)); % Calculate the interpolated intensity intensity_loc=intensity_xyz1*perc(1)+intensity_xyz2*perc(2)+intensity_xyz3*perc(3)+intensity_xyz4*perc(4); % Update the shear image buffer Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c); end end Ibuffer=Ibuffer/imax; render_image = warp(Ibuffer, image_size(1:2),Mshearinv,Mwarp2Dinv,c); function Ibuffer=updatebuffer(intensity_loc,Ibuffer,px,py,c) if(c==2||c==5), intensity_loc=intensity_loc'; end % Update the current pixel in the shear image buffer check=double(intensity_loc>Ibuffer(px,py)); Ibuffer(px,py)=(check).*intensity_loc+(1-check).*Ibuffer(px,py);
github
jacksky64/imageProcessing-master
bitmaptext.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/bitmaptext.m
100,462
utf_8
6a905a18b93a3d3e263a7630face0e68
function I=bitmaptext(lines,I,pos,options) % The function BITMAPTEXT will insert textline(s) on the specified position % in the image. % % I=bitmaptext(Text,Ibackground,Position,options) % % inputs, % Text : Cell array with text lines % Ibackground: the bitmap used as background when a m x n x 3 matrix % color plots are made, when m x n a greyscale plot. If empty [] % autosize to fit text. % Position: x,y position of the text % options: struct with options such as color % % outputs, % Iplot: The bitmap containing the plotted text % % note, % Colors are always [r(ed) g(reen) b(lue) a(pha)], with range 0..1. % when Ibackground is grayscale, the mean of r,g,b is used as grey value. % % options, % options.Color: The color of the text. % options.FontSize: The size of the font, 1,2 or 3 (small,medium,large). % % example, % % % The text consisting of 2 lines % lines={'a_A_j_J?,','ImageText version 1.1'}; % % Background image % I=ones([256 256 3]); % % Plot text into background image % I=bitmaptext(lines,I,[1 1],struct('FontSize',3)); % % Show the result % figure, imshow(I), % % Function is written by D.Kroon University of Twente (March 2009) global character_images; % Process inputs defaultoptions=struct('Color',[0 0 1 1],'FontSize',1); if(~exist('options','var')), options=defaultoptions; else tags = fieldnames(defaultoptions); for i=1:length(tags) if(~isfield(options,tags{i})), options.(tags{i})=defaultoptions.(tags{i}); end end if(length(tags)~=length(fieldnames(options))), warning('register_images:unknownoption','unknown options found'); end end % If single line make it a cell array if(~iscell(lines)), lines={lines}; end if(~exist('I','var')), I=[]; end if(exist('pos','var')), if(length(pos)~=2) error('imagtext:inputs','position must have x,y coordinates'); end else pos=[1 1]; end % Set the size of the font fsize=options.FontSize; % The character bitmap and character set; character_set='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_+-=[]\;'''',./{}|:"<>?'; if(isempty(character_images)), character_images=load_font(); end % Font parameters Font_sizes_x=[8 10 11]; Font_sizes_y=[13 15 18]; Font_startx=[1 1 1]; Font_starty=[1 14 29]; % Get maximum sentence length lengths=zeros(1,length(lines)); for i=1:length(lines), lengths(i)=length(lines{i}); end max_line_length=max(lengths); % Make text image from the lines lines_image=zeros([(Font_sizes_y(fsize)+4)*length(lines),max_line_length*Font_sizes_x(fsize)],'double'); for j=1:length(lines) line=lines{j}; for i=1:length(line), [t,p]=find(character_set==line(i)); if(~isempty(p)) p=p(1)-1; character_bitmap=character_images(Font_starty(fsize):(Font_starty(fsize)+Font_sizes_y(fsize)-1),Font_startx(fsize)+(1+p*Font_sizes_x(fsize)):Font_startx(fsize)+((p+1)*Font_sizes_x(fsize))); posx=Font_sizes_x(fsize)*(i-1); posy=(Font_sizes_y(fsize)+4)*(j-1); lines_image((1:Font_sizes_y(fsize))+posy,(1:Font_sizes_x(fsize))+posx)=character_bitmap; end end end if(isempty(I)), I=zeros([size(lines_image) 3]); end % Remove part of textimage which will be outside of the output image if(pos(1)<1), lines_image=lines_image(2-pos(1):end,:); pos(1)=1; end if(pos(2)<2), lines_image=lines_image(:,2-pos(2):end); pos(2)=1; end if((pos(1)+size(lines_image,1))>size(I,1)), dif=size(I,1)-(pos(1)+size(lines_image,1)); lines_image=lines_image(1:end+dif,:); end if((pos(2)+size(lines_image,2))>size(I,2)), dif=size(I,2)-(pos(2)+size(lines_image,2)); lines_image=lines_image(:,1:end+dif); end % Make text image the same size as background image I_line=zeros([size(I,1) size(I,2)]); I_line(pos(1):(pos(1)+size(lines_image,1)-1),pos(2):(pos(2)+size(lines_image,2)-1))=lines_image; I_line=I_line*options.Color(4); % Insert the text image into the output image if(~isempty(lines_image)) if(size(I,3)==3) for i=1:3 I(:,:,i)=I(:,:,i).*(1-I_line)+options.Color(i)*(I_line); end else I=I.*(1-I_line)+mean(options.Color(1:3))*(I_line); end end function character_images=load_font() character_images=uint8([0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]); character_images=double(character_images)/9;
github
jacksky64/imageProcessing-master
viewer3d_qualityspeed.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/viewer3d_qualityspeed.m
6,060
utf_8
b56938bc38cf2f4eccdd0ba38ff93d0a
function varargout = viewer3d_qualityspeed(varargin) % VIEWER3D_QUALITYSPEED M-file for viewer3d_qualityspeed.fig % VIEWER3D_QUALITYSPEED, by itself, creates a new VIEWER3D_QUALITYSPEED or raises the existing % singleton*. % % H = VIEWER3D_QUALITYSPEED returns the handle to a new VIEWER3D_QUALITYSPEED or the handle to % the existing singleton*. % % VIEWER3D_QUALITYSPEED('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in VIEWER3D_QUALITYSPEED.M with the given input arguments. % % VIEWER3D_QUALITYSPEED('Property','Value',...) creates a new VIEWER3D_QUALITYSPEED or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before viewer3d_qualityspeed_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to viewer3d_qualityspeed_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help viewer3d_qualityspeed % Last Modified by GUIDE v2.5 10-Nov-2010 13:55:49 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_qualityspeed_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_qualityspeed_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d_qualityspeed is made visible. function viewer3d_qualityspeed_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d_qualityspeed (see VARARGIN) % Choose default command line output for viewer3d_qualityspeed handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes viewer3d_qualityspeed wait for user response (see UIRESUME) % uiwait(handles.figurequalityspeed); % --- Outputs from this function are returned to the command line. function varargout = viewer3d_qualityspeed_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in checkbox_prerender. function checkbox_prerender_Callback(hObject, eventdata, handles) % hObject handle to checkbox_prerender (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of checkbox_prerender % --- Executes on button press in radiobutton_scaling25. function radiobutton_scaling25_Callback(hObject, eventdata, handles) % hObject handle to radiobutton_scaling25 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of radiobutton_scaling25 % --- Executes on button press in radiobutton_scaling50. function radiobutton_scaling50_Callback(hObject, eventdata, handles) % hObject handle to radiobutton_scaling50 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of radiobutton_scaling50 % --- Executes on button press in radiobutton_scaling100. function radiobutton_scaling100_Callback(hObject, eventdata, handles) % hObject handle to radiobutton_scaling100 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of radiobutton_scaling100 % --- Executes on button press in radiobutton_scaling200. function radiobutton_scaling200_Callback(hObject, eventdata, handles) % hObject handle to radiobutton_scaling200 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of radiobutton_scaling200 % --- Executes on button press in checkbox_storexyz. function checkbox_storexyz_Callback(hObject, eventdata, handles) % hObject handle to checkbox_storexyz (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of checkbox_storexyz % --- Executes on button press in pushbutton_applyconfig. function pushbutton_applyconfig_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_applyconfig (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in pushbutton_saveconfig. function pushbutton_saveconfig_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_saveconfig (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
github
jacksky64/imageProcessing-master
viewer3d_voxelsize.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/viewer3d_voxelsize.m
8,989
utf_8
05035f45cf682370f5de14ad000e1ffa
function varargout = viewer3d_voxelsize(varargin) % VIEWER3D_VOXELSIZE M-file for viewer3d_voxelsize.fig % VIEWER3D_VOXELSIZE, by itself, creates a new VIEWER3D_VOXELSIZE or raises the existing % singleton*. % % H = VIEWER3D_VOXELSIZE returns the handle to a new VIEWER3D_VOXELSIZE or the handle to % the existing singleton*. % % VIEWER3D_VOXELSIZE('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in VIEWER3D_VOXELSIZE.M with the given input arguments. % % VIEWER3D_VOXELSIZE('Property','Value',...) creates a new VIEWER3D_VOXELSIZE or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before viewer3d_voxelsize_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to viewer3d_voxelsize_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help viewer3d_voxelsize % Last Modified by GUIDE v2.5 10-Nov-2010 13:54:19 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_voxelsize_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_voxelsize_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d_voxelsize is made visible. function viewer3d_voxelsize_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d_voxelsize (see VARARGIN) % Choose default command line output for viewer3d_voxelsize handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes viewer3d_voxelsize wait for user response (see UIRESUME) % uiwait(handles.figurevoxelsize); % --- Outputs from this function are returned to the command line. function varargout = viewer3d_voxelsize_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; function edit_scax_Callback(hObject, eventdata, handles) % hObject handle to edit_scax (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_scax as text % str2double(get(hObject,'String')) returns contents of edit_scax as a double % --- Executes during object creation, after setting all properties. function edit_scax_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_scax (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_scay_Callback(hObject, eventdata, handles) % hObject handle to edit_scay (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_scay as text % str2double(get(hObject,'String')) returns contents of edit_scay as a double % --- Executes during object creation, after setting all properties. function edit_scay_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_scay (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_scaz_Callback(hObject, eventdata, handles) % hObject handle to edit_scaz (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_scaz as text % str2double(get(hObject,'String')) returns contents of edit_scaz as a double % --- Executes during object creation, after setting all properties. function edit_scaz_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_scaz (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_volx_Callback(hObject, eventdata, handles) % hObject handle to edit_volx (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_volx as text % str2double(get(hObject,'String')) returns contents of edit_volx as a double % --- Executes during object creation, after setting all properties. function edit_volx_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_volx (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_voly_Callback(hObject, eventdata, handles) % hObject handle to edit_voly (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_voly as text % str2double(get(hObject,'String')) returns contents of edit_voly as a double % --- Executes during object creation, after setting all properties. function edit_voly_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_voly (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_volz_Callback(hObject, eventdata, handles) % hObject handle to edit_volz (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_volz as text % str2double(get(hObject,'String')) returns contents of edit_volz as a double % --- Executes during object creation, after setting all properties. function edit_volz_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_volz (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in button_apply. function button_apply_Callback(hObject, eventdata, handles) % hObject handle to button_apply (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
github
jacksky64/imageProcessing-master
viewer3d_lightvector.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/viewer3d_lightvector.m
6,223
utf_8
15bbf1983818b61fcb3e2747adea2fe1
function varargout = viewer3d_lightvector(varargin) % VIEWER3D_LIGHTVECTOR M-file for viewer3d_lightvector.fig % VIEWER3D_LIGHTVECTOR, by itself, creates a new VIEWER3D_LIGHTVECTOR or raises the existing % singleton*. % % H = VIEWER3D_LIGHTVECTOR returns the handle to a new VIEWER3D_LIGHTVECTOR or the handle to % the existing singleton*. % % VIEWER3D_LIGHTVECTOR('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in VIEWER3D_LIGHTVECTOR.M with the given input arguments. % % VIEWER3D_LIGHTVECTOR('Property','Value',...) creates a new VIEWER3D_LIGHTVECTOR or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before viewer3d_lightvector_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to viewer3d_lightvector_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help viewer3d_lightvector % Last Modified by GUIDE v2.5 25-Feb-2009 14:27:43 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_lightvector_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_lightvector_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d_lightvector is made visible. function viewer3d_lightvector_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d_lightvector (see VARARGIN) % Choose default command line output for viewer3d_lightvector handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes viewer3d_lightvector wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = viewer3d_lightvector_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; function edit_lightx_Callback(hObject, eventdata, handles) % hObject handle to edit_lightx (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_lightx as text % str2double(get(hObject,'String')) returns contents of edit_lightx as a double % --- Executes during object creation, after setting all properties. function edit_lightx_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_lightx (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_lighty_Callback(hObject, eventdata, handles) % hObject handle to edit_lighty (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_lighty as text % str2double(get(hObject,'String')) returns contents of edit_lighty as a double % --- Executes during object creation, after setting all properties. function edit_lighty_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_lighty (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit_lightz_Callback(hObject, eventdata, handles) % hObject handle to edit_lightz (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_lightz as text % str2double(get(hObject,'String')) returns contents of edit_lightz as a double % --- Executes during object creation, after setting all properties. function edit_lightz_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_lightz (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in button_apply. function button_apply_Callback(hObject, eventdata, handles) % hObject handle to button_apply (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
github
jacksky64/imageProcessing-master
viewer3d_histogram.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/viewer3d_histogram.m
4,955
utf_8
707fcbdb2a3d383b3de6cfbb144169d0
function varargout = viewer3d_histogram(varargin) % This function is part of VIEWER3D % % color and alpha maps can be changed on the fly by dragging and creating % new color/alpha markers with the left mouse button. % % Function is written by D.Kroon University of Twente (October 2008) % Edit the above text to modify the response to help viewer3d_histogram % Last Modified by GUIDE v2.5 10-Nov-2010 13:53:41 % Begin initialization code - DO NOT EDIT gui_Singleton = 0; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_histogram_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_histogram_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d_histogram is made visible. function viewer3d_histogram_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d_histogram (see VARARGIN) % Choose default command line output for viewer3d_histogram handles.output = hObject; % Update handles structure guidata(hObject, handles); function figurehistogram_WindowButtonMotionFcn(hObject, eventdata, handles) function varargout = viewer3d_histogram_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes during object creation, after setting all properties. function popupmenu_colors_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu_colors (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. set(hObject,'String',{'jet','hsv','hot','cool','spring','summer','autumn','winter','gray','bone','copper','pink'}); set(hObject,'Value',3); if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % -------------------------------------------------------------------- function menu_file_Callback(hObject, eventdata, handles) % hObject handle to menu_file (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_load_Callback(hObject, eventdata, handles) % hObject handle to menu_load (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function menu_save_Callback(hObject, eventdata, handles) % hObject handle to menu_save (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on selection change in popupmenu_colors. function popupmenu_colors_Callback(hObject, eventdata, handles) % hObject handle to popupmenu_colors (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns popupmenu_colors contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu_colors % --- Executes on button press in pushbutton_update_view. function pushbutton_update_view_Callback(hObject, eventdata, handles) % hObject handle to pushbutton_update_view (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in checkbox_auto_update. function checkbox_auto_update_Callback(hObject, eventdata, handles) % hObject handle to checkbox_auto_update (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of checkbox_auto_update
github
jacksky64/imageProcessing-master
makeViewMatrix.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/makeViewMatrix.m
1,190
utf_8
49d443a4402c434f497d4b2dba34f211
function Mview=makeViewMatrix(r,s,t) % function makeViewMatrix construct a 4x4 transformation matrix from % rotation, resize and translation variables. % % Mview=makeViewMatrix(R,S,T) % % inputs, % R: Rotation vector [Rx, Ry, Rz]; % S: Resize vector [Sx, Sy, Sz]; % T: Translation vector [Tx, Ty, Tz]; % % outputs, % Mview: 4x4 transformation matrix % % Example, % Mview=makeViewMatrix([45 45 0],[1 1 1],[0 0 0]); % disp(Mview); % % Function is written by D.Kroon University of Twente (October 2008) R=RotationMatrix(r); S=ResizeMatrix(s); T=TranslateMatrix(t); Mview=R*S*T; function R=RotationMatrix(r) % Determine the rotation matrix (View matrix) for rotation angles xyz ... Rx=[1 0 0 0; 0 cosd(r(1)) -sind(r(1)) 0; 0 sind(r(1)) cosd(r(1)) 0; 0 0 0 1]; Ry=[cosd(r(2)) 0 sind(r(2)) 0; 0 1 0 0; -sind(r(2)) 0 cosd(r(2)) 0; 0 0 0 1]; Rz=[cosd(r(3)) -sind(r(3)) 0 0; sind(r(3)) cosd(r(3)) 0 0; 0 0 1 0; 0 0 0 1]; R=Rx*Ry*Rz; function S=ResizeMatrix(s) S=[1/s(1) 0 0 0; 0 1/s(2) 0 0; 0 0 1/s(3) 0; 0 0 0 1]; function T=TranslateMatrix(t) T=[1 0 0 -t(1); 0 1 0 -t(2); 0 0 1 -t(3); 0 0 0 1];
github
jacksky64/imageProcessing-master
viewer3d_console.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/viewer3d_console.m
4,231
utf_8
c358c82f26d26886a33ea68845e6cfb0
function varargout = viewer3d_console(varargin) % VIEWER3D_CONSOLE M-file for viewer3d_console.fig % VIEWER3D_CONSOLE, by itself, creates a new VIEWER3D_CONSOLE or raises the existing % singleton*. % % H = VIEWER3D_CONSOLE returns the handle to a new VIEWER3D_CONSOLE or the handle to % the existing singleton*. % % VIEWER3D_CONSOLE('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in VIEWER3D_CONSOLE.M with the given input arguments. % % VIEWER3D_CONSOLE('Property','Value',...) creates a new VIEWER3D_CONSOLE or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before viewer3d_console_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to viewer3d_console_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help viewer3d_console % Last Modified by GUIDE v2.5 10-Nov-2010 13:56:33 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_console_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_console_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d_console is made visible. function viewer3d_console_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d_console (see VARARGIN) % Choose default command line output for viewer3d_console handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes viewer3d_console wait for user response (see UIRESUME) % uiwait(handles.figureconsole); % --- Outputs from this function are returned to the command line. function varargout = viewer3d_console_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; function edit_console_Callback(hObject, eventdata, handles) % hObject handle to edit_console (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_console as text % str2double(get(hObject,'String')) returns contents of edit_console as a double % --- Executes during object creation, after setting all properties. function edit_console_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_console (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in button_clear. function button_clear_Callback(hObject, eventdata, handles) % hObject handle to button_clear (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
github
jacksky64/imageProcessing-master
viewer3d_error.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/viewer3d_error.m
3,313
utf_8
abc306910c64efef252c1762e396a06b
function varargout = viewer3d_error(varargin) % VIEWER3D_ERROR M-file for viewer3d_error.fig % VIEWER3D_ERROR, by itself, creates a new VIEWER3D_ERROR or raises the existing % singleton*. % % H = VIEWER3D_ERROR returns the handle to a new VIEWER3D_ERROR or the handle to % the existing singleton*. % % VIEWER3D_ERROR('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in VIEWER3D_ERROR.M with the given input arguments. % % VIEWER3D_ERROR('Property','Value',...) creates a new VIEWER3D_ERROR or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before viewer3d_error_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to viewer3d_error_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help viewer3d_error % Last Modified by GUIDE v2.5 05-Nov-2008 14:39:24 % Begin initialization code - DO NOT EDIT gui_Singleton = 0; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_error_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_error_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d_error is made visible. function viewer3d_error_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d_error (see VARARGIN) % Choose default command line output for viewer3d_error handles.output = hObject; % Update handles structure guidata(hObject, handles); if (~isempty(varargin)) set(handles.text1,'string',varargin{1}) end % UIWAIT makes viewer3d_error wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = viewer3d_error_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) delete(handles.figure1);
github
jacksky64/imageProcessing-master
viewer3d_about.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/viewer3d_about.m
2,931
utf_8
b00f2eccc530dd07ac25d2285ef08012
function varargout = viewer3d_about(varargin) % VIEWER3D_ABOUT M-file for viewer3d_about.fig % VIEWER3D_ABOUT, by itself, creates a new VIEWER3D_ABOUT or raises the existing % singleton*. % % H = VIEWER3D_ABOUT returns the handle to a new VIEWER3D_ABOUT or the handle to % the existing singleton*. % % VIEWER3D_ABOUT('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in VIEWER3D_ABOUT.M with the given input arguments. % % VIEWER3D_ABOUT('Property','Value',...) creates a new VIEWER3D_ABOUT or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before viewer3d_about_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to viewer3d_about_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help viewer3d_about % Last Modified by GUIDE v2.5 10-Nov-2010 13:57:15 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_about_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_about_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d_about is made visible. function viewer3d_about_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d_about (see VARARGIN) % Choose default command line output for viewer3d_about handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes viewer3d_about wait for user response (see UIRESUME) % uiwait(handles.figureabout); % --- Outputs from this function are returned to the command line. function varargout = viewer3d_about_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output;
github
jacksky64/imageProcessing-master
viewer3d_workspacevars.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/viewer3d_workspacevars.m
4,426
utf_8
7a77a2a3833854c6146fc182b03521b8
function varargout = viewer3d_workspacevars(varargin) % VIEWER3D_WORKSPACEVARS M-file for viewer3d_workspacevars.fig % VIEWER3D_WORKSPACEVARS, by itself, creates a new VIEWER3D_WORKSPACEVARS or raises the existing % singleton*. % % H = VIEWER3D_WORKSPACEVARS returns the handle to a new VIEWER3D_WORKSPACEVARS or the handle to % the existing singleton*. % % VIEWER3D_WORKSPACEVARS('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in VIEWER3D_WORKSPACEVARS.M with the given input arguments. % % VIEWER3D_WORKSPACEVARS('Property','Value',...) creates a new VIEWER3D_WORKSPACEVARS or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before viewer3d_workspacevars_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to viewer3d_workspacevars_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help viewer3d_workspacevars % Last Modified by GUIDE v2.5 10-Nov-2010 13:55:11 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_workspacevars_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_workspacevars_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d_workspacevars is made visible. function viewer3d_workspacevars_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d_workspacevars (see VARARGIN) % Choose default command line output for viewer3d_workspacevars handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes viewer3d_workspacevars wait for user response (see UIRESUME) % uiwait(handles.figureworkspacevars); % --- Outputs from this function are returned to the command line. function varargout = viewer3d_workspacevars_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on selection change in listbox_vars. function listbox_vars_Callback(hObject, eventdata, handles) % hObject handle to listbox_vars (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = get(hObject,'String') returns listbox_vars contents as cell array % contents{get(hObject,'Value')} returns selected item from listbox_vars % --- Executes during object creation, after setting all properties. function listbox_vars_CreateFcn(hObject, eventdata, handles) % hObject handle to listbox_vars (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on button press in button_load. function button_load_Callback(hObject, eventdata, handles) % hObject handle to button_load (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
github
jacksky64/imageProcessing-master
viewer3d_dicominfo.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/viewer3d_dicominfo.m
3,768
utf_8
799dc4c250afac440206ca300c785cf9
function varargout = viewer3d_dicominfo(varargin) % VIEWER3D_DICOMINFO M-file for viewer3d_dicominfo.fig % VIEWER3D_DICOMINFO, by itself, creates a new VIEWER3D_DICOMINFO or raises the existing % singleton*. % % H = VIEWER3D_DICOMINFO returns the handle to a new VIEWER3D_DICOMINFO or the handle to % the existing singleton*. % % VIEWER3D_DICOMINFO('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in VIEWER3D_DICOMINFO.M with the given input arguments. % % VIEWER3D_DICOMINFO('Property','Value',...) creates a new VIEWER3D_DICOMINFO or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before viewer3d_dicominfo_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to viewer3d_dicominfo_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help viewer3d_dicominfo % Last Modified by GUIDE v2.5 10-Nov-2010 13:56:13 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_dicominfo_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_dicominfo_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d_dicominfo is made visible. function viewer3d_dicominfo_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d_dicominfo (see VARARGIN) % Choose default command line output for viewer3d_dicominfo handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes viewer3d_dicominfo wait for user response (see UIRESUME) % uiwait(handles.figuredicominfo); info=varargin{1}; if(isempty(info)), return; end infocell=cell(100000,2); [infocell,poscell]=showinfo(info,infocell,0,''); infocell(poscell+1:end,:)=[]; set(handles.uitable1,'Data',infocell) function [infocell,poscell] = showinfo(info,infocell,poscell,s) fnames=fieldnames(info); for i=1:length(fnames) type=fnames{i}; data=info.(type); if(isnumeric(data)) poscell=poscell+1; infocell{poscell,1}=[s type]; infocell{poscell,2}=num2str(data(:)'); elseif(ischar(data)) poscell=poscell+1; infocell{poscell,1}=[s type]; infocell{poscell,2}=data; elseif(iscell(data)) elseif(isstruct(data)) [infocell,poscell]=showinfo(data,infocell,poscell,[type '.']); end end % --- Outputs from this function are returned to the command line. function varargout = viewer3d_dicominfo_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output;
github
jacksky64/imageProcessing-master
interpcontour.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/interpcontour.m
698
utf_8
693643a87f9f2e5d508ebbbaef519f29
function [x,y,z]=interpcontour(x,y,z,s) % [x,y,z]=interpcontour(x,y,z,s) % pos=[x(:) y(:) z(:)]; [t,ind]=unique(pos,'rows'); pos=pos(sort(ind),:); x=pos(:,1); y=pos(:,2); z=pos(:,3); [x,y,z]=interpcontour1(x,y,z,1); [x,y,z]=interpcontour1(x,y,z,s); function [x,y,z]=interpcontour1(x,y,z,s) i1=(length(x)+1); i2=(length(x)*2)+1; x=[x(:);x(:);x(:)]; y=[y(:);y(:);y(:)]; z=[z(:);z(:);z(:)]; dx=x(2:end)-x(1:end-1); dy=y(2:end)-y(1:end-1); dz=z(2:end)-z(1:end-1); d=cumsum([0;sqrt(dx.^2+dy.^2+dz.^2)]); n=ceil((d(i2)-d(i1))/s); di=linspace(d(i1),d(i2),n+1); di=di(1:end-1); x = interp1(d,x,di,'spline'); y = interp1(d,y,di,'spline'); z = interp1(d,z,di,'spline');
github
jacksky64/imageProcessing-master
menubar.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/menubar.m
22,307
utf_8
7934250b43bec6ecb3cd05f58e364c50
function menubar(varargin) % This function MenuBar, allows the user to create menu's anywhere in a figure % it replaces UIcontextmenu of UIpanels by real menu bars. % % menubar(figure_handle) or menubar % % Mouse hover, and window-resize updates can be enabled by % % menubar('start',figure_handle) or menubar('start') % % Or alternatively by: % % set(figure_handle,'ResizeFcn','menubar(''ResizeFcn'',gcf)'); % set(figure_handle,'WindowButtonMotionFcn','menubar(''MotionFcn'',gcf)'); % % Example, % % % Creat figure with uipanel % figure, % uipanel1 = uipanel('Units','Pixels','Position',[10 200 400 200]); % % % Attach a contextmenu (right-mouse button menu) % menu_panel1=uicontextmenu; % set(uipanel1,'UIContextMenu',menu_panel1); % % % Add menu-items to the context menu % hchild=uimenu(menu_panel1, 'Label', 'Random Pixels'); % uimenu(hchild, 'Label', 'Red','Callback','disp(''Red callback'')'); % uimenu(hchild, 'Label', 'Blue','Callback','disp(''Blue callback'')'); % % % Make form the context menu a real menubar % menubar % % % Add some other menu-buttons % hchild=uimenu(menu_panel1, 'Label', 'Clear','Callback','disp(''Clear'')'); % hchild=uimenu(menu_panel1, 'Label', 'Help'); % uimenu(hchild, 'Label', 'Info','Callback','disp(''Info callback'')'); % % % Update the menubar % menubar % % % Enable the mouse over and resize effects % menubar('start'); % % Function is written by D.Kroon University of Twente (December 2010) % Get Figure Handle figure_handle=gcf; if(nargin>0) if(isnumeric(varargin{1})), figure_handle=varargin{1}; end if(nargin==2), figure_handle=varargin{2}; end if(ischar(varargin{1})) switch lower(varargin{1}) case 'resizefcn' menubar_ResizeFcn(figure_handle); case 'motionfcn' menubar_MotionFcn(figure_handle); case 'start' renewtimer(figure_handle); end return end end % There must be Motion Function otherwise the cursorpostion % in the axis is not updated. if(isempty(get(figure_handle,'WindowButtonMotionFcn'))) set(figure_handle,'WindowButtonMotionFcn',@menubar_DummyFcn); end % Get the Children of the Figure which are UIpanels C=get(figure_handle,'Children'); D=false(size(C)); for i=1:length(C), D(i)=strcmpi(get(C(i),'Type'),'uipanel'); end C=C(D); % Copy UIContextMenu of uipanels to real menubars for i=1:length(C) % If the panel has a UIContextMenu it is processed uimenuhandle=get(C(i),'UIContextMenu'); if(isempty(uimenuhandle)||(~ishandle(uimenuhandle))), continue; end datahandle=C(i); UpdateMenu(datahandle,figure_handle); end figuredata.uipanels=C; setMyData(figuredata,figure_handle) function renewtimer(figure_handle) figuredata=getMyData(figure_handle); if(isempty(figuredata)),return; end if(isfield(figuredata,'timer')) stop(figuredata.timer); delete(figuredata.timer); end figuredata.timer = timer('TimerFcn',@(x,y)menubar_Timer(x,y,figure_handle), 'Period', 0.2,'ExecutionMode','fixedSpacing'); % Start the event-timer start(figuredata.timer); setMyData(figuredata,figure_handle); function m=AddChildren(h,Properties) % This function will create a Matlab Structure from the UICContextMenu % % The structure looks like : % m(1).Label='File'; % m(1).Children(1).Label='New'; % m(1).Children(1).Children(1).Label='Script'; % m(1).Children(1).Children(2).Label='Function'; % m(1).Children(1).Children(2).Separator='on'; % m(1).Children(1).Children(3).Label='Class'; % m(1).Children(1).Children(3).Callback='disp(''callback'')'; % m(1).Children(2).Label='Open'; % m(1).Children(3).Label='Close'; % m(2).Label='Edit'; % m(2).Callback='disp(''callback'')'; % m(3).Label='View'; % m(4).Label='Insert'; % m=struct; % Get all children (menu-items) of the handle hc=get(h,'Children'); % Sort the children by their tag position (menu-items) p=zeros(1,length(hc)); for i=1:length(hc), p(i)=get(hc(i),'Position'); end; [t,i]=sort(p); % Add the menu-item to the structure hc=hc(i); for i=1:length(hc) for j=1:length(Properties) m(i).(Properties{j})=get(hc(i),Properties{j}); end % If the menu-item has also children (sub-menus), then use the current % function recursivly to get all sub-(sub)-(sub)-menus. C=get(hc(i),'Children'); if(~isempty(C)), m(i).Children=AddChildren(hc(i),Properties); end end function CreatMenuBar(uimenuhandle,datahandle,Pos,figure_handle) % Properties (Writeable) of a menu-item Properties={'Label','Callback','Separator','Checked','Enable','ForegroundColor','Position','ButtonDownFcn','Selected','SelectionHighlight','Visible','UserData'}; % This will create a Matlab Structure from the UICContextMenu data.menuitems=AddChildren(uimenuhandle,Properties); % This variable will store the selected-menu button data.sel=[]; % Store the handle to the current figure data.figure_handle=figure_handle; % This variable will store the menu button beneath the mouse % used for hover-animation data.hov=[]; % Store position of uipanel data.Pos=Pos; % This Calculates the length and position of each menu-button % related to the string-lenght of the label tstr=zeros(length(data.menuitems),1); for i=1:length(data.menuitems) tstr(i)=length(data.menuitems(i).Label)*7+16; end % Pos(1) and Pos(2), are the location of the UIpanel in the figure xpositions=[0;cumsum(tstr)]+Pos(1)+1; data.xpositions=xpositions; data.yposition=Pos(2)+Pos(4)-26; % Instead of .png files with the images, we store the pixels to make % menubuttons inside the function loadbarimages [data.IN,data.IS,data.IH]=loadbarimages(); % This function will paint all menu-buttons in the figure for i=1:length(data.menuitems); w=tstr(i); h=25; x=xpositions(i); [barimage,barimagehover,barimageselect]=getbarimage(w,data); data.menuitems(i).Handle=axes('Units','Pixels','Position',[x data.yposition w h],'Parent',figure_handle); data.menuitems(i).HandleImshow=imshow(barimage,'Parent',data.menuitems(i).Handle); set(data.menuitems(i).HandleImshow,'ButtonDownFcn',@(x,y)menubar_ButtonDownFcn(x,y,datahandle)); if(strcmpi(data.menuitems(i).Enable,'on')) hc=text(8,25/2,data.menuitems(i).Label,'Parent',data.menuitems(i).Handle); set(hc,'ButtonDownFcn',@(x,y)menubar_ButtonDownFcn(x,y,datahandle)); else hc=text(8,25/2,data.menuitems(i).Label,'Parent',data.menuitems(i).Handle); data.menuitems(i).Children=[]; set(hc,'Color',[0.5 0.5 0.5]); end data.menuitems(i).barimage=barimage; data.menuitems(i).barimagehover=barimagehover; data.menuitems(i).barimageselect=barimageselect; end i=length(data.menuitems)+1; w=round(Pos(3))-sum(tstr(1:end))-3; w(w<1)=1; x=xpositions(i); barimage=getbarimage(w,data); data.menuitems(i).Handle=axes('Units','Pixels','Position',[x data.yposition w h],'Parent',figure_handle); data.menuitems(i).HandleImshow=imshow(barimage,'Parent',data.menuitems(i).Handle); % This function builds the sub-menus which will appear beneath the menubar % in the figure z=data.menuitems; for i=1:length(z) data.cMenu(i) = uicontextmenu('Parent',figure_handle); addMenuChilds(z(i),data.cMenu(i),Properties) end % Store all data (this structure is attached to the uipanel-handle setMyData(data,datahandle); function addMenuChilds(z,h,Properties) % This function builds the sub-menus of the menubar % (adding sub-sub-menus recursively) if(isfield(z,'Children')&&~isempty(z.Children)) for i=1:length(z.Children) z2=z.Children(i); hchild=uimenu(h, 'Label', z2.Label); for j=1:length(Properties) Pr=Properties{j}; if(isfield(z2,Pr)) val=z2.(Pr); if(~isempty(val)), set(hchild ,Pr,val); end end end addMenuChilds(z2,hchild,Properties) end end function [barimage,barimagehover,barimageselect]=getbarimage(w,data) % This function builds the whole menu-buttons from the few pixel-lines stored % in loadbarimages barimage=zeros(size(data.IN,1),w,'uint8'); barimage(:,:,1)=repmat(data.IN(:,1),1,w); barimage(:,:,2)=repmat(data.IN(:,2),1,w); barimage(:,:,3)=repmat(data.IN(:,3),1,w); barimagehover=zeros(size(data.IN,1),w,'uint8'); barimagehover(:,:,1)=repmat(data.IH(:,4,1),1,w); barimagehover(:,:,2)=repmat(data.IH(:,4,2),1,w); barimagehover(:,:,3)=repmat(data.IH(:,4,3),1,w); barimagehover(:,1:3,1)=data.IH(:,1:3,1); barimagehover(:,1:3,2)=data.IH(:,1:3,2); barimagehover(:,1:3,3)=data.IH(:,1:3,3); barimagehover(:,end-2:end,1)=data.IH(:,5:7,1); barimagehover(:,end-2:end,2)=data.IH(:,5:7,2); barimagehover(:,end-2:end,3)=data.IH(:,5:7,3); barimageselect=zeros(size(data.IN,1),w,'uint8'); barimageselect(:,:,1)=repmat(data.IS(:,4,1),1,w); barimageselect(:,:,2)=repmat(data.IS(:,4,2),1,w); barimageselect(:,:,3)=repmat(data.IS(:,4,3),1,w); barimageselect(:,1:3,1)=data.IS(:,1:3,1); barimageselect(:,1:3,2)=data.IS(:,1:3,2); barimageselect(:,1:3,3)=data.IS(:,1:3,3); barimageselect(:,end-2:end,1)=data.IS(:,5:7,1); barimageselect(:,end-2:end,2)=data.IS(:,5:7,2); barimageselect(:,end-2:end,3)=data.IS(:,5:7,3); function menubar_ButtonDownFcn(hObject, eventdata,datahandle) data=getMyData(datahandle); if(isempty(data)), return; end % Get the handle of the axes, (which is a parant of the clicked image or text). hp=hObject; switch get(hp,'Type'); case 'text', hp=get(hObject,'Parent'); case 'image', hp=get(hObject,'Parent'); end % Detect the number of the clicked button sel=find([data.menuitems.Handle]==hp); % If another button was selected, reset the image to normal if(~isempty(data.sel)) I=data.menuitems(data.sel).barimage; set(data.menuitems(data.sel).HandleImshow,'CData',I); end % Set the selected-button image to selected, and display menu if present data.sel=sel; setSelect(data); % If this main menu-item has a callback executes it. dm=data.menuitems(data.sel); if(isfield(dm,'Callback')&&(~isempty(dm.Callback))) if(isa(dm.Callback,'function_handle')) feval(dm.Callback); else eval(dm.Callback); end end % Store the Data setMyData(data,datahandle); function setSelect(data) % Set the selected-button image to selected, and display menu if present cMenu=data.cMenu(data.sel); I=data.menuitems(data.sel).barimageselect; set(data.menuitems(data.sel).HandleImshow,'CData',I); set(cMenu,'Visible','off'); u=get(data.menuitems(data.sel).Handle,'Units'); set(data.menuitems(data.sel).Handle,'Units','pixels'); pos=get(data.menuitems(data.sel).Handle,'Position'); set(data.menuitems(data.sel).Handle,'Units',u); set(cMenu,'Position',[pos(1) pos(2)]) set(cMenu,'Visible','on'); drawnow function menubar_DummyFcn(hObject, eventdata) function menubar_MotionFcn(figurehandle) figuredata=getMyData(figurehandle); if(isempty(figuredata)), return; end arrayfun(@(x)ProcessMotion(x),figuredata.uipanels) function menubar_ResizeFcn(figurehandle) figuredata=getMyData(figurehandle); if(isempty(figuredata)), return; end arrayfun(@(x)ProcessResize(x),figuredata.uipanels) function menubar_Timer(hObject, eventdata,figurehandle) % This function acts like a MotionFcn, (Used to animated hover effect % on menu buttons) if(ishandle(figurehandle)) figuredata=getMyData(figurehandle); if(isempty(figuredata)), return; end arrayfun(@(x)ProcessResize(x),figuredata.uipanels) arrayfun(@(x)ProcessMotion(x),figuredata.uipanels) else stop(hObject); delete(hObject); end function ProcessResize(datahandle) % This function is responsible for the hover-effect of the menu-buttons. data=getMyData(datahandle); if(isempty(data)), return; end % Get Position of Panel in Pixels U=get(datahandle,'Units'); set(datahandle,'Units','Pixels'); Pos=get(datahandle,'Position'); set(datahandle,'Units',U); % Replace the menu-bar by a new one, if window resized. if(any(abs(Pos-data.Pos)>1e-3)) UpdateMenu(datahandle,data.figure_handle) end function UpdateMenu(datahandle,figure_handle) % Get Position of Panel in Pixels U=get(datahandle,'Units'); set(datahandle,'Units','Pixels'); Pos=get(datahandle,'Position'); set(datahandle,'Units',U); % Remove old existing menubars of the panel removeOldMenuBar(datahandle); uimenuhandle=get(datahandle,'UIContextMenu'); % Create a real-menubar from the panel UICContextMenu if(~isempty( get(uimenuhandle,'Children'))) CreatMenuBar(uimenuhandle,datahandle,Pos,figure_handle) end drawnow('expose'); function ProcessMotion(datahandle) % This function is responsible for the hover-effect of the menu-buttons. data=getMyData(datahandle); if(isempty(data)), return; end hover=false; for i=1:length(data.menuitems), if(~ishandle(data.menuitems(i).Handle)), return; end % Detect mouseposition relative to axis coordinates p = get(data.menuitems(i).Handle, 'CurrentPoint'); y= p(1,2); x= p(1,1); % The position must be inside the axis it self if(y<0||y>25||x<0), break; end if(x>0&&x<size( data.menuitems(i).barimage,2)) % The Mouse is hovering over a menu-button hover=true; if(~isempty(data.hov)&&(data.hov~=i)) % If another button is already in hover-modes, set % that button to normal-look I=data.menuitems( data.hov).barimage; set(data.menuitems( data.hov).HandleImshow,'CData',I); end data.hov=i; if(isempty(data.sel)) % Set current button to hover look I=data.menuitems( data.hov).barimagehover; set(data.menuitems( data.hov).HandleImshow,'CData',I); else % If another button is selected, set that button % to normal look if(data.hov~=data.sel) I=data.menuitems( data.hov).barimagehover; set(data.menuitems( data.hov).HandleImshow,'CData',I); end end % If another button was already selected, disable the menu % beneath the button, enable the menu of the hover-button, % and set it to selected modus. if(~isempty(data.sel)&&(data.sel~=data.hov)) cMenu=data.cMenu(data.sel); set(cMenu,'Visible','off'); data.sel=data.hov; setSelect(data) end drawnow('expose'); break; end end if(hover) setMyData(data,datahandle); else % If the mouse isn't above a button reset any past hover-button to % normal if(~isempty(data.hov)) I=data.menuitems( data.hov).barimage; set(data.menuitems( data.hov).HandleImshow,'CData',I); data.hov=[]; setMyData(data,datahandle); drawnow('expose'); end end % If there is an menubar in selected modus, but his sub-menu already % disappeared, because the user clicked elsewhere in the figure % reset also the button in the menubar. if(~isempty(data.sel)) cMenu=data.cMenu(data.sel); p=get(cMenu,'Visible'); if(strcmpi(p,'off')) I=data.menuitems(data.sel).barimage; set(data.menuitems(data.sel).HandleImshow,'CData',I); data.sel=[]; setMyData(data,datahandle); drawnow('expose'); end end function [IN,IS,IH]=loadbarimages() IN(:,:,1) = [254 252 249 246 242 239 235 232 229 211 211 211 212 212 213 214 215 217 218 219 220 222 223 224 225; 254 253 250 248 245 242 239 236 234 218 218 218 219 219 220 221 222 223 224 225 226 227 228 229 230; 255 254 253 252 250 249 248 246 245 237 237 237 237 238 238 239 240 240 241 242 243 243 244 245 245]'; IS(:,:,1) = [254 252 175 106 84 83 82 81 80 74 74 74 74 74 74 75 75 76 76 76 77 77 96 157 225; 254 179 92 145 202 200 206 207 205 193 196 196 200 197 198 199 200 202 202 204 204 207 213 109 156; 254 111 146 187 206 203 206 207 205 193 196 196 200 197 198 199 200 202 202 204 204 207 213 196 96; 254 88 161 185 202 200 205 207 205 193 196 196 200 196 197 199 202 203 206 209 210 212 213 212 79; 254 111 146 169 186 183 191 194 191 181 184 184 188 184 185 187 189 191 193 195 196 198 200 181 96; 254 179 102 147 163 161 166 168 166 158 160 160 163 161 162 162 165 166 167 170 171 172 162 100 156; 254 252 175 106 84 83 82 81 80 74 74 74 74 74 74 75 75 76 76 76 77 77 96 157 225]'; IS(:,:,2) = [254 253 175 107 86 84 83 82 82 76 76 76 76 76 77 77 77 78 78 79 79 79 98 161 230; 254 180 92 146 205 202 209 211 209 199 203 203 206 204 204 205 206 207 207 209 210 212 217 111 160; 254 111 147 189 208 206 210 211 209 199 203 203 206 204 204 205 206 207 207 209 210 212 217 200 98; 254 88 161 186 205 202 208 211 209 199 203 203 206 203 204 205 208 209 212 214 215 216 218 217 80; 254 111 147 171 188 186 195 197 195 187 190 190 194 190 191 193 195 196 198 200 201 202 204 185 98; 254 180 102 148 164 163 168 170 169 162 165 165 167 166 166 167 169 170 171 174 175 175 165 102 160; 254 253 175 107 86 84 83 82 82 76 76 76 76 76 77 77 77 78 78 79 79 79 98 161 230]'; IS(:,:,3) = [255 254 178 109 87 87 87 86 86 83 83 83 83 83 83 83 84 84 84 84 85 85 105 172 245; 255 180 93 148 209 208 217 220 219 217 220 220 223 221 221 222 223 223 223 225 226 227 233 119 170; 255 112 148 192 213 212 218 220 219 217 220 220 223 221 221 222 223 223 223 225 226 227 233 214 105; 255 89 163 189 209 208 216 220 219 217 220 220 223 220 220 222 225 225 228 231 232 232 233 232 86; 255 112 148 173 191 191 202 205 204 202 206 206 209 206 206 208 210 210 212 215 216 216 218 197 105; 255 180 103 150 167 167 174 176 176 174 177 177 179 178 178 179 181 181 183 185 186 186 175 109 170; 255 254 178 109 87 87 87 86 86 83 83 83 83 83 83 83 84 84 84 84 85 85 105 172 245]'; IH(:,:,1) = [254 252 215 181 169 167 164 162 160 147 147 147 148 148 149 149 150 151 152 153 154 155 164 193 225; 254 218 192 242 251 250 248 246 244 235 234 234 233 210 211 214 218 219 223 229 229 233 226 176 193; 254 187 242 252 244 242 237 231 229 214 211 211 209 193 194 197 201 203 208 213 214 219 233 228 165; 254 176 252 248 244 242 237 231 229 214 211 211 209 193 194 197 201 203 208 213 214 219 223 238 157; 254 187 242 252 244 242 237 231 229 214 211 211 209 193 194 197 201 203 208 213 214 219 233 228 165; 254 218 192 242 251 250 248 246 244 235 234 234 233 210 211 214 218 219 223 229 229 233 226 176 193; 254 252 215 181 169 167 164 162 160 147 147 147 148 148 149 149 150 151 152 153 154 155 164 193 225]'; IH(:,:,2) = [254 253 216 183 171 169 167 165 163 152 152 152 153 153 154 154 155 156 156 157 158 158 168 198 230; 254 219 193 243 252 251 249 247 246 238 237 237 237 214 214 217 222 222 226 232 232 235 229 179 198; 254 188 242 253 245 244 239 234 233 219 216 216 215 199 200 203 207 208 213 219 220 224 236 231 169; 254 177 253 249 245 244 239 234 233 219 216 216 215 199 200 203 207 208 213 219 220 224 227 241 161; 254 188 242 253 245 244 239 234 233 219 216 216 215 199 200 203 207 208 213 219 220 224 236 231 169; 254 219 193 243 252 251 249 247 246 238 237 237 237 214 214 217 222 222 226 232 232 235 229 179 198; 254 253 216 183 171 169 167 165 163 152 152 152 153 153 154 154 155 156 156 157 158 158 168 198 230]'; IH(:,:,3) = [255 254 218 186 175 174 173 172 171 165 165 165 165 166 166 167 168 168 168 169 170 170 180 211 245; 255 220 195 244 253 253 252 251 251 247 246 246 246 222 222 226 230 230 234 240 240 243 237 189 210; 255 188 243 254 248 248 245 241 240 233 231 231 229 215 215 218 222 222 228 234 234 238 246 240 180; 255 177 253 251 248 248 245 241 240 233 231 231 229 215 215 218 222 222 228 234 234 238 242 249 171; 255 188 243 254 248 248 245 241 240 233 231 231 229 215 215 218 222 222 228 234 234 238 246 240 180; 255 220 195 244 253 253 252 251 251 247 246 246 246 222 222 226 230 230 234 240 240 243 237 189 210; 255 254 218 186 175 174 173 172 171 165 165 165 165 166 166 167 168 168 168 169 170 170 180 211 245]'; IN=uint8(IN); IH=uint8(IH); IS=uint8(IS); function w=removeOldMenuBar(datahandle) % This function detects if the uipanel is replaced in the past by % a menubar, and removes the menubar in the figure, and the stored-data. data=getMyData(datahandle); if(isempty(data)),return; end for i=1:length(data.menuitems) if(ishandle(data.menuitems(i).Handle)) delete(data.menuitems(i).Handle); end if(ishandle(data.cMenu(i))) delete(data.cMenu(i)); end end remMyData(datahandle); w=true; function remMyData(datahandle) % Get data struct stored in figure rmappdata(datahandle,'menubar'); function setMyData(data,datahandle) % Store data struct in figure setappdata(datahandle,'menubar',data); function data=getMyData(datahandle) % Get data struct stored in figure data=getappdata(datahandle,'menubar');
github
jacksky64/imageProcessing-master
bitmapplot.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/bitmapplot.m
9,087
utf_8
375759d6ed5becf085537d9f29bcb6c2
function I=bitmapplot(x,y,Ibackground,options) % BITMAPPLOT, Linear plot in bitmap. % % Iplot=bitmapplot(x,y,Ibackground,options) % % inputs, % x : a vector with x values % y : a vector with y values, with same length as x % Ibackground: the bitmap used as background when a m x n x 3 matrix % color plots are made, when m x n a greyscale plot. % options: struct with options such as color % % outputs, % Iplot: The bitmap containing the plotted lines % % note, % Colors are always [r(ed) g(reen) b(lue) a(pha)], with range 0..1. % when Ibackground is grayscale, the mean of r,g,b is used as grey value. % % options, % options.Color: The color of the line. % options.FillColor: If this color is set, the region between % the x and y coordnates will be filled with this color. % options.LineWidth: Thickness of the line in pixels 1,2,3..n % options.Marker: The marker type: 'o', '+' or '*'. % options.MarkerColor: The color of the markers used. % options.MarkerSize: The size of the markers used % % example, % % Make empty bitmap % I = zeros([320 256 3]); % % % Add a line % x=rand(1,10)*50+50; y=linspace(1,512,10); % I=bitmapplot(x,y,I); % % % Add a thick red line % x=rand(1,10)*50+100; y=linspace(1,256,10); % I=bitmapplot(x,y,I,struct('LineWidth',5,'Color',[1 0 0 1])); % % % Add a line with markers % x=rand(1,10)*50+150; y=linspace(1,256,10); % I=bitmapplot(x,y,I,struct('Marker','*','MarkerColor',[1 0 1 1],'Color',[1 1 0 1])); % % % Add a filled polygon % x=[1 100 30 100]+200; y=[30 1 250 200]; % I=bitmapplot(x,y,I,struct('FillColor',[0 1 0 0.5],'Color',[1 1 0 1])); % % % Add a filled polygon on top % x=[30 80 70 120]+200; y=[30 1 250 200]; % I=bitmapplot(x,y,I,struct('FillColor',[1 0 0 0.5],'Color',[1 0 0 1])); % % lines={'Plot Test,','BitmapPlot version 1.2'}; % % Plot text into background image % I=bitmaptext(lines,I,[1 1],struct('Color',[1 1 1 1])); % % % Show the bitmap % figure, imshow(I); % % Function is written by D.Kroon University of Twente (April 2009) % Process inputs defaultoptions=struct('Color',[0 0 1 1],'FillColor',[],'LineWidth',1,'Grid',[],'MarkerColor',[1 0 0 1],'Marker',[],'MarkerSize',6); if(~exist('options','var')), options=defaultoptions; else tags = fieldnames(defaultoptions); for i=1:length(tags) if(~isfield(options,tags{i})), options.(tags{i})=defaultoptions.(tags{i}); end end if(length(tags)~=length(fieldnames(options))), warning('register_images:unknownoption','unknown options found'); end end % The function works with double values (store class for ouput) Classb=class(Ibackground); Ibackground=im2double(Ibackground); % Detect if RGB mode isRGB=size(Ibackground,3)==3; % x and y to row vectors x=round(x(:))'; y=round(y(:))'; % Make line, marker an fill bitmap I_line=zeros([size(Ibackground,1) size(Ibackground,2)]); I_marker=zeros([size(Ibackground,1)*size(Ibackground,2) 4]); I_fill = zeros([size(Ibackground,1)+2 size(Ibackground,2)+2]); % Close the line if, fill color is set if(~isempty(options.FillColor)), x=[x x(1)]; y=[y y(1)]; end % Get all Pixels of the line pline = arrayfun(@(i)(LinePixels(x,y,i)), 1:(length(x)-1), 'UniformOutput', false); pline=[pline{:}]; if(~isempty(pline)) xline=pline(1,:); yline=pline(2,:); else xline=x; yline=y; end % Make closed line structure for fill if FillColor specified. if(~isempty(options.FillColor)) xline_fill=xline; yline_fill=yline; % Limit to boundaries xline_fill(xline_fill<1)=1; yline_fill(yline_fill<1)=1; xline_fill(xline_fill>size(I_line,1))=size(I_line,1); yline_fill(yline_fill>size(I_line,2))=size(I_line,2); % I_fill is one pixel larger than I_line to allow background fill xline_fill=xline_fill+1; yline_fill=yline_fill+1; % Insert all pixels in the fill image I_fill(round(xline_fill)+(round(yline_fill)-1)*size(I_fill,1))=1; % Fill the line image I_fill I_fill=bwfill(I_fill,1,1); I_fill=1-I_fill(2:end-1,2:end-1); % Adjust the fill with alpha value I_fill=I_fill*options.FillColor(4); end if(options.LineWidth==1) % Remove pixels outside image xline1=xline; yline1=yline; check=(xline1<1)|(yline1<1)|(xline1>size(I_line,1))|(yline1>size(I_line,2)); xline1(check)=[]; yline1(check)=[]; % Insert all pixels in the line image I_line(round(xline1)+round(yline1-1)*size(I_line,1))=1; elseif(options.LineWidth>1) % Add more pixel is line-width is larger than 1... % Calculate normal on line ang=[yline(end)-yline(1) xline(end)-xline(1)]; ang=ang./(0.00001+sqrt(sum(ang.^2))); for j=-((options.LineWidth-1)/2):((options.LineWidth-1)/2); % Make lines close to the other lines xline1=xline+(ang(1)*j); yline1=yline-(ang(2)*j); % Remove pixels outside image check=(xline1<1)|(yline1<1)|(xline1>size(I_line,1))|(yline1>size(I_line,2)); xline1(check)=[]; yline1(check)=[]; % Insert all pixels in the line image I_line(ceil(xline1)+floor(yline1-1)*size(I_line,1))=1; I_line(floor(xline1)+floor(yline1-1)*size(I_line,1))=1; I_line(ceil(xline1)+ceil(yline1-1)*size(I_line,1))=1; I_line(floor(xline1)+ceil(yline1-1)*size(I_line,1))=1; end end % Adjust the lines with alpha value I_line=I_line*options.Color(4); % Make marker image if(~isempty(options.Marker)) % Make marker pixels (center 0,0) switch(options.Marker) case '+' markerx=[-(options.MarkerSize/2):(options.MarkerSize/2) zeros(1,options.MarkerSize+1)]; markery=[zeros(1,options.MarkerSize+1) -(options.MarkerSize/2):(options.MarkerSize/2)]; case '*' markerx=[-(options.MarkerSize/2):(options.MarkerSize/2) zeros(1,options.MarkerSize+1)]; markery=[zeros(1,options.MarkerSize+1) -(options.MarkerSize/2):(options.MarkerSize/2)]; markerx=[markerx -(options.MarkerSize/2):(options.MarkerSize/2) -(options.MarkerSize/2):(options.MarkerSize/2)]; markery=[markery -(options.MarkerSize/2):(options.MarkerSize/2) (options.MarkerSize/2):-1:-(options.MarkerSize/2)]; case 'o' step=360/(2*pi*options.MarkerSize); markerx=options.MarkerSize/2*sind(0:step:90); markery=options.MarkerSize/2*cosd(0:step:90); markerx=[markerx -markerx markerx -markerx]; markery=[markery markery -markery -markery]; end % Add all line markers to the marker image isColorTable=size(options.MarkerColor,1)==length(x); for i=1:length(x); % Move marker to line coordinate xp=round(markerx)+round(x(i)); yp=round(markery)+round(y(i)); % Remove outside marker pixels check=(xp<1)|(yp<1)|(xp>size(I_line,1))|(yp>size(I_line,2)); xp(check)=[]; yp(check)=[]; ind=xp+(yp-1)*size(I_line,1); if(isColorTable), k=i; else k=1; end I_marker(ind,1)=options.MarkerColor(k,1); I_marker(ind,2)=options.MarkerColor(k,2); I_marker(ind,3)=options.MarkerColor(k,3); I_marker(ind,4)=options.MarkerColor(k,4); end I_marker=reshape(I_marker,[size(Ibackground,1) size(Ibackground,2) 4]); end % Add lines, markers and fill in the right colors in the image I=Ibackground; if(isRGB) % Color image for i=1:3 if(~isempty(options.FillColor)), I(:,:,i)=I(:,:,i).*(1-I_fill)+options.FillColor(i)*(I_fill); end I(:,:,i)=I(:,:,i).*(1-I_line)+options.Color(i)*(I_line); if(~isempty(options.Marker)), I(:,:,i)=I(:,:,i).*(1-I_marker(:,:,4))+I_marker(:,:,4).*I_marker(:,:,i); end end else % Grey scale if(~isempty(options.FillColor)), I=I.*(1-I_fill)+mean(options.FillColor(1:3))*(I_fill); end I=I.*(1-I_line)+mean(options.Color(1:3))*(I_line); if(~isempty(options.Marker)), I=I.*(1-I_marker(:,:,4))+mean(I_marker(:,:,1:3),3).*(I_marker(:,:,4)); end end % Set to range 0..1 I(I>1)=1; I(I<0)=0; % Back to class background switch (Classb) case 'single', I=im2single(I); case 'int16', I=im2int16(I); case 'uint8', I=im2uint8(I); case 'uint16', I=im2uint16(I); end function pline=LinePixels(x,y,i) % Calculate the pixels needed to construct a line of 1 pixel thickness % between two coordinates. xp=[x(i) x(i+1)]; yp=[y(i) y(i+1)]; dx=abs(xp(2)-xp(1)); dy=abs(yp(2)-yp(1)); if(dx==dy) if(xp(2)>xp(1)), xline=xp(1):xp(2); else xline=xp(1):-1:xp(2); end if(yp(2)>yp(1)), yline=yp(1):yp(2); else yline=yp(1):-1:yp(2); end elseif(dx>dy) if(xp(2)>xp(1)), xline=xp(1):xp(2); else xline=xp(1):-1:xp(2); end yline=linspace(yp(1),yp(2),length(xline)); else if(yp(2)>yp(1)), yline=yp(1):yp(2); else yline=yp(1):-1:yp(2); end xline=linspace(xp(1),xp(2),length(yline)); end pline(1,:)=xline; pline(2,:)=yline;
github
jacksky64/imageProcessing-master
viewer3d_segment.m
.m
imageProcessing-master/Matlab Viewer3D/SubFunctions/viewer3d_segment.m
10,723
utf_8
7b38f76dbd5d9b62bc3cdb6a3b682bc5
function varargout = viewer3d_segment(varargin) % VIEWER3D_SEGMENT MATLAB code for viewer3d_segment.fig % VIEWER3D_SEGMENT, by itself, creates a new VIEWER3D_SEGMENT or raises the existing % singleton*. % % H = VIEWER3D_SEGMENT returns the handle to a new VIEWER3D_SEGMENT or the handle to % the existing singleton*. % % VIEWER3D_SEGMENT('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in VIEWER3D_SEGMENT.M with the given input arguments. % % VIEWER3D_SEGMENT('Property','Value',...) creates a new VIEWER3D_SEGMENT or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before viewer3d_segment_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to viewer3d_segment_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help viewer3d_segment % Last Modified by GUIDE v2.5 25-Jan-2011 16:41:31 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @viewer3d_segment_OpeningFcn, ... 'gui_OutputFcn', @viewer3d_segment_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before viewer3d_segment is made visible. function viewer3d_segment_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to viewer3d_segment (see VARARGIN) % Choose default command line output for viewer3d_segment handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes viewer3d_segment wait for user response (see UIRESUME) % uiwait(handles.figure1); data=getMyData(); if(isempty(data)), return, end Options=struct('Verbose',false,'nPoints',100,'Wline',0.04,'Wedge',2,'Wterm',0.01,'Sigma1',1,'Sigma2',1,'Alpha',0.2,'Beta',0.2,'Delta',0.1,'Gamma',1,'Kappa',2,'Iterations',100,'GIterations',0,'Mu',0.2,'Sigma3',1); % Initalize Snake Parameters n=structfind(data.substorage,'name','viewer3d_segment'); if(isempty(n)) n=length(data.substorage)+1; data.substorage(n).name='viewer3d_segment'; data.substorage(n).data.Options=Options; end setMyData(data); fn=fields(data.substorage(n).data.Options); set(handles.listbox2,'String',fn); listbox2_Callback(hObject, eventdata, handles); % --- Outputs from this function are returned to the command line. function varargout = viewer3d_segment_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end % ID's to volume struct location dvs=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); id=data.subwindow(data.axes_select).volume_id_select; editable=false(1,length(id)); dv2=zeros(1,length(id)); for i=1:length(id) dv2(i)=structfind(data.volumes,'id',id(i)); editable(i)=data.volumes(dv2(i)).Editable; end [editable,i]=sort(editable); dv2=dv2(i); dvs2=dv2(1); n=structfind(data.volumes(dvs).MeasureList,'type','s'); if(isempty(n)), return; end n=n(end); vm=data.volumes(dvs).MeasureList(n); SliceSelected=data.subwindow(data.axes_select).SliceSelected(uint8(data.subwindow(data.axes_select).render_type(6))-119); switch(vm.RenderSelected) case {'x'} I=data.volumes(dvs2).volume_original(SliceSelected,:,:); y=vm.z; x=vm.y; case {'y'} I=data.volumes(dvs2).volume_original(:,SliceSelected,:); y=vm.z; x=vm.x; case {'z'} I=data.volumes(dvs2).volume_original(:,:,SliceSelected); y=vm.y; x=vm.x; end I=double(I); I=I-min(I(:)); I=I./max(I(:)); % Make an array with the clicked coordinates P=[x(:) y(:)]; % Start Snake Process n=structfind(data.substorage,'name','viewer3d_segment'); Options=data.substorage(n).data.Options; O=Snake2D(I,P,Options); figure(data.handles.figure1); x=O(:,1); y=O(:,2); [x,y]=interpcontour(x,y,zeros(size(x)),2); switch(vm.RenderSelected) case {'x'} vm.z=y; vm.y=x; case {'y'} vm.z=y; vm.x=x; case {'z'} vm.y=y; vm.x=x; end data.volumes(dvs).MeasureList(n)=vm; setMyData(data); viewer3d('show3d_Callback',gcf,[false false],guidata(gcf)); % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end % ID's to volume struct location dvs=structfind(data.volumes,'id',data.subwindow(data.axes_select).volume_id_select(1)); id=data.subwindow(data.axes_select).volume_id_select; editable=false(1,length(id)); dv2=zeros(1,length(id)); for i=1:length(id) dv2(i)=structfind(data.volumes,'id',id(i)); editable(i)=data.volumes(dv2(i)).Editable; end [editable,i]=sort(editable); dv2=dv2(i); dvs2=dv2(end); n=structfind(data.volumes(dvs).MeasureList,'type','s'); if(isempty(n)), return; end n=n(end); x=data.volumes(dvs).MeasureList(n).x; y=data.volumes(dvs).MeasureList(n).y; z=data.volumes(dvs).MeasureList(n).z; S=data.subwindow(data.axes_select).SliceSelected; switch (data.volumes(dvs).MeasureList(n).RenderSelected) case {'x'} J=squeeze(data.volumes(dvs2).volume_original(S(1),:,:,:)); J=bitmapplot(y,z,J,struct('FillColor',[1 1 1 1],'Color',[1 1 1 1]))>0; data.volumes(dvs2).volume_original(S(1),:,:,:)=J; case {'y'} J=squeeze(data.volumes(dvs2).volume_original(:,S(2),:,:)); J=bitmapplot(x,z,J,struct('FillColor',[1 1 1 1],'Color',[1 1 1 1]))>0; data.volumes(dvs2).volume_original(:,S(2),:,:)=J; case {'z'} J=squeeze(data.volumes(dvs2).volume_original(:,:,S(3),:)); J=bitmapplot(x,y,J,struct('FillColor',[1 1 1 1],'Color',[1 1 1 1]))>0; data.volumes(dvs2).volume_original(:,:,S(3),:)=J; end setMyData(data); viewer3d('UpdatedVolume_Callback',gcf,dvs2,guidata(gcf)); % --- Executes on selection change in listbox2. function listbox2_Callback(hObject, eventdata, handles) % hObject handle to listbox2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns listbox2 contents as cell array % contents{get(hObject,'Value')} returns selected item from listbox2 data=getMyData(); if(isempty(data)), return, end n=structfind(data.substorage,'name','viewer3d_segment'); fn=fields(data.substorage(n).data.Options); sel=get(handles.listbox2,'Value'); val=data.substorage(n).data.Options.(fn{sel}); set(handles.edit1,'String',num2str(val)); % --- Executes during object creation, after setting all properties. function listbox2_CreateFcn(hObject, eventdata, handles) % hObject handle to listbox2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function edit1_Callback(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit1 as text % str2double(get(hObject,'String')) returns contents of edit1 as a double data=getMyData(); if(isempty(data)), return, end n=structfind(data.substorage,'name','viewer3d_segment'); fn=fields(data.substorage(n).data.Options); sel=get(handles.listbox2,'Value'); data.substorage(n).data.Options.(fn{sel})=str2double(get(handles.edit1,'String')); setMyData(data); % --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % --- Executes on key press with focus on edit1 and none of its controls. function edit1_KeyPressFcn(hObject, eventdata, handles) % hObject handle to edit1 (see GCBO) % eventdata structure with the following fields (see UICONTROL) % Key: name of the key that was pressed, in lower case % Character: character interpretation of the key(s) that was pressed % Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) data=getMyData(); if(isempty(data)), return, end data.mouse.button='select_roi'; data.mouse.action='segment_roi'; setMyData(data);