Displaying surf actual size?
5 views (last 30 days)
Show older comments
Hi, is there a way to display surf in its actual size? Been looking in the web but couldnt find anything which worked. I'm also quite new to matlab.
Here is my code:
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)
I'm loading a bunch of images and taking slices at a specific points and stitching them together. The output doesnt display the actual size.
0 Comments
Answers (1)
Image Analyst
on 18 Jan 2015
I don't know what actual size means for surf(). It's a 2.5D perspective rendering of a 2D image/matrix. To get such a rendering you have to have the viewpoint off angle (not normal incidence). You could have actual size if you were looking straight down , perpendicularly to the surface, but then that is just what you would see if you were using imshow(). I attach a demo (adapted from code the Mathworks image processing team sent me) to demonstrate how to display an image as "actual" size (image pixel-for-screen pixel) using a "scrollpanel".
0 Comments
See Also
Categories
Find more on Interactions, Camera Views, and Lighting in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!