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...
-
Forner Carpet Company produced high-grade carpeting materials for use in automobiles and recreational vans. Forner's products were sold to finishers, who cut and bound the material so that it would...
-
On April 17, 2018, the Loadstone Mining Company purchased the rights to a coal mine. The purchase price plus additional costs necessary to prepare the mine for extraction of the coal totaled...
-
X Ltd is a retail supermarket chain which regularly constructs its own superstores. During the year ending 31 December 1995, X Ltd began work on a new site. On 1 January 1995, a leasehold interest in...
-
Nasoff Company operates a small manufacturing facility as a supplement to its regular service activities. At the beginning of 2011, an asset account for the company showed the following balances:...
-
Makails Chocolate Limited is a manufacturer of premium chocolate bars. The manager of the company has provided you with the following information & asked for your assistance in preparing the master...
-
You have taken out a loan of $19,000 for 4 years with an interest rate of 3% compounded annually. The loan will be repaid by end of year payments. Fill in all the boxes below, and round all entries...
-
Please reply to the below comment: (agree/disagree and add more information regarding it) Comment : A general journal is a place where the business records every accounting transaction. It records ...
-
An investment opportunity that costs $40,000 generates $20,000 in cash inflows each of the next four years. What is the payback period for the investment?
-
A mother wants to put sufficient money in the bank to cover university expenses for her daughter in 15 years. She estimates that in 15 years $100,000 will be necessary to pay for university. The bank...
-
What is the value of a 10-year annuity in 10 years if the interest rate is 6 percent and each annuity payment is 100?
-
What is the IRR of an investment of \($1,000\) that yields cash flows of \($600\) in each of the first two years?
-
Your grandfather put $1,000 in the bank for you 48 years ago. The bank paid 6 percent interest compounded annually during this time period. How much is your grandfathers deposit worth today?
-
Question 40 Vaughn Co. has equipment with a carrying amount of $690,500. The expected future net cash flows from the equipment are $695,710, and its fair value is $617,920. The equipment is expected...
-
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...
-
Revise cash collections budget (Learning Objective 4) Turn to the original Whitewater Sporting Goods Data Set item 4. Suppose \(70 \%\) of sales are cash and \(30 \%\) are credit. Revise Whitewater's...
-
Revise inventory, purchases, and cost of goods sold budget (Learning Objective 4) Refer to the original Whitewater Sporting Goods Data Set item 5. Suppose cost of goods sold averages \(75 \%\) of...
-
Revise cash payments for purchases (Learning Objective 4) Refer to the original Whitewater Sporting Goods Data Set item 5. Suppose Whitewater Sporting Goods pays for \(60 \%\) of inventory purchases...
Study smarter with the SolutionInn App