In MATLAB, a grey-scale image is stored a a matrix of numbers, all between 0 (black)...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In MATLAB, a grey-scale image is stored a a matrix of numbers, all between 0 (black) and 255 (white). Since there are 256 possible values, 8 bits are needed or each pixel, in contrast to a normal integer, which is 64 bits. To save memory, grey-scale images are stored with a special data type, uint8 (unsigned 8-bit integer). In computer terminology, 8 bits = 1 byte. Even at one byte per pixel, a large image can consume a lot of memory. For example, a 1000x1000-pixel image takes 1 million bytes (which is a little less than 1 megabyte, since by convention 1 Mbyte = 2^20 bytes). One technique for reducing the size of an image is quantization - reducing the number of allowable levels from 256 to something smaller. Surprisingly, most images can be quantized by a large factor without losing much information. In this problem, you will quantize a grey-scale image to only 4 levels, so that it could (in principle) be stored as 2 bits per pixel. The template will read in an image file. Your job is to loop over all rows and columns of the image matrix, N, and set each pixel to 0, 1, 2, or 3 as follows: original pixel value 0-64 65 - 128 129 - 192 193-255 Script new pixel value 0 1 Use imshow to display the original and modified images so that you can see the effect of the quantization. 2 3 1 % Load in the color image and convert it to grey-scale 2 M imread('images_L8_2.jpg'); 3 N uint8(mean (M, 3)); 4 7 8 %{ 9 YOUR CODE GOES HERE imshow(N) %look at the original image 10 %} 11 12 13 14 15 16 17 18 19 20 %THIS WILL DISPLAY THE QUANTIZED IMAGE 21 22 figure 23 Levels = uint8([32, 96, 160, 224]) %display each pixel as the mid-point of its range 24 imshow(Levels (N+1)) 25 Save C Reset MATLAB Documentation In MATLAB, a grey-scale image is stored a a matrix of numbers, all between 0 (black) and 255 (white). Since there are 256 possible values, 8 bits are needed or each pixel, in contrast to a normal integer, which is 64 bits. To save memory, grey-scale images are stored with a special data type, uint8 (unsigned 8-bit integer). In computer terminology, 8 bits = 1 byte. Even at one byte per pixel, a large image can consume a lot of memory. For example, a 1000x1000-pixel image takes 1 million bytes (which is a little less than 1 megabyte, since by convention 1 Mbyte = 2^20 bytes). One technique for reducing the size of an image is quantization - reducing the number of allowable levels from 256 to something smaller. Surprisingly, most images can be quantized by a large factor without losing much information. In this problem, you will quantize a grey-scale image to only 4 levels, so that it could (in principle) be stored as 2 bits per pixel. The template will read in an image file. Your job is to loop over all rows and columns of the image matrix, N, and set each pixel to 0, 1, 2, or 3 as follows: original pixel value 0-64 65 - 128 129 - 192 193-255 Script new pixel value 0 1 Use imshow to display the original and modified images so that you can see the effect of the quantization. 2 3 1 % Load in the color image and convert it to grey-scale 2 M imread('images_L8_2.jpg'); 3 N uint8(mean (M, 3)); 4 7 8 %{ 9 YOUR CODE GOES HERE imshow(N) %look at the original image 10 %} 11 12 13 14 15 16 17 18 19 20 %THIS WILL DISPLAY THE QUANTIZED IMAGE 21 22 figure 23 Levels = uint8([32, 96, 160, 224]) %display each pixel as the mid-point of its range 24 imshow(Levels (N+1)) 25 Save C Reset MATLAB Documentation
Expert Answer:
Answer rating: 100% (QA)
The question involves writing a MATLAB script to quantize a greyscale image to just four ... View the full answer
Related Book For
Microeconomics An Intuitive Approach with Calculus
ISBN: 978-0538453257
1st edition
Authors: Thomas Nechyba
Posted Date:
Students also viewed these programming questions
-
Assume that a preferred stock starts paying a $5 annual dividend next year in perpetuity. What is this stock worth today if the required rate of a return is 8%?
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Net income Depreciation expense Accounts receivable increase (decrease) Inventory increase (decrease) Accounts payable increase (decrease) Accrued liabilities increase (decrease) O Changes in current...
-
Suppose Jackson Jets is a small company that customizes Learjets for wealthy clients. At present, the company's managers are negotiating with three potential customers for next year's sales. The...
-
Humble Management Services opened for business and completed these transactions in September. Sep. 1. H. Humble, the owner, invested $38,000 cash along with office equipment valued at $15,000 in the...
-
For a given x-value, the 95% confidence interval for the mean response will always be wider than the 95% prediction interval. In Exercises 5 and 6, determine whether the statement is true or false....
-
1. Complete pages 1 and 2 of Form 1040 for Marc and Michelle. 2. Complete Schedule 1 of Form 1040 for Marc and Michelle. (use the most recent form available). Form 1040: Not sure if correct? Schedule...
-
Flexible Budget. At normal capacity, Boulder Products Corp. manufactures 10,000 trail bikes. At that level, unit variable costs for the Assembly Department are: Direct...
-
The following data were obtained from a series of Charpy impact tests performed on four steels, each having a different manganese content. Plot the data and determine (a) The transition temperature...
-
a.) Describe how you would determine the cost of goods sold and the value of any ending inventory for financial reporting purposes. (No computations are required.) b.)You have just received an...
-
Sue was required to sign an NDA when she took a job at her new company. Why did the company require her to sign it?
-
What is a recursive method? Explain with an example of a recursive method? [K/U 5 marks] Question 2: What is the difference between linear search and binary search? What is the complexity of them?...
-
Write a java program to display prime numbers loop pattern. 2 35 7 11 13 17 19 23 29
-
An analytical chemist is titrating201.4 mLof a0.5900 M solution of trimethylamine CH33N with a 0.6600 M solutionof HNO3. The pKb of trimethylamine is 4.19. Calculate the pH of the base solution after...
-
Write a java program to accept array elements and display them.
-
Edible Insoles Corp. wants to expand their operations and decided to issue $2,000,000 of 3 year, 8.2% bonds, on 1/1/20. Interest is payable semiannually with payments on July 1 and December 31 of...
-
A circular concrete shaft liner with Youngs modulus of 3.4 million psi, Poissons ratio of 0.25, unconfined compressive strength 3,500 psi and tensile strength 350 psi is loaded to the verge of...
-
A: Suppose that all firms in the fast food restaurant business face U-shaped average cost curves prior to the introduction of a recurring license fee. The only output they produce is hamburgers....
-
In New York City, you are allowed to operate a taxi cab only if you carry a special taxi medallion made by the Taxi Commission of New York. Suppose 50,000 of these have been sold, and no further ones...
-
The Risks of Short Selling: In the text, we mentioned that short-selling can entail a lot more risk if the investors guesses are wildly incorrect than taking the more conventional long position of...
-
A roller cam is used to impart a periodic motion to the base of the spring-mass system shown in Fig. 4.41. If the coefficient of friction between the mass and the surface is \(\mu\), find the...
-
Three rival professors teaching English 1 all claim the honor of having the best students. To settle the issue, eight students are randomly drawn from each class and given the same exam. The exams...
-
One of the arguments in favor of distribution-free tests is that they are more appropriate for ordinal scale data. (This issue was addressed earlier in the book in a different context.) Give a reason...
Study smarter with the SolutionInn App