|
Let's start with a 100x100 matrix of zeros (black). img = zeros(100,100); Then we'll add a white (1.0) square in the upper left corner: img(1:20,1:20) = 1.0; Then we'll add a grey (0.50) rectangle: img(20:50,20:80) = 0.50; |
>>imshow(img)
|
|
Now, let's take a little clip of our image, as shown by the red square below:
clip = img(10:30,10:30);
|
>>imshow(clip)
|
|
Now, let's make a new picture, using the clip from the old picture. Let's start with a white background: newpic = ones(100,100); And add in the clip in two places:
newpic(1:21,1:21) = clip; to produce this picture:
|
>>imshow(newpic)
|
|
What do you need to do to make this picture?
|
>>imshow(newpic)
|
clip = img(10:30,10:30);
How can we create the clip's cousin, flip (shown below) in MATLAB?
hmmm, what is the relationship between clip and flip?
And how about clip's other cousin, upsidedown_clip, how can we make the picture below?
robinson.jpg in your
assign3_programs folder. Read this image into MATLAB like
this: nate = double(imread('robinson.jpg'))/255;
This reads in the JPG file (where the numbers range from 0-255) and scales it into a matrix with double precision numbers ranging from 0.0-1.0. The double refers to the precision and not to the value.
Peek in the workspace to see your (large) variable named nate.
Now let's use imtool to figure out the coordinates to get a closeup
of his face.
imtool(nate);
imtool(nate) brings up the window below (without the red dashed lines and yellow dots). As you move your cursor over the image, you can see the coordinate in the lower left corner of the Image Tool window. The coordinates of the box around Nate's face are labeled in the image below:
Now, using your matrix variable nate, take a subset of nate using the coordinates above as a guideline. Think carefully about which coordinates to use (remember that imtool reverses x and y). Save his face in a variable called face and then show his face using imshow. Note that his face closeup will appear in grayscale (as opposed to color), we'll talk about why this occurs later in the course.
Warning: Could not start Excel server for export.
XLSWRITE attempts to file in CSV format.
Even though it issues a warning, MATLAB still creates a file with your data called my_data_v2.csv. The csv stands for comma separated value format.