solve the following program in matlab Ever seen these 3D posters that work when
ID: 3695683 • Letter: S
Question
solve the following program in matlab
Ever seen these 3D posters that work when you stare at them for a while? Did you ever care to know how they work or wanted to make one yourself? Here's your chance! First, the theory behind autostereograms (very non-scientific); Our brain figures out the depth of objects by comparing the two angles at which our eyes see it. We can fool this mechanism by creating a pattern that is nearly periodic in the horizontal direction, and then look at it as if it is closer or further away than it actually is. By staring or looking cross-eyed at the pattern, we make each eye focus on a different copy of the repetitive pattern. However, since the patterns is repetitive the brain assumes that it is looking at object that is located at a different depth. To create an illusion of a 3D object we deviate from the repetitive pattern in the following precise fashion: Each dot in a copy is moved horizontally with respect to the matching dot (in the repetitive pattern). The amount in which the dot is moved is proportional to the desired depth of the illusion at that place. In terms of coding you will need to figure out how to: • Find an interesting 2Dsurface from which you would like to create an autostereogram. This should be represented internally as a matrix, picture, or mathematical formula. This doesn't mean that your program should accept all of these as input, but rather that you consider the possibilities and think about converting the input into a map, (x, y) z. • Create a random pattern of dots (with about 50% fill) in a narrow vertical rectangle (should be about 1” in width). • Create a vertical strip of the autostereogram, copy the previous dot pattern and move the dots in proportion to the desired depth at that point. Remember that you need to keep copying the previous strip and not the original one. • Plot your points to create the stereogram. It is useful to plot two additional large points below your autostereogram to indicate the spacing of repetition. This will help when trying to view the autostereogram. • Try your program first on a simple input that you know more or less what the answer should look like (for example, a simple square that is lifted from the background). Then try it on other simple geometric objects, like pyramids and spheres. Have a 3D picture in mind and create it. • If your height function has a large jump, you will find that a big area with no points may be created and this will hurt the quality of the result. To avoid this you can try to locate big empty spaces at each repetition and fill them up with new random points. These extra points should then be copied and moved together with the others. • Big jumps in the height function can also cause points to “overlap” creating dense “blobs” of points. This, too can hurt the quality of the autostereogram. Removing points that have overlapped (not the points doing the overlapping) is another way to improve your autostereogram.
Explanation / Answer
% learn the basic function calls that are related to
% this type of work on AutoSteroGrams to
% achieve periodicity of the horizantal direction image size
%
% So the brain looks at the horizaontal angle and vertical angle
% if we had understood the question correctly!!
%
%
% load command - what is the syntax and example?
% what load soes - it loads what - a file , an image or what it loads? from where to where?
%
% Example:
% imageName1 = load('NameOfImage');
% imresize better written as imReSize will resize the image
% imReSize = image Re Size
% Syntax:
variable2 = imresize(imageName1.IMAGENAME1, numberOfTimesBigger);
% say we want to enlarge the image 5 times, then we can
% achieve that as follows:
%
% newImage = imReSize(oldImage.OLDIMAGE, 5);
%
% what is a membrane?
% In biology, membrane is a very thin and soft tissue
% there are semi permiable membranes that can be used for demonstrating
% how the roots of the plants send water upwards against gravity to their leaves
% if you soak the dried grapes in water they will bulge
% in contrast if you soak the mangoe in salt water it will shrink
% both of this phenomena is due to the membranes of grapes and mango
% back to the track: what is membrane in MatLab and how membrane will be useful for
% making the autoSteroGram to work?
% DataForDisplay = membrane(integer1, integer2, integer3, integr4);
% where integer1 can be = 1 to 10
% integer2 can be = 245 to 255 ( sounds like color parameter?)
% integer3= ?
% integer4= ?
% D = Dimension
% We create horizontal periodicity
% each dot moves (in repeated copy) in the horizontal direction
% let the screen map scale be 1 milli meter (mm) = 1 feet - in the display and real world view
% if you want the illusion to be 10 feet depth
% then move the dots in closely placed repeated images by 10 inches
% this is assuming that 10 milli meter ( mm) is scaled for 10 feet in the map
% hence if we want the illusion to be 5 feet, then it has to 5 mm so that we get 5 feet depth on the view
%
% The membranes in matlab can be rotated,
% vrmemb is related SimuLink animation for 3D
%
% vrml
%
% vrml is a built in matlab function
% we can get L Shaped membrane as well
%
% handle graphic objects are also related
%
%How we do it?
% once the panel of graphicsis started, the sliders can be used to change the scaled depth size from 1 mm to 5 mm to 10mm etc
% so that the image will look as 1 feet deep, 5 feet deep, or 10 feet deep respectively
% for coding part:
% finding out how to get an interesting 2 dimensional surface as a base for auto Stero Gram creation
% = an internal matrix, picture, or mathematical formula
%
% reveive user inputs
% make those inputs into a map
%
%
%
function autoSteroGram = asg(scalingFactor, sizeInImg, sizeInReal, imageFile)
scalingFactor = input('Enter the scaling factor
sizeInImg = input('Enter Size in Image');
sizeInReal = input('Enter size in Real World');
imageFile = input('Enter the file holdingthe image, if you would like to interface the web camera to take a new image, click the select button ');
% make a button that displays "Click me to activate web camera for taking a new photo"
% if this button is clicked, write the code for activating the web camera through the USB port or through internal port if it is a built in camera
% hence first find where the camera is attached - whether built in as part of the lap top monitor or
% the user had attached an external web camera through an Universal Serial Bus (USB) port
% once the 4 inputs are received, they can be mapped using Root InPort Mapping Tool
%
%
asgm = membrane(2, 245, 7, 3);
makeAbsird(asgm)
oldImage = load(imageFile);
% enlarge image 10 times
newImage = imresize(oldImage.OLDIMAGE, 10);
makeAbsird(newImage);
end % end function asg
function crpod = CreateRandomPatternOfDots(patternWidth, patternHeight, percentageOfWhiteComponent)
randomDotPattern = zeros(patte rnHeight, patternWidth);
randomDotPattern = (1:round(0.01*percentageOfWhiteComponent*numel(randomDotPattern ) ) ) , patternHeight, patternWidth);
imagesc(randomDotPattern );
% choose the color you like
colormap('blue')
% set the axis as equal proportionately numbered lable indices
axis equal;
end % crpod
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.