数字图像处理实验(2):PROJECT 02-02, Reducing the Number of Gray Levels in an Image 标签: 图像处理MATLAB 2017-
实验要求:
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-的更多相关文章
- 数字图像处理实验(总计23个)汇总 标签: 图像处理MATLAB 2017-05-31 10:30 175人阅读 评论(0)
以下这些实验中的代码全部是我自己编写调试通过的,到此,最后进行一下汇总. 数字图像处理实验(1):PROJECT 02-01, Image Printing Program Based on Half ...
- 数字图像处理实验(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 ...
- 数字图像处理实验(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 ...
- 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餐饮数据 ...
- 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: ...
- 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: ...
- 面试题 02.02. [链表][双指针]返回倒数第 k 个节点
面试题 02.02. 返回倒数第 k 个节点 方法一:使用外部空间 // 执行用时: 1 ms , 在所有 Java 提交中击败了 16.75% 的用户 // 内存消耗: 36.8 MB , 在所有 ...
- 数字图像处理实验(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 ...
- 数字图像处理实验(15):PROJECT 06-02,Pseudo-Color Image Processing 标签: 图像处理MATLAB 2017-05-27 20:53
实验要求: 上面的实验要求中Objective(实验目的)部分是错误的. 然而在我拿到的大纲中就是这么写的,所以请忽视那部分,其余部分是没有问题的. 本实验是使用伪彩色强调突出我们感兴趣的灰度范围,在 ...
随机推荐
- mac下用brew安装mongodb
分享到:QQ空间新浪微博腾讯微博人人网微信 mac 下安装mongoDB一般俩种方法. (1)下载源码,解压,编译,配置,启动 比较艰难的一种模式. (2)brew install mongodb , ...
- python list的extend和append方法
append: Appends object at the end. x = [1, 2, 3] x.append([4, 5]) print (x) gives you: [1, 2, 3, [4, ...
- inndb索引原理
###详解b+树如上图,是一颗b+树,关于b+树的定义可以参见B+树,这里只说一些重点,浅蓝色的块我们称之为一个磁盘块,可以看到每个磁盘块包含几个数据项(深蓝色所示)和指针(黄色所示),如磁盘块1包含 ...
- itunesconnect如何提交被决绝过了的相同版本号
遇到一次审核被拒,打算再次提交时,不想改变版本号,可以在xcode里把build版本号后面几个.1,比如version上次被拒时是1.1.3,build也是1.1.3,这次送审时version不变,b ...
- .net remoting和wcf自托管——一个bug引发的警示
一.解决问题,需要深入,并从细节入手,多从代码找原因,不能认为代码是死的,不会出错: 之前代码都运行良好,突然某一天,在我电脑上出问题了.出了问题,那就应该找出原因.其实这个问题,本身并不难,好歹给你 ...
- mysql之 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 11
问题描述:启动MySQL后,出现连接不上,报 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 11[root@mysql01 ~]# service ...
- CentOS7自动补齐
cenos7,最小安装,做服务器嘛.但是发现tab键的自动补齐功能没有:其实可以直接把centos7作为yum源,然后直接安装bash-completion yum install -y bash- ...
- bzoj 2839 集合计数 —— 二项式反演
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2839 设 \( f(i) \) 为至少 \( i \) 个选择,则 \( f(i) = C_ ...
- Kubernetes创建挂载共享存储的容器
原文链接:https://www.58jb.com/html/135.html 在上一次的Mysql容器中,已经使用过了配置宿主机目录挂载的方式,这样虽然方便但是不够安全:一般都是把数据存储在远程服务 ...
- python3 之 格式化json
import json json_string = None with open("json_file.json") as f: json_string = f.read() tr ...