Reducing the Number of Gray Levels in an Image
2011-10-02 00:47
435 查看
Problem:
(a) Write a computer program capable of reducing the number of gray levels in a image from 256 to 2, in integer powers of 2. The desired number of gray levels needs to be a variable input to your program.(b) Download Fig. 2.21(a) and duplicate the results shown in Fig. 2.21 of the book.
Solution:
reduceGrayLevel.m
function img = reduceGrayLevel(image, level) imageSize = size(image); num = 256 / level; img = uint8(zeros(imageSize(1), imageSize(2))); for r = 1:1:imageSize(1) for c = 1:1:imageSize(2) img(r, c) = fix(double(image(r, c)) / num) * 255 / (level-1); end end end
proj0201.m
clear; clc; image = imread('Fig0221(a)(ctskull-256).tif'); img1 = reduceGrayLevel(image, 128); img2 = reduceGrayLevel(image, 64); img3 = reduceGrayLevel(image, 32); img4 = reduceGrayLevel(image, 16); img5 = reduceGrayLevel(image, 8); img6 = reduceGrayLevel(image, 4); img7 = reduceGrayLevel(image, 2); subplot(2, 4, 1), imshow(image), subplot(2, 4, 2), imshow(img1), ... subplot(2, 4, 3), imshow(img2), subplot(2, 4, 4), imshow(img3), ... subplot(2, 4, 5), imshow(img4), subplot(2, 4, 6), imshow(img5), ... subplot(2, 4, 7), imshow(img6), subplot(2, 4, 8), imshow(img7);
Answer:
相关文章推荐
- 数字图像处理实验(2):PROJECT 02-02, Reducing the Number of Gray Levels in an Image
- 数字图像处理实验(2):PROJECT 02-02, Reducing the Number of Gray Levels in an Image 标签: 图像处理MATLAB 2017-
- Reducing the Number of Gray Levels, Zooming and Shrinking Images
- 图像灰度级减少及基本缩放(Reducing the Number of Gray Levels, Zooming and Shrinking Images)
- Reducing the Number of Gray Levels,Zoming and Shrinking Images
- Invalid update: invalid number of rows in section 0. The number of rows contained in an ....
- 删除tableview的section遇到crash:The number of rows contained in an existing section after the update
- Counting-the-number-of-set-bits-in-an-integer
- Is there a limit to the number of columns in an HBase row?
- 《How hard can it be? Estimating the difficulty of visual search in an image》和 PPT
- Count the number of bits that are on in an unsigned integer(计算一个无符整数中1Bit的个数)-- (1)
- Tooltip 显示大图的代码(show an enlarge image in the tooltip of the image)
- The role of an object storage system in the cloud
- Evaluate the value of an arithmetic expression in Reverse Polish Notation.
- What is the maximum number of files allowed in a HDFS directory?
- Changing The Size Of An Image
- - No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosing in
- Coursera-An Introduction to Interactive Programming in Python (Part 1)-Mini-project — “Guess the number” game
- The number of method references in a .dex file cannot exceed 64K. Error 解决方案
- 23 In Recovery Manager (RMAN), you are taking image copies of the data files of your production data