显示冲浪实际尺寸?
Displaying surf actual size?
有没有办法以实际大小和纵横比显示 surf
?我一直在网上寻找,但找不到任何有用的东西。我对 MATLAB 也很陌生。
这是我的代码:
rpos1 = 0; % image row vector pos counter
rpos2 = 0; % existing image vector pos counter
rpos3 = 0; % avg vector pos counter
prompt = {'Image location:','Lowest image #:','Highest image #:','Row of interest:','Background noise reduction:'};
dlg_title = 'Input';
num_lines = 1;
def = {'C:\Users\Moz\Desktop\Hyperspecdata\images','300','390','700','100'};
answer = inputdlg(prompt,dlg_title,num_lines,def);
directory = (answer{1});
x1 = str2num(answer{2});
x2 = x1;
y1 = str2num(answer{3});
y2 = y1-1;
z = str2num(answer{4});
v = str2num(answer{5});
finalslice = zeros(1,1312); % create matrix (imagecount x 1312)
%INSERT SLICES WITH 1 GAP%
for k = x1 : y1
baseFileName = sprintf('image0000000%03d.pgm',k);
fullFileName = fullfile(directory, baseFileName); %fullfile(folder, baseFileName);
A = imread(fullFileName);
A = floor(A./16); % transform back to 12 bit
B = A-v; % remove background noise
rpos1 = rpos1+1; % jump to next row
thisline = B(z,:); % desired row in images
finalslice(rpos1,:) = thisline; % add row vector
rpos1 = rpos1+1; % jump to next row
emptyline = zeros(1,1312); % create empty row vector
finalslice(rpos1,:) = emptyline; % insert empty row vector
end
%INSERT AVERAGES INTO GAPS%
for k = x2 : y2
rpos2 = rpos2+1; % find first existing vector
line1 = finalslice(rpos2,:);
rpos2 = rpos2+2; % find second existing vector
line2 = finalslice(rpos2,:);
avgline1 = (line1 + line2)/2; % average both
rpos3 = rpos3+2;
finalslice(rpos3,:) = avgline1; % insert average vector
rpos2 = rpos2-1; % jump back to second existing vector
end
figure(1)
h = surf(finalslice,'EdgeColor','none','LineStyle','none','FaceLighting','phong');
colormap('jet');
view(2)
我正在加载一堆图像并在特定点截取切片并将它们拼接在一起。输出不显示实际大小和纵横比。
已解决:
已添加daspect()
o = max(max(finalslice));
[m n] = size(finalslice);
figure(1) h = surf(finalslice,'EdgeColor','none','LineStyle','none','FaceLighting','phong'); colormap('jet');
view(2)
daspect([m n o]);
有没有办法以实际大小和纵横比显示 surf
?我一直在网上寻找,但找不到任何有用的东西。我对 MATLAB 也很陌生。
这是我的代码:
rpos1 = 0; % image row vector pos counter
rpos2 = 0; % existing image vector pos counter
rpos3 = 0; % avg vector pos counter
prompt = {'Image location:','Lowest image #:','Highest image #:','Row of interest:','Background noise reduction:'};
dlg_title = 'Input';
num_lines = 1;
def = {'C:\Users\Moz\Desktop\Hyperspecdata\images','300','390','700','100'};
answer = inputdlg(prompt,dlg_title,num_lines,def);
directory = (answer{1});
x1 = str2num(answer{2});
x2 = x1;
y1 = str2num(answer{3});
y2 = y1-1;
z = str2num(answer{4});
v = str2num(answer{5});
finalslice = zeros(1,1312); % create matrix (imagecount x 1312)
%INSERT SLICES WITH 1 GAP%
for k = x1 : y1
baseFileName = sprintf('image0000000%03d.pgm',k);
fullFileName = fullfile(directory, baseFileName); %fullfile(folder, baseFileName);
A = imread(fullFileName);
A = floor(A./16); % transform back to 12 bit
B = A-v; % remove background noise
rpos1 = rpos1+1; % jump to next row
thisline = B(z,:); % desired row in images
finalslice(rpos1,:) = thisline; % add row vector
rpos1 = rpos1+1; % jump to next row
emptyline = zeros(1,1312); % create empty row vector
finalslice(rpos1,:) = emptyline; % insert empty row vector
end
%INSERT AVERAGES INTO GAPS%
for k = x2 : y2
rpos2 = rpos2+1; % find first existing vector
line1 = finalslice(rpos2,:);
rpos2 = rpos2+2; % find second existing vector
line2 = finalslice(rpos2,:);
avgline1 = (line1 + line2)/2; % average both
rpos3 = rpos3+2;
finalslice(rpos3,:) = avgline1; % insert average vector
rpos2 = rpos2-1; % jump back to second existing vector
end
figure(1)
h = surf(finalslice,'EdgeColor','none','LineStyle','none','FaceLighting','phong');
colormap('jet');
view(2)
我正在加载一堆图像并在特定点截取切片并将它们拼接在一起。输出不显示实际大小和纵横比。
已解决:
已添加daspect()
o = max(max(finalslice));
[m n] = size(finalslice);
figure(1) h = surf(finalslice,'EdgeColor','none','LineStyle','none','FaceLighting','phong'); colormap('jet');
view(2)
daspect([m n o]);