MATLAB Basics (brain.jpg) 1. What is the difference between a binary, grey-scale
ID: 3763469 • Letter: M
Question
MATLAB Basics
(brain.jpg)
1. What is the difference between a binary, grey-scale and color image?
2. What is the use of the functions below?
a. imread
b. imfinfo
c. imwrite
d. imagesc
e. imshow
f. subplot (be sure to explain the M, N, and P parameters
Use the help function in Matlab.
For the following problems you will need to download the image file brain.jpg.
(Can you please type out the code for each .m file?)
3. Create a m-file named Lab5_01.m that:
a. Loads the image into Matlab.
b. Displays the information of the image into the command window.
c. Rotates the image by 90 degrees.
d. Show the image.
4. Create another Matlab file named Lab5_02.m and use the same brain image as the previous problem. Write the script to load the image and add 'salt and pepper' noise to the image (you choose the level of noise density added). Then filter the image using the "imfilter" built-in function. Use a filter mask of 11X11 to convolve the signal. Afterwards, try one other filter size of your choice and compare filter size to image clarity. Show the different noisy and filtered images.
5. Finally, create a Matlab file named Lab5_03.m and use the same brain image file as previous problems.
a. This script should load the file and plot the intensity histogram of the image as a bar graph with an appropriate title and axis labels.
b. Use the immultiply function and multiply the original image by 5. Then, plot the intensity histogram of this new image as a bar graph with an appropriate title and labels.
c. Use the immultiply function once again to multiply the original image by itself. Then, plot the intensity histogram of this new image as a bar graph with an appropriate title and labels.
Describe the differences you observe between the three different plots.
Explanation / Answer
1. binary, grey-scale and color image
Binary image : Each pixel is filled with either 0 or 255. And same value is used for Red, Green and Blue bands(i.e A pixel can be complete black or complete white
Eg : [0,0,0], [255,255,255]
Grey-scale : Each pixel is filled with any value from 0 to 255. And same value is used for Red, Green and Blue bands(i.e. A pixel can have gradient of black decreasing as the value increases to 255)
Eg : [0,0,0], [100,100,100], [255,255,255]
Color image : Each pixel is filled with any value from 0 to 255 with different values for Red, Green and Blue bands. Combination of different values of R, G and B bands results in different colors
Eg : [0,26,156], [100,190,10], [255,0,25
256 is the general bit depth of an image. But the limit can be any value.
2.
a. imread
img = imread(image_file) : reads the image from the file specified by image_file and stores the pixel data of the image in the form of 3D-array(resolution of image x 3 => X * Y * 3) in img.
b. imfinfo
info = imfinfo(image_file) : returns a structure with the information about image_file like file name, file format, file size, last modified date, bit depth of the image etc
c. imwrite
imwrite(img,image_file) : writes image data img to the file specified by image_file.
d. imagesc
imagesc(arr) : displays the data in array, arr, as an image that uses the full range of colors in the colormap. Each element of arr is considerded as data for 1 pixel of the image
e. imshow
imshow(img) : displays the image img in a Graphics window. It is generally used to check the image after any operations on image data.
f. subplot
subplot(M, N, P) divides the current image into an M-by-N array and creates an axes for a subplot in the position specified by P. MATLAB numbers its subplots by row, such that the first subplot is the first column of the first row, the second subplot is the second column of the first row, and so on. If the axes already exists, then the command subplot(M, N, P) makes the subplot in position p the current axes.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.