📄 isimcapr.m
字号:
function newmod = isimcapr(data,model);%ISIMCAPR Applies IMGSIMCA models to new images% This function uses models developed with the IMGSIMCA function% to classify areas on a new multivariate image (data). Note that the% new image can be of different size (i.e. it can have a different% number of pixels than the original multivariate image used to% construct the IMGSIMCA model (model)), but it must have the same% depth. The output is a structure array (newmod) which contains% the new classifications. The fields of the structure are:%% mwaname: name of original multivariate image data% modelname: name of the original SIMCA model from IMGSIMCA% name: model type, always ISIMCAPR% date: date stamp% time: time stamp% size: size of the image data% in_class: array which gives pixels within 95% Q limits for each class% closest_class: array which gives closest class for each pixel% rqmat: reduced Q values for all classes for all pixels% rtsqmat: reduced T^2 values for all classes for all pixels%%I/O: newmod = isimcapr(data,model);%%See also: IMGPCA, IMGSIMCA, IMGSELCT%Copyright Eigenvector Research, Inc. 1999-2000%bmw April 27, 1999%nbg 11/00 changed helpdatadim = size(data);data = reshape(data,datadim(1)*datadim(2),datadim(3));[nclass,rtsq,rq] = simcaprd(double(data),model.simcamod,0);[mr,nr] = size(rtsq);classclose = ones(datadim(1),datadim(2),nr)*255;classin = ones(datadim(1),datadim(2),nr+1)*255;rqmat = zeros(datadim(1),datadim(2),nr);rtsqmat = rqmat;for i = 1:nr rqmat(:,:,i) = reshape(rq(:,i),datadim(1),datadim(2)); rtsqmat(:,:,i) = reshape(rtsq(:,i),datadim(1),datadim(2));endk = 0;for i = 1:datadim(2); for j = 1:datadim(1); k = k+1; classclose(j,i,nclass(k)) = 0; if ~isempty(find(rq(k,:)<=1)) classin(j,i,find(rq(k,:)<=1)) = zeros(size(find(rq(k,:)<=1))); end if min(rq(k,:))>1 classin(j,i,nr+1) = 0; end endendcolormap(hot(256));for i = 1:nr if i == 1 h1 = figure; image(classin(:,:,i)); title('Areas in Class 1 Shown in Black') colormap(hot(256)); h2 = figure; image(classclose(:,:,i)); title('Areas Closest to Class 1 Shown in Black') colormap(hot(256)) h3 = figure; imagesc(sqrt(rqmat(:,:,i))); title('Q values on Class 1 for Entire Image, 95% Limit = 1') else figure(h1); image(classin(:,:,i)); title(sprintf('Areas in Class %g Shown in Black',i)); figure(h2); image(classclose(:,:,i)); title(sprintf('Areas Closest to Class %g Shown in Black',i)); figure(h3); imagesc(sqrt(rqmat(:,:,i))); title(sprintf('Q values on Class %g for Entire Image, 95% Limit = 1',i)) end colormap(hot(256)); colorbar pauseendfigure(h1); image(classin(:,:,nr+1));title('Areas in Not in Any Class Shown in Black');% Save the model as a structured array newmod = struct('mwaname',inputname(1),'modelname',inputname(2),'name','ISIMCAPR',... 'date',date,'time',clock,'size',datadim,... 'in_class',classin,'closest_class',classclose,'rqmat',rqmat,'rtsqmat',rtsqmat);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -