实验要求:

Reducing the Number of Gray Levels in an Image

Objective

To understand how the number of gray levels affect the image perceptual quality.

Main requirements:

Ability of programming with C, C++, or Matlab.

Instruction manual:

(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.

英文不懂的查字典,不做赘述。

编写MATLAB函数”reduceGrayLevel.m”:

function img_o = reduceGrayLevel( img_i, level )
%UNTITLED2 此处显示有关此函数的摘要
% 此处显示详细说明
imagesize = size(img_i);
num = 256 / level; %创建新的图像,与原图像大小相同
img_o = uint8(zeros(imagesize(1), imagesize(2))); % 灰度变换
for r = 1:1:imagesize(1)
for c = 1:1:imagesize(2)
img_o(r, c) = fix(double(img_i(r,c))/num) * 255 / (level-1);
end
end end

运行下面程序:

%%
clear all;
clc;
close all; %%
image_name = 'general_img.jpg';
image = imread(image_name); image_level_128 = reduceGrayLevel(image, 128);
image_level_64 = reduceGrayLevel(image, 64);
image_level_32 = reduceGrayLevel(image, 32);
image_level_16 = reduceGrayLevel(image, 16);
image_level_8 = reduceGrayLevel(image, 8);
image_level_4 = reduceGrayLevel(image, 4);
image_level_2 = reduceGrayLevel(image, 2); figure(1)
subplot(2,4,1), imshow(image)
subplot(2,4,2), imshow(image_level_128)
subplot(2,4,3), imshow(image_level_64)
subplot(2,4,4), imshow(image_level_32)
subplot(2,4,5), imshow(image_level_16)
subplot(2,4,6), imshow(image_level_8)
subplot(2,4,7), imshow(image_level_4)
subplot(2,4,8), imshow(image_level_2)

实验结果:

很明显,随着灰度级的减小,图片越来越不清晰。

数字图像处理实验(2):PROJECT 02-02, Reducing the Number of Gray Levels in an Image 标签: 图像处理MATLAB 2017-的更多相关文章

  1. 数字图像处理实验(总计23个)汇总 标签: 图像处理MATLAB 2017-05-31 10:30 175人阅读 评论(0)

    以下这些实验中的代码全部是我自己编写调试通过的,到此,最后进行一下汇总. 数字图像处理实验(1):PROJECT 02-01, Image Printing Program Based on Half ...

  2. 数字图像处理实验(12):PROJECT 05-03,Periodic Noise Reduction Using a Notch Filter 标签: 图像处理MATLAB 2017-0

    实验要求: Objective: To understand the principle of the notch filter and its periodic noise reducing abi ...

  3. 数字图像处理实验(1):PROJECT 02-01, Image Printing Program Based on Halftoning 标签: 图像处理MATLAB 2017-04-2

    实验要求: Image Printing Program Based on Halftoning Objective: To know in principle what is "halft ...

  4. 02.02.03第3章 餐饮项目案例(Power BI商业智能分析)

    02.02.03第3章 餐饮项目案例 02.02.03.01餐饮数据理解与读入 00:06:12 02.02.03.02餐饮数据处理 00:29:57 处理生成的表为: 02.02.03.03餐饮数据 ...

  5. 02.02.02 第2章 制作power bi图表(Power BI商业智能分析)

    ---恢复内容开始--- 02.02.02第2章 制作power bi图表 02.02.02.01 power pivot数据导入 00:08:43 02.02.02.02建立数据透视表 00:11: ...

  6. 02.02.01 第1章 简介及基础操作(Power BI商业智能分析)

    02.02.01.01 powerbi简介 00:10:59 02.02.01.02 query数据导入 00:03:26 具体操作实例如下: 02.02.01.03导入access数据 00:05: ...

  7. 面试题 02.02. [链表][双指针]返回倒数第 k 个节点

    面试题 02.02. 返回倒数第 k 个节点 方法一:使用外部空间 // 执行用时: 1 ms , 在所有 Java 提交中击败了 16.75% 的用户 // 内存消耗: 36.8 MB , 在所有 ...

  8. 数字图像处理实验(16):PROJECT 06-03,Color Image Enhancement by Histogram Processing 标签: 图像处理MATLAB 2017

    实验要求: Objective: To know how to implement image enhancement for color images by histogram processing ...

  9. 数字图像处理实验(15):PROJECT 06-02,Pseudo-Color Image Processing 标签: 图像处理MATLAB 2017-05-27 20:53

    实验要求: 上面的实验要求中Objective(实验目的)部分是错误的. 然而在我拿到的大纲中就是这么写的,所以请忽视那部分,其余部分是没有问题的. 本实验是使用伪彩色强调突出我们感兴趣的灰度范围,在 ...

随机推荐

  1. MySQL 创建千万集数据

    - MySQL测试任务:使用存储过程,往表中插入千万级数据,根据索引优化速度 -- 1.使用索引查询 -- 2.不使用索引查 -- 3.比较两者查询速度的差异 1.创建数据和索引 1.创建索引测试表 ...

  2. Unity自带寻路Navmesh

    自带寻路Navmesh的三大组件: 1.Nav Mesh Agent:主要挂在寻路物体上 2.Off Mesh Link:实现区域转移功能(例如,有时不一定只是在地面上进行寻路,可能有些高高的平台,平 ...

  3. VueJs路由跳转——vue-router的使用

    对于单页应用,官方提供了vue-router进行路由跳转的处理,本篇主要也是基于其官方文档写作而成. 安装 基于传统,我更喜欢采用npm包的形式进行安装. npm install vue-router ...

  4. NOI模拟赛 #4

    好像只有一个串串题可以做... 不会 dp 和数据结构啊 QAQ 10 + 20 + 100 = 130 T1 一棵树,每个点有一个能量的最大容量 $l_i$ 和一个增长速度 $v_i$,每次可以选一 ...

  5. 在winform下实现左右布局多窗口界面的方法(二)

    这篇文章主要介绍了在winform下实现左右布局多窗口界面的方法之续篇 的相关资料,需要的朋友可以参考下 在上篇文章在winform下实现左右布局多窗口界面的方法(一)已经实现了左右布局多窗口界面,今 ...

  6. 玩转C链表

    链表是C语言编程中常用的数据结构,比如我们要建一个整数链表,一般可能这么定义: 1 2 3 4 struct int_node {         int val;         struct in ...

  7. UOJ #55 & 洛谷 P3920 紫荆花之恋 —— 动态点分治+替罪羊树

    题目:http://uoj.ac/problem/55 https://www.luogu.org/problemnew/show/P3920 参考博客:https://www.cnblogs.com ...

  8. Python 列表的切片和连接

    一.定义一个list >>> a = [1, 3, 4, 5, 'a', 's'] >>> a [1, 3, 4, 5, 'a', 's'] 二.获取列表中前3个元 ...

  9. WPF案例:如何设计搜索框(自定义控件的原则和方法)

    我们平时自定义WPF控件的方法有:Style,DataTemplate,ControlTemplate, DependencyProperty, CustomControl等几个方法. 按照优先顺序应 ...

  10. ARM模式下创建Express Route

    在Azure的ARM模式下,创建Express Route的命令和ASM模式下是有一些区别的. 本文将介绍在ARM模式下,如果创建Express Route的Circuit. 1. 查看支持的Serv ...