📄 prex5.m
字号:
%PREX5 PRTOOLS example of image vector quantizationhelp prex5echo on % standard Matlab TIFF readgirl = imread('girl.tif','tiff'); % displayfiguresubplot(2,3,1);subimage(girl); axis off;title('Girl 1'); drawnow % construct 3-feature dataset from entire imageg1 = im2feat(girl); % generate testsett = gendat(g1,250); % run modeseek, find labels, and construct labeled datasetlabt = modeseek(t*proxm(t),25);t= dataset(t,labt); % train NMC classifierw = t*qdc([],1e-6,1e-6); % classify all pixelspacklab = g1*w*classim; % show result % substitute class means for colorscmap = +meancov(t(:,1:3));subplot(2,3,2);subimage(lab,cmap);axis off;title('Girl 1 --> Map 1')drawnow % Now, read second imagegirl2 = imread('girl2.tif','tiff'); % displaysubplot(2,3,4);subimage(girl2); axis off;title('Girl 2'); drawnow % construct 3-feature dataset from entire imageg2 = im2feat(girl2);clear girl girl2packlab2 = g2*w*classim; % show result % substitute class means for colorscmap = +meancov(t(:,1:3));subplot(2,3,5); subimage(lab2,cmap);axis off;title('Girl 2 --> Map 1')drawnow % Compute combined mapg = [g1; g2];t = gendat(g,250);labt = modeseek(t*proxm(t),25);t= dataset(t,labt);w = t*qdc([],1e-6,1e-6);cmap = +meancov(t(:,1:3));clear gpacklab = g1*w*classim;subplot(2,3,3); subimage(lab,cmap);axis off;title('Girl 1 --> Map 1,2')drawnowpacklab = g2*w*classim;subplot(2,3,6); subimage(lab,cmap);axis off;title('Girl 2 --> Map 1,2')drawnowset(gcf,'DefaultAxesVisible','remove')echo off
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -